41 lines
807 B
YAML
41 lines
807 B
YAML
---
|
|
- name: Gather package facts
|
|
package_facts:
|
|
manager: apt
|
|
|
|
- name: Check if ifupdown2 is installed
|
|
set_fact:
|
|
must_mask: "{{ 'ifupdown2' not in ansible_facts.packages }}"
|
|
|
|
- name: Mask networking before installing ifupdown2
|
|
systemd:
|
|
name: networking.service
|
|
masked: true
|
|
when: must_mask
|
|
|
|
- name: Install ifupdown2
|
|
apt:
|
|
name: ifupdown2
|
|
|
|
- name: Unmask networking now that ifupdown2 is installed
|
|
systemd:
|
|
name: networking.service
|
|
masked: false
|
|
when: must_mask
|
|
|
|
- name: Configure ifupdown2
|
|
template:
|
|
src: interfaces.j2
|
|
dest: /etc/network/interfaces
|
|
owner: root
|
|
group: root
|
|
mode: u=rw,g=r,o=
|
|
notify:
|
|
- Restart networking
|
|
|
|
- name: Enable and start networking
|
|
systemd:
|
|
name: networking.service
|
|
state: started
|
|
enabled: true
|
|
...
|