--- - name: (caching-nameserver.yml) update apt: update_cache: true cache_valid_time: "{{ 0 if apt_config_updated is defined and apt_config_updated.changed else apt_update_cache_valid_time }}" when: apt_update|bool tags: - apt-caching-nameserver - name: (caching-nameserver.yml) dpkg --configure command: > dpkg --configure -a args: warn: false changed_when: _dpkg_configure.stdout_lines | length register: _dpkg_configure when: apt_dpkg_configure|bool tags: - apt-caching-nameserver - name: (caching-nameserver.yml) upgrade apt: upgrade: "{{ apt_upgrade_type }}" update_cache: true dpkg_options: "{{ apt_upgrade_dpkg_options | join(',') }}" when: apt_upgrade|bool tags: - apt-caching-nameserver - name: (caching-nameserver.yml) Install bind9 packages apt: name: "{{ apt_bind9_pkgs }}" state: present when: apt_install_bind9_packages|bool == true tags: - apt-caching-nameserver - name: (caching-nameserver.yml) Create directory /var/log/named if it does not exist file: path: /var/log/named state: directory owner: bind group: bind mode: '0755' - name: (caching-nameserver.yml) update named.conf.options configuration file template: src: etc/bind/named.conf.options.j2 dest: /etc/bind/named.conf.options backup: yes owner: root group: bind mode: 0644 #validate: visudo -cf %s tags: - sudoers-global-configuration - name: (caching-nameserver.yml) Add 127.0.0.1 as first nameserver entry to /etc/resolv.conf lineinfile: path: /etc/resolv.conf line: nameserver 127.0.0.1 firstmatch: yes insertbefore: '^nameserver' state: present owner: root group: root mode: '0644' - name: (caching-nameserver.yml) Start service bind9, if not started service: name: bind9 state: reloaded enabled: yes