main.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. # Deploys the infrastructure modifications needed to support SNOx node installation:
  3. #
  4. # - DNS zone files
  5. # - DNS zone configuration
  6. # - bastion zone delegation
  7. # - DHCP server modifications
  8. #
  9. # REQUIRES:
  10. # - variable "node" according to vms structure
  11. #
  12. - name: Publish forward DNS zone
  13. template:
  14. src: templates/sno.zone.j2
  15. dest: /var/named/{{ node.cluster }}.example.com.zone
  16. mode: 0640
  17. owner: root
  18. group: named
  19. notify:
  20. - reload_named
  21. - name: Configure DNS to load the published zone
  22. lineinfile:
  23. path: /etc/named.conf
  24. insertafter: "^# BEGIN ANSIBLE MANAGED DNS ZONES$"
  25. regexp: '^zone "{{ node.cluster }}.example.com"'
  26. line: 'zone "{{ node.cluster }}.example.com" { type master; file "{{ node.cluster }}.example.com.zone"; allow-update { none; }; };'
  27. state: present
  28. notify:
  29. - reload_named
  30. - name: Update reverse DNS zone
  31. lineinfile:
  32. path: /var/named/50.168.192.in-addr.arpa.zone
  33. insertafter: "^; BEGIN DYNAMIC 50 rZONE RECORDS$"
  34. regexp: "^{{ node.ip | regex_replace('^192.168.50.', '') }}"
  35. line: "{{ node.ip | regex_replace('^192.168.50.', '') }} IN PTR {{ node.name }}.{{ node.cluster }}.example.com."
  36. state: present
  37. register: zoneupdate
  38. # TODO
  39. #- name: Extract the serial if rzone was updated
  40. #- name: Bump up the serial if rzone was updated
  41. - name: Delegate the new zone to utility from bastion
  42. delegate_to: bastion.lab.example.com
  43. template:
  44. src: templates/dnsmasq.conf.j2
  45. dest: /etc/dnsmasq.d/{{ node.cluster }}.conf
  46. mode: 0644
  47. owner: root
  48. group: root
  49. notify: restart_bastion_dnsmasq
  50. - name: Make sure DHCP server recognizes us
  51. lineinfile:
  52. path: /etc/dhcp/dhcpd.conf
  53. insertafter: "^# BEGIN ANSIBLE MANAGED DHCP CONFIG$"
  54. regexp: "hardware ethernet {{ node.mac | regex_replace('^01-', '') | regex_replace('-', ':') }}"
  55. line: 'host {{ node.name }}-{{ node.cluster }} { hardware ethernet {{ node.mac | regex_replace("^01-", "") | regex_replace("-", ":") }}; fixed-address {{ node.ip }}; option host-name "{{ node.name }}.{{ node.cluster }}.example.com."; }'
  56. state: present
  57. notify: restart_dhcpd
  58. ...