diff --git a/salt/pillars/network.sls b/salt/pillars/network.sls index 4c4c533..26606f6 100644 --- a/salt/pillars/network.sls +++ b/salt/pillars/network.sls @@ -24,3 +24,7 @@ network: id: 250 address: 192.168.250.1 netmask: 24 + wol: + 1: 7c:10:c9:50:17:9b + 2: 7c:10:c9:50:17:0a + 3: 7c:10:c9:50:17:58 diff --git a/salt/states/top.sls b/salt/states/top.sls index fc9cd35..5776101 100644 --- a/salt/states/top.sls +++ b/salt/states/top.sls @@ -13,3 +13,4 @@ base: - remote-desktop - hostapd - firewalld + - wol diff --git a/salt/states/wol/files/wol.jinja b/salt/states/wol/files/wol.jinja new file mode 100644 index 0000000..aaf4f61 --- /dev/null +++ b/salt/states/wol/files/wol.jinja @@ -0,0 +1,18 @@ +#/bin/bash +set -aeou pipefail + + +for arg in "$@" +do + case "$arg" in +{% for number, mac in pillar['network']['wol'].items() %} + {{ number }}|srv{{ number }}|server{{ number }}) + sudo ether-wake -i {{ pillar['network']['interface']['bridge'] }} {{ mac }} + ;; +{% endfor %} + + *) + echo "unknown: $arg" + ;; + esac +done diff --git a/salt/states/wol/init.sls b/salt/states/wol/init.sls new file mode 100644 index 0000000..a6a2d36 --- /dev/null +++ b/salt/states/wol/init.sls @@ -0,0 +1,12 @@ +install net-tools: + pkg.installed: + - name: net-tools + +configure bin/wol: + file.managed: + - name: /home/{{ pillar['username'] }}/bin/wol + - source: salt://wol/files/wol.jinja + - template: jinja + - user: {{ pillar['username'] }} + - group: users + - mode: "0755"