Added salt-master state

and reactor for rfxcom
This commit is contained in:
= 2020-12-25 13:18:47 +01:00
parent ab5a894780
commit 4b9e15a9e5
5 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,3 @@
reactor:
- 'salt/beacon/*/inotify//dev':
- /srv/reactor/device_reactor.sls

View File

@ -0,0 +1,16 @@
{% set label = data['path'].split('/')[-1] -%}
{% if label in ['rfxtrx433'] -%}
{% if data['change'] == 'IN_CREATE' -%}
{% set label = label + '=true' -%}
{% else %}
{% set label = label +'-' -%}
{% endif -%}
{% set node = data['id'].split('.')[0] -%}
label_k3s_node_{{ node }}:
local.state.single:
- tgt: masters
- tgt_type: nodegroup
- args:
- fun: cmd.run
- name: "kubectl label node {{ node }} {{ label }}"
{% endif -%}

2
salt-master/init.sls Normal file
View File

@ -0,0 +1,2 @@
include:
- salt-master.reactors

28
salt-master/reactors.sls Normal file
View File

@ -0,0 +1,28 @@
Create reactors master configuration:
file.managed:
- name: /etc/salt/master.d/reactors.conf
- source: salt://salt-master/files/etc/salt/master.d/reactors.conf
- user: root
- group: root
- mode: "0644"
restart master:
service.running:
- name: salt-master
- onchanges:
- file: Create reactors master configuration
Create reactors directory:
file.directory:
- name: /srv/reactor
- user: root
- group: root
- mode: "0755"
Create rfxcom reactor:
file.managed:
- name: /srv/reactor/device_reactor.sls
- source: salt://salt-master/files/srv/reactor/device_reactor.sls
- user: root
- group: root
- mode: "0644"

View File

@ -10,6 +10,7 @@ base:
'salt.rre.nu': 'salt.rre.nu':
- dnsmasq - dnsmasq
- salt-master
'k3s': 'k3s':
- match: nodegroup - match: nodegroup