--- - name: Install DNS packages become: yes ignore_errors: yes package: name: - bind - net-tools - iputils state: present - name: Set up /etc/resolv.conf become: yes copy: dest: /etc/resolv.conf content: "domain {{ replica_domain }}\nnameserver {{ dns }}\n" owner: root group: root mode: 0644 - name: Set up /etc/hosts vars: ansible_become_password: "{{ passwords[inventory_hostname] }}" become: yes lineinfile: dest: /etc/hosts regexp: '^127.0.0.1[ \t]+localhost' line: "127.0.0.1 localhost localhost.localdomain {{ inventory_hostname }} {{ inventory_hostname }}.{{ replica_domain }}" state: present