From cdef59b3488b0d5e9a93f38ab3df87b58fa84295 Mon Sep 17 00:00:00 2001 From: vincent Date: Sat, 10 Dec 2022 18:50:44 +0100 Subject: [PATCH] feat: add wol configuration --- defaults/main.yml | 3 +++ molecule/default/molecule.yml | 3 +++ tasks/wol.yml | 9 +++++++++ templates/50-wired.link | 7 +++++++ 4 files changed, 22 insertions(+) create mode 100644 tasks/wol.yml create mode 100644 templates/50-wired.link diff --git a/defaults/main.yml b/defaults/main.yml index f9e8cc5..3ef3974 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -42,3 +42,6 @@ system_ssh_custom_host: [] # - host: # user: # keyfile: + +system_wol_enable: False +system_wol_mac: "{{ ansible_default_ipv4.macaddress }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index ee6745d..8060e9e 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -42,5 +42,8 @@ provisioner: debian: user: name: user + group_vars: + all: + system_wol_enable: True verifier: name: ansible diff --git a/tasks/wol.yml b/tasks/wol.yml new file mode 100644 index 0000000..b57386b --- /dev/null +++ b/tasks/wol.yml @@ -0,0 +1,9 @@ +- name: Configure wol + ansible.builtin.template: + src: 50-wired.link + dest: /etc/systemd/network/ + owner: root + group: root + mode: 0644 + become: true + when: system_wol_enable is true diff --git a/templates/50-wired.link b/templates/50-wired.link new file mode 100644 index 0000000..5f8ae3e --- /dev/null +++ b/templates/50-wired.link @@ -0,0 +1,7 @@ +[Match] +MACAddress={{ system_wol_mac }} + +[Link] +NamePolicy=kernel database onboard slot path +MACAddressPolicy=persistent +WakeOnLan=magic