Selaa lähdekoodia

cleanup handlers; add zone delegation; fixing dhcp

Grega Bremec 3 vuotta sitten
vanhempi
commit
1ea21cce72

+ 2 - 14
roles/deploy-infra/handlers/main.yml

@@ -5,28 +5,16 @@
     enabled: yes
     state: reloaded
 
-- name: reload_haproxy
-  service:
-    name: haproxy
-    enabled: yes
-    state: reloaded
-
-- name: restart_chronyd
-  service:
-    name: chronyd
-    enabled: yes
-    state: restarted
-
 - name: restart_dhcpd
   service:
     name: dhcpd
     enabled: yes
     state: restarted
 
-- name: reload_bastion_dnsmasq
+- name: restart_bastion_dnsmasq
   delegate_to: bastion.lab.example.com
   service:
     name: dnsmasq
     enabled: yes
-    state: reloaded
+    state: restarted
 ...

+ 18 - 2
roles/deploy-infra/tasks/main.yml

@@ -41,6 +41,22 @@
 #- name: Extract the serial if rzone was updated
 #- name: Bump up the serial if rzone was updated
 
-# TODO: delegate zone on bastion
-# TODO: make sure DHCP server recognizes us
+- name: Delegate the new zone to utility from bastion
+  delegate_to: bastion.lab.example.com
+  template:
+    src: templates/dnsmasq.conf.j2
+    dest: /etc/dnsmasq.d/{{ node.cluster }}.conf
+    mode: 0644
+    owner: root
+    group: root
+  notify: restart_bastion_dnsmasq
+
+- name: Make sure DHCP server recognizes us
+  lineinfile:
+    path: /etc/dhcp/dhcpd.conf
+    insertafter: "^# BEGIN ANSIBLE MANAGED DHCP CONFIG$"
+    regexp: "hardware ethernet {{ node.mac | regex_replace('^01-', '') | regex_replace_all('-', ':') }}"
+    line: 'host {{ node.name }}-{{ node.cluster }} { hardware ethernet {{ node.mac | regex_replace("^01-", "") | regex_replace_all("-", ":") }}; fixed-address {{ node.ip }}; option host-name "{{ node.name }}.{{ node.cluster }}.example.com."; }'
+    state: present
+  notify: restart_dhcpd
 ...

+ 1 - 0
roles/deploy-infra/templates/dnsmasq.conf.j2

@@ -0,0 +1 @@
+server=/{{ node.cluster }}.example.com/172.25.250.253