1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/network/tasks/netplan.yml

70 lines
2 KiB
YAML
Raw Normal View History

2019-05-04 04:54:27 +00:00
- name: Figure out netplan file name
2018-12-15 18:55:18 +00:00
shell: ls /etc/netplan
2018-12-13 11:07:08 +00:00
register: netplan
2018-12-13 16:10:36 +00:00
- name: Disable cloud-init the easy way
2018-12-13 13:34:29 +00:00
shell: touch /etc/cloud/cloud-init.disabled
2018-12-15 18:55:18 +00:00
when: ("item" == "50-cloud-init.yaml")
2018-12-13 16:43:11 +00:00
with_items:
- "{{ netplan.stdout_lines }}"
2018-12-13 11:40:36 +00:00
2018-12-13 11:07:08 +00:00
- name: Remove stock netplan template
file:
state: absent
path: /etc/netplan/{{ item }}
2018-12-13 16:43:11 +00:00
with_items:
- "{{ netplan.stdout_lines }}"
2018-12-29 19:49:06 +00:00
when: netplan.stdout.find("yaml") != -1
2018-12-13 11:07:08 +00:00
2018-12-29 20:14:56 +00:00
- name: Cheap way to do systemd unmask
file:
state: absent
dest: /etc/systemd/system/systemd-networkd-wait-online.service
2018-12-16 13:52:50 +00:00
- name: Ensure systemd-networkd-wait-online is enabled
2018-12-13 16:10:36 +00:00
systemd:
name: "{{ item }}"
enabled: yes
with_items:
- systemd-networkd-wait-online
2019-05-24 07:06:43 +00:00
when: systemd_networkd_active | bool
2018-12-13 11:07:08 +00:00
# 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:
2018-12-29 19:49:06 +00:00
dest: /etc/netplan/01-iiab-config.yaml
2018-12-13 11:07:08 +00:00
src: network/netplan.j2
backup: no
2018-12-16 13:52:50 +00:00
# should blow up here if we messed up the yml file
2018-12-14 19:54:46 +00:00
#- name: Generate netplan config
# shell: netplan generate --debug
2018-12-13 11:07:08 +00:00
2018-12-14 19:54:46 +00:00
#- name: Stopping services
# include_tasks: down-debian.yml
2018-12-13 11:40:36 +00:00
# wants a controlling terminal for the ENTER key, so it fails
2018-12-14 19:54:46 +00:00
#- name: Test netplan config
# shell: netplan try --debug --timeout=2
# register: test-netplan
# ignore_errors: True
2018-12-13 11:07:08 +00:00
2018-12-13 11:40:36 +00:00
# and does not apply the generated config until rebooted
# or ignore the above test - on the fence atm...
2018-12-14 19:54:46 +00:00
#- name: Reload netplan
# shell: netplan apply
# when: not no_net_restart and test-netplan == "Configuration accepted"