ifupdown2: simple interfaces file configuration

This commit is contained in:
jeltz 2022-08-26 20:52:23 +02:00
parent e26d5dfc27
commit a5a4d28ccc
Signed by: jeltz
GPG Key ID: 800882B66C0C3326
4 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,3 @@
---
ifupdown2__interfaces: {}
...

View File

@ -0,0 +1,6 @@
---
- name: Restart networking
systemd:
name: networking.service
state: restarted
...

View File

@ -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

View 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 %}