From 4feaad11f951bba426974d0d47ffe6f502d27090 Mon Sep 17 00:00:00 2001 From: Vlad R Date: Fri, 10 May 2024 09:41:11 +0000 Subject: [PATCH] Added playbook that sets the netplan of the servers to only use the internal DNS --- dnaclab_linux/prestage_update_dns.yaml | 31 ++++++++++++++++++++++++++ dnaclab_linux/reboot.yml | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 dnaclab_linux/prestage_update_dns.yaml diff --git a/dnaclab_linux/prestage_update_dns.yaml b/dnaclab_linux/prestage_update_dns.yaml new file mode 100644 index 0000000..63669bb --- /dev/null +++ b/dnaclab_linux/prestage_update_dns.yaml @@ -0,0 +1,31 @@ +--- +- name: Change the netplan configuration to only allow the internal DNS server + hosts: all + become: yes + vars_files: + - global_vars/main.yml + + tasks: + + - name: Check if the netplan configuration is present + ansible.builtin.stat: + path: /etc/netplan/00-installer-config.yaml + + - name: Set the new netplan to use only the internal DNS + ansible.builtin.command: netplan set ethernets.ens160.nameservers.addresses=[10.221.0.100] + + - name: Apply the new netplan + ansible.builtin.command: netplan apply + + - name: Restart the resolved service + ansible.builtin.command: systemctl restart systemd-resolved.service + + - name: Get currently configured DNS servers + ansible.builtin.command: netplan get ethernets.ens160.nameservers.addresses + register: dns_check + + - name: Validate that only the internal DNS is configured + ansible.builtin.debug: + msg: Change successfull! + when: dns_check.stdout == "- 10.221.0.100" + diff --git a/dnaclab_linux/reboot.yml b/dnaclab_linux/reboot.yml index d29a135..cef1974 100644 --- a/dnaclab_linux/reboot.yml +++ b/dnaclab_linux/reboot.yml @@ -1,6 +1,6 @@ --- - name: Reboots linux host and checks status - hosts: kubernetes_dev + hosts: kubernetes become: yes vars_files: - global_vars/main.yml