Configure /etc/network/interfaces and /etc/resolv.conf using Ansible #98

Merged
jeltz merged 7 commits from ifupdown2 into master 2022-08-27 04:55:31 +02:00
4 changed files with 31 additions and 0 deletions
Showing only changes of commit a5a4d28ccc - Show all commits

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 masked: false
when: must_mask 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 - name: Enable and start networking
systemd: systemd:
name: networking.service 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 %}