1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/network/tasks/netplan.yml
2018-12-15 00:32:33 -06:00

74 lines
2.2 KiB
YAML

# netplan.yml
- name: Figure out netplan file name on Ubuntu 18
shell: ls /etc/netplan | grep -v -e 01-iiab-config
register: netplan
- name: Disable cloud-init the easy way
shell: touch /etc/cloud/cloud-init.disabled
when: "{{ netplan }}" == "50-cloud-init.yaml"
- name: Remove stock netplan template
file:
state: absent
dest: /etc/netplan/{{ netplan }}
when: netplan != ""
### NM might need attention also
- name: Disable the stock dnsmasq unit file that starts too early with systemd_networkd_active
systemd:
name: dnsmasq
enabled: no
when: systemd_networkd_active
- name: Install dnsmasq helper unit file when systemd_networkd_active
template:
src: network/dnsmasq.service.u18
dest: /etc/systemd/system/iiab-dnsmasq.service
when: systemd_networkd_active
- name: Ensure required dnsmasq unit files are enabled for reboot systemd_networkd_active
systemd:
name: "{{ item }}"
enabled: yes
with_items:
- iiab-dnsmasq
- systemd-networkd-wait-online
when: systemd_networkd_active
# ICO will always set gui_static_wan_ip away from the default of 'unset' while
# gui_static_wan turns dhcp on/off through wan_ip in computed_network and
# overrides gui_static_wan_ip that is present. Changing wan_ip in local_vars
# is a oneway street to static.
- name: Static IP computing CIDR
shell: netmask {{ wan_ip }}/{{ wan_netmask }} | awk -F "/" '{print $2}'
register: CIDR
when: wan_ip != "dhcp"
- name: Static IP setting CIDR
set_fact:
wan_cidr: "{{ CIDR.stdout }}"
when: wan_ip != "dhcp"
- name: Supply netplan template
template:
dest: /etc/netplan/01-iiab-config
src: network/netplan.j2
backup: no
- name: generate netplan config
shell: netplan generate --debug
- name: Stopping services
include_tasks: down-debian.yml
# wants a controlling terminal for the ENTER key, so it fails
- name: test netplan config
shell: netplan try --debug --timeout=2
register: test-netplan
ignore_errors: True
# and does not apply the generated config until rebooted
# or ignore the above test - on the fence atm...
- name: Reload netplan
shell: netplan apply
when: not no_net_restart and test-netplan == "Configuration accepted"