mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-10-29 01:20:07 +01:00
40 lines
1.0 KiB
YAML
Executable File
40 lines
1.0 KiB
YAML
Executable File
- name: Install ethtool
|
|
ansible.builtin.apt:
|
|
name: ethtool
|
|
state: present
|
|
become: true
|
|
- name: Display all interfaces name
|
|
ansible.builtin.debug:
|
|
var: ansible_facts.interfaces
|
|
- name: Get wifi adapter
|
|
ansible.builtin.set_fact:
|
|
active_adapter: '{{ item }}'
|
|
loop: '{{ ansible_facts.interfaces }}'
|
|
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
|
|
|
|
|
|
- name: Creating config
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: "/etc/systemd/system/wol@.service"
|
|
content: |
|
|
[Unit]
|
|
Description=Enable Wake On Lan
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart = /usr/sbin/ethtool --change %i wol g
|
|
|
|
[Install]
|
|
WantedBy=basic.target
|
|
owner: root
|
|
mode: '0744'
|
|
- name: Restart service wol, in all cases
|
|
ansible.builtin.service:
|
|
name: wol@{{ item }}
|
|
state: restarted
|
|
enabled: true
|
|
become: true
|
|
loop: '{{ ansible_facts.interfaces }}'
|
|
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
|