summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/network')
-rw-r--r--ansible/roles/network/tasks/main.yml40
-rw-r--r--ansible/roles/network/templates/network/custom.link6
-rw-r--r--ansible/roles/network/templates/network/custom.network38
3 files changed, 84 insertions, 0 deletions
diff --git a/ansible/roles/network/tasks/main.yml b/ansible/roles/network/tasks/main.yml
new file mode 100644
index 0000000..5aaaeff
--- /dev/null
+++ b/ansible/roles/network/tasks/main.yml
@@ -0,0 +1,40 @@
1---
2#- name: plop netplan
3# copy:
4# src: "{{ inventory_hostname }}.yaml"
5# dest: "/etc/netplan/20-customNetworking.yaml"
6# register: netplanCopy
7#
8#- name: generate netplan
9# command: netplan generate
10# register: netplanGenerated
11# when: netplanCopy.changed
12#
13#- name: apply netplan
14# command: netplan apply
15# when: netplanGenerated.changed
16
17- name: configure public network link through systemd directly
18 template:
19 src: network/custom.link
20 dest: "/etc/systemd/network/custom-{{ network.ethernets.interface }}.link"
21 register: networkUpdated
22
23- name: configure public network address through systemd directly
24 template:
25 src: network/custom.network
26 dest: "/etc/systemd/network/custom-{{ network.ethernets.interface }}.network"
27 register: networkUpdated
28
29- name: reload network since configuration changed
30 command: systemctl restart systemd-networkd
31 when: networkUpdated.changed
32
33- name: re-query ansible facts since system changed
34 setup:
35 gather_subset:
36 - "!all"
37 - "!min"
38 - network
39 when: networkUpdated.changed
40
diff --git a/ansible/roles/network/templates/network/custom.link b/ansible/roles/network/templates/network/custom.link
new file mode 100644
index 0000000..e3bc5a8
--- /dev/null
+++ b/ansible/roles/network/templates/network/custom.link
@@ -0,0 +1,6 @@
1[Match]
2OriginalName={{ network.ethernets.interface }}
3
4[Link]
5WakeOnLan=off
6MACAddress={{ network.ethernets.macaddress }}
diff --git a/ansible/roles/network/templates/network/custom.network b/ansible/roles/network/templates/network/custom.network
new file mode 100644
index 0000000..5a8b74e
--- /dev/null
+++ b/ansible/roles/network/templates/network/custom.network
@@ -0,0 +1,38 @@
1[Match]
2Name={{ network.ethernets.interface }}
3
4#{% for net in network.ethernets.networks %}
5#[Network]
6#Address={{ net.subnet }}
7#{% if net.gateway is defined %}
8#Gateway={{ net.gateway }}
9#{% endif %}
10#
11#{% endfor %}
12
13
14{% for addr in network.ethernets.addresses %}
15[Address]
16Address={{ addr }}
17
18{% endfor %}
19
20{% for net in network.ethernets.networks %}
21[Network]
22Address={{ net.subnet }}
23{% if net.gateway is defined %}
24Gateway={{ net.gateway }}
25{% endif %}
26
27{% endfor %}
28
29
30{% for route in network.ethernets.routes %}
31[Route]
32Destination={{ route.to }}
33Gateway={{ route.via }}
34{% if route['on-link'] %}
35GatewayOnlink=true
36{% endif %}
37
38{% endfor %}
Powered by cgit v1.2.3 (git 2.41.0)