--- - name: make sure required software is installed hosts: all become: yes tasks: - name: ensure the software is there yum: name: "{{ packages }}" state: latest - name: deploy corresponding dns service and configuration hosts: dnsservers,caching_ns become: yes tasks: - name: process any templates and publish them template: src: "{{ item.src }}" dest: "{{ item.dest }}" owner: "{{ item.owner }}" group: "{{ item.group }}" mode: "{{ item.mode }}" notify: - test configuration validity - reload or restart the service loop: "{{ configs }}" - name: deploy the static files as well copy: src: "{{ item.src }}" dest: "{{ item.dest }}" owner: "{{ item.owner }}" group: "{{ item.group }}" mode: "{{ item.mode }}" notify: them handlerz loop: "{{ staticfiles }}" - name: execute handlers if necessary meta: flush_handlers - name: ensure the service is started and enabled to start automatically service: name: "{{ service }}" state: started enabled: yes - name: ensure firewall is open for the service firewalld: service: "{{ fwsvc }}" state: enabled immediate: yes permanent: yes handlers: - name: test configuration validity listen: them handlerz command: "{{ item }}" changed_when: false loop: "{{ test_programs }}" - name: restart the service listen: them handlerz service: name: "{{ service }}" state: restarted