Grega Bremec 1 год назад
Родитель
Сommit
74d13b81f1
3 измененных файлов с 29 добавлено и 0 удалено
  1. 5 0
      pre-flight.yml
  2. 6 0
      roles/add-hosts/handlers/main.yml
  3. 18 0
      roles/add-hosts/tasks/main.yml

+ 5 - 0
pre-flight.yml

@@ -10,4 +10,9 @@
       tags: check
     - role: fix-operators
       tags: fix
+- name: Class DNS changes on bastion.
+  hosts: bastion.lab.example.com
+  gather_subset: min
+    - role: add-hosts
+      tags: fix
 ...

+ 6 - 0
roles/add-hosts/handlers/main.yml

@@ -0,0 +1,6 @@
+---
+- name: Restart dnsmasq
+  service:
+    name: dnsmasq
+    state: restarted
+...

+ 18 - 0
roles/add-hosts/tasks/main.yml

@@ -0,0 +1,18 @@
+---
+# Adds sso.lab.example.com and idm.lab.example.com as aliases for workstation to /etc/hosts
+# Must be executed on bastion.lab.example.com
+#
+# Basically there is a line with workstation IP there...
+#
+#   172.25.250.9    workstation.lab.example.com workstation
+#
+# And it must have the above hostnames added, theen dnsmasq restarted.
+- name: Make sure hostnames are in /etc/hosts
+  ansible.builtin.lineinfile:
+    path: /etc/hosts
+    regexp: "^172.25.250.9\s+"
+    line: "172.25.250.9    workstation.lab.example.com workstation sso.lab.example.com idm.lab.example.com"
+    state: present
+  notify:
+    - Restart dnsmasq
+...