2023-09-18 16:18:30 +02:00
|
|
|
- hosts: omv
|
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:
|
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 }}'
|
|
|
|
when: 'item.startswith("en")'
|
|
|
|
|
2023-09-18 16:16:59 +02:00
|
|
|
- name: Creating config
|
2023-09-18 17:08:42 +02:00
|
|
|
become: yes
|
2023-09-18 16:16:59 +02:00
|
|
|
ansible.builtin.copy:
|
2023-09-18 17:08:42 +02:00
|
|
|
|
2023-09-18 16:16:59 +02:00
|
|
|
dest: "/etc/systemd/system/wol.service"
|
|
|
|
content: |
|
|
|
|
[Unit]
|
|
|
|
Description=Enable Wake On Lan
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2023-09-18 17:29:51 +02:00
|
|
|
ExecStart = /usr/sbin/ethtool --change {{ wifi_adapter }} wol g
|
2023-09-18 16:16:59 +02:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=basic.target
|
|
|
|
owner: root
|
2023-09-18 17:31:52 +02:00
|
|
|
mode: '0744'
|
|
|
|
- name: Restart service wol, in all cases
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: wol
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|