From 8353376b24e6f2c038575c8d378c348c4ee5e092 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 14 Sep 2024 20:38:55 +0200 Subject: systemd-networkd: Allow templating --- ansible/plays/files/danneri/systemd-networkd/enp1s0.netdev | 1 - ansible/plays/files/danneri/systemd-networkd/enp1s0.network | 1 - ansible/plays/templates/danneri/systemd-networkd/enp1s0.netdev | 1 + .../plays/templates/danneri/systemd-networkd/enp1s0.network | 1 + ansible/roles/systemd-networkd/handlers/main.yml | 5 +++-- ansible/roles/systemd-networkd/tasks/main.yml | 10 ++++++---- 6 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 ansible/plays/files/danneri/systemd-networkd/enp1s0.netdev delete mode 100644 ansible/plays/files/danneri/systemd-networkd/enp1s0.network create mode 100644 ansible/plays/templates/danneri/systemd-networkd/enp1s0.netdev create mode 100644 ansible/plays/templates/danneri/systemd-networkd/enp1s0.network diff --git a/ansible/plays/files/danneri/systemd-networkd/enp1s0.netdev b/ansible/plays/files/danneri/systemd-networkd/enp1s0.netdev deleted file mode 100644 index 1e0ca6a..0000000 --- a/ansible/plays/files/danneri/systemd-networkd/enp1s0.netdev +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/ansible/plays/files/danneri/systemd-networkd/enp1s0.network b/ansible/plays/files/danneri/systemd-networkd/enp1s0.network deleted file mode 100644 index 1e0ca6a..0000000 --- a/ansible/plays/files/danneri/systemd-networkd/enp1s0.network +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/ansible/plays/templates/danneri/systemd-networkd/enp1s0.netdev b/ansible/plays/templates/danneri/systemd-networkd/enp1s0.netdev new file mode 100644 index 0000000..1e0ca6a --- /dev/null +++ b/ansible/plays/templates/danneri/systemd-networkd/enp1s0.netdev @@ -0,0 +1 @@ +# diff --git a/ansible/plays/templates/danneri/systemd-networkd/enp1s0.network b/ansible/plays/templates/danneri/systemd-networkd/enp1s0.network new file mode 100644 index 0000000..1e0ca6a --- /dev/null +++ b/ansible/plays/templates/danneri/systemd-networkd/enp1s0.network @@ -0,0 +1 @@ +# diff --git a/ansible/roles/systemd-networkd/handlers/main.yml b/ansible/roles/systemd-networkd/handlers/main.yml index 9656da4..5050e02 100644 --- a/ansible/roles/systemd-networkd/handlers/main.yml +++ b/ansible/roles/systemd-networkd/handlers/main.yml @@ -1,4 +1,5 @@ -- name: restart +- become: yes + name: reload systemd: name: systemd-networkd - state: restarted + state: reloaded diff --git a/ansible/roles/systemd-networkd/tasks/main.yml b/ansible/roles/systemd-networkd/tasks/main.yml index 13c167b..0e8856b 100644 --- a/ansible/roles/systemd-networkd/tasks/main.yml +++ b/ansible/roles/systemd-networkd/tasks/main.yml @@ -1,9 +1,11 @@ -- systemd: +- become: yes + systemd: name: systemd-networkd state: started enabled: yes -- loop: "{{ systemd_networkd__files | default([]) }}" - copy: +- become: yes + loop: "{{ systemd_networkd__files | default([]) }}" + template: src: "{{ item }}" dest: "/etc/systemd/network/{{ item | basename }}" - notify: restart + notify: reload -- cgit v1.2.3