main.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. - name: install unbound for Debian OS family
  3. apt: pkg=unbound state={{ unbound_pkg_state }}
  4. when: ansible_os_family == 'Debian' and unbound_only_zones == false
  5. tags: ["packages","unbound"]
  6. - name: install unbound for RedHat OS family
  7. yum: name=unbound state={{ unbound_pkg_state }}
  8. when: ansible_os_family == 'RedHat' and unbound_only_zones == false
  9. tags: ["packages","unbound"]
  10. - name: Ensure zones folder exist
  11. file: path=/etc/unbound/conf.d state=directory mode=755
  12. notify: restart unbound
  13. tags: ["configuration","unbound"]
  14. - name: Ensure log file exist
  15. file: path={{unbound_logfile}} state=touch mode=755 owner=unbound
  16. notify: restart unbound
  17. tags: ["configuration","unbound"]
  18. - name: configure add independant config file
  19. template:
  20. src={{item}}.j2
  21. dest="/etc/unbound/conf.d/{{item}}"
  22. with_items:
  23. - 01general.conf
  24. - 99forward_zone.conf
  25. notify: restart unbound
  26. when: unbound_only_zones == false
  27. tags: ["configuration","unbound"]
  28. - name: configure unbound zones
  29. template:
  30. src=10zone.conf.j2
  31. dest="/etc/unbound/conf.d/10{{item.name}}.conf"
  32. with_items: unbound_zones
  33. notify: restart unbound
  34. tags: ["configuration","unbound"]
  35. - name: retreive unbound conf file list
  36. shell: /bin/ls /etc/unbound/conf.d/
  37. register: unbound_conf_list
  38. always_run: true
  39. tags: ["configuration","unbound"]
  40. - name: configure unbound.conf to include all configuration
  41. template:
  42. src=unbound.conf.j2
  43. dest=/etc/unbound/unbound.conf
  44. validate="/usr/sbin/unbound-checkconf %s"
  45. notify: restart unbound
  46. tags: ["configuration","unbound"]
  47. - name: ensure unbound is started/stopped
  48. service:
  49. name=unbound
  50. state={{ unbound_service_state }}
  51. enabled={{ unbound_service_enabled }}
  52. pattern="unbound"
  53. tags: ["service","unbound"]