ifupdown2: simple interfaces file configuration
This commit is contained in:
parent
e26d5dfc27
commit
a5a4d28ccc
4 changed files with 31 additions and 0 deletions
3
roles/ifupdown2/defaults/main.yml
Normal file
3
roles/ifupdown2/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
ifupdown2__interfaces: {}
|
||||
...
|
6
roles/ifupdown2/handlers/main.yml
Normal file
6
roles/ifupdown2/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Restart networking
|
||||
systemd:
|
||||
name: networking.service
|
||||
state: restarted
|
||||
...
|
|
@ -23,6 +23,16 @@
|
|||
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
|
||||
|
|
12
roles/ifupdown2/templates/interfaces.j2
Normal file
12
roles/ifupdown2/templates/interfaces.j2
Normal file
|
@ -0,0 +1,12 @@
|
|||
{{ ansible_managed | comment }}
|
||||
|
||||
{% for name, iface in ifupdown2__interfaces.items() %}
|
||||
allow-hotplug {{ name }}
|
||||
iface {{ name }}
|
||||
{% for address in iface.addresses %}
|
||||
address {{ address | ipaddr }}
|
||||
{% endfor %}
|
||||
{% for gateway in iface.gateways %}
|
||||
gateway {{ gateway | ipaddr }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
Loading…
Reference in a new issue