2024-06-27 00:19:16 +02:00
|
|
|
- hosts: datacenter
|
2023-09-18 16:16:59 +02:00
|
|
|
name: Enable WOL
|
2023-09-18 17:07:10 +02:00
|
|
|
become: true
|
2023-09-18 16:16:59 +02:00
|
|
|
tasks:
|
2024-06-27 00:19:16 +02:00
|
|
|
- name: Install ethtool
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: ethtool
|
|
|
|
state: present
|
2023-09-18 17:10:34 +02:00
|
|
|
- name: Display all interfaces name
|
|
|
|
debug:
|
2023-09-18 17:18:39 +02:00
|
|
|
var: ansible_facts.interfaces
|
2023-09-18 17:28:09 +02:00
|
|
|
- name: Get wifi adapter
|
|
|
|
set_fact:
|
|
|
|
wifi_adapter: '{{ item }}'
|
|
|
|
loop: '{{ ansible_facts.interfaces }}'
|
2024-11-27 17:28:07 +01:00
|
|
|
when: 'item.startswith("enp")'
|
|
|
|
|
|
|
|
- name: Creating a file with content
|
2024-06-27 00:19:16 +02:00
|
|
|
become: true
|
2024-11-27 17:28:07 +01:00
|
|
|
copy:
|
|
|
|
dest: "//etc/systemd/system/wol.service"
|
2023-09-18 16:16:59 +02:00
|
|
|
content: |
|
2024-11-27 17:28:07 +01:00
|
|
|
[Unit]
|
|
|
|
Description=Enable Wake On Lan
|
2023-09-18 16:16:59 +02:00
|
|
|
|
2024-11-27 17:28:07 +01:00
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart = /usr/sbin/ethtool --change {{ wifi_adapter }} wol g
|
2023-09-18 16:16:59 +02:00
|
|
|
|
2024-11-27 17:28:07 +01:00
|
|
|
[Install]
|
|
|
|
WantedBy=basic.target
|
2023-09-18 16:16:59 +02:00
|
|
|
owner: root
|
2023-09-18 17:31:52 +02:00
|
|
|
mode: '0744'
|
2024-11-27 17:28:07 +01:00
|
|
|
|
2023-09-18 17:31:52 +02:00
|
|
|
- name: Restart service wol, in all cases
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: wol
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|