deploy-dns.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. - name: make sure required software is installed
  3. hosts: all
  4. become: yes
  5. gather_facts: no
  6. tasks:
  7. - name: ensure the software is there
  8. yum:
  9. name: "{{ packages }}"
  10. state: latest
  11. - name: deploy corresponding dns service and configuration
  12. hosts: dnsservers,caching_ns
  13. become: yes
  14. gather_facts: no
  15. tasks:
  16. - name: process any templates and publish them
  17. template:
  18. src: "{{ item.src }}"
  19. dest: "{{ item.dest }}"
  20. owner: "{{ item.owner }}"
  21. group: "{{ item.group }}"
  22. mode: "{{ item.mode }}"
  23. notify:
  24. - test configuration validity
  25. - restart the service
  26. loop: "{{ configs }}"
  27. when: configs is defined
  28. - name: deploy the static files as well
  29. copy:
  30. src: "{{ item.src }}"
  31. dest: "{{ item.dest }}"
  32. owner: "{{ item.owner }}"
  33. group: "{{ item.group }}"
  34. mode: "{{ item.mode }}"
  35. notify: them handlerz
  36. loop: "{{ staticfiles }}"
  37. when: staticfiles is defined
  38. - name: execute handlers if necessary
  39. meta: flush_handlers
  40. - name: ensure the service is started and enabled to start automatically
  41. service:
  42. name: "{{ service }}"
  43. state: started
  44. enabled: yes
  45. - name: ensure firewall is open for the service
  46. firewalld:
  47. service: "{{ fwsvc }}"
  48. state: enabled
  49. immediate: yes
  50. permanent: yes
  51. handlers:
  52. - name: test configuration validity
  53. listen: them handlerz
  54. command: "{{ item }}"
  55. changed_when: false
  56. loop: "{{ test_programs }}"
  57. - name: restart the service
  58. listen: them handlerz
  59. service:
  60. name: "{{ service }}"
  61. state: restarted