-
Notifications
You must be signed in to change notification settings - Fork 97
/
wakeonlan.yml
46 lines (40 loc) · 1.18 KB
/
wakeonlan.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright 2017, Dag Wieers <dag@wieers.com>
#
# This playbook wakes up all/selected desktop systems. It is intended to be
# used before running any Ansible maintenance playbooks system-wide.
- hosts: computers
gather_facts: no
serial: 10
# vars:
# wake_server: localhost
vars:
macaddress: "{{ (ansible_interfaces|first).macaddress|default(mac|default('')) }}"
tasks:
- name: Send magic Wake-On-Lan packet to turn on individual systems via gateway {{ wake_server }}
win_wakeonlan:
mac: '{{ macaddress }}'
broadcast: 192.168.0.255
delegate_to: '{{ wake_server }}'
when: wake_server is defined
- wakeonlan:
mac: '{{ macaddress }}'
broadcast: 192.168.0.255
delegate_to: localhost
when: wake_server is not defined
# Advanced idempotent implementation
# - wakeonlan-adv:
# mac: '{{ macaddress }}'
# broadcast: 192.168.234.1
# port: 9
# check_arp: no
# timeout: 10
# become: yes
# delegate_to: localhost
# when: wake_server is not defined
- hosts: computers
gather_facts: no
tags: test
tasks:
- name: Wait for the system's WinRM service to come online
wait_for_connection:
timeout: 20