ansible/playbooks/wol_enable.yml
ladislav.dusa afc7817a81 conf added
2024-12-11 16:33:42 +01:00

39 lines
984 B
YAML
Executable File

- hosts: datacenter
name: Enable WOL
become: true
tasks:
- name: Install ethtool
ansible.builtin.apt:
name: ethtool
state: present
- name: Display all interfaces name
debug:
var: ansible_facts.interfaces
- name: Get wifi adapter
set_fact:
wifi_adapter: '{{ item }}'
loop: '{{ ansible_facts.interfaces }}'
when: 'item.startswith("enp")'
- name: Creating a file with content
become: true
copy:
dest: "//etc/systemd/system/wol.service"
content: |
[Unit]
Description=Enable Wake On Lan
[Service]
Type=oneshot
ExecStart = /usr/sbin/ethtool --change {{ wifi_adapter }} wol g
[Install]
WantedBy=basic.target
owner: root
mode: '0744'
- name: Restart service wol, in all cases
ansible.builtin.service:
name: wol
state: restarted
enabled: true