From ad4bec22f71fd772ce52b453550f629d81858bc9 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 27 Feb 2021 08:45:57 -0600 Subject: [PATCH] Cleanup --- roles/netplan-static-ip/tasks/main.yml | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/roles/netplan-static-ip/tasks/main.yml b/roles/netplan-static-ip/tasks/main.yml index e0a43d3..3fdb431 100644 --- a/roles/netplan-static-ip/tasks/main.yml +++ b/roles/netplan-static-ip/tasks/main.yml @@ -1,3 +1,31 @@ #!/usr/bin/env ansible-playbook # vim:ft=ansible: - +--- +- name: disable cloud-init networking + copy: + dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg + content: 'network: {config: disabled}' + # We don't apply network config after doing this because it doesn't actually + # matter. The next config comes after it and overrides it anyway. + # I just do this to make things cleaner. +- name: remove 50-cloud-init.yaml + file: path=/etc/netplan/50-cloud-init.yaml state=absent +- name: configure netplan static ip + copy: + dest: /etc/netplan/51-static-ip.yaml + # Note: some syntax highlighters will say the stanza below is yaml + # It's not. It's a heredoc + content: | + network: + ethernets: + eth0: + dhcp4: no + addresses: + - {{ static_ip }} + gateway4: {{ netplan_gateway }} + nameservers: + addresses: {{ netplan_addresses }} + register: netplan +- name: apply netplan + command: netplan apply + when: netplan is changed