forked from UtahDave/salt-states
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relate-etcd.sls
71 lines (55 loc) · 1.75 KB
/
relate-etcd.sls
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# vi: set ft=yaml.jinja :
{% set host = salt['config.get']('host') %}
{% set ipv4 = salt['config.get']('fqdn_ip4') %}
{% set minions = salt['roles.dict']('etcd') %}
{% set psls = sls.split('.')[0] %}
include:
- salt-minion
{% if minions['etcd'] %}
/etc/salt/minion.d/etcd.conf:
file.managed:
- template: jinja
- source: salt://{{ psls }}/etc/salt/minion.d/etcd.conf
- user: root
- group: root
- mode: '0644'
- require:
- file: /etc/salt/minion.d
- watch_in:
- service: salt-minion
{% set key = '/skydns/local/skydns/' + host %}
{% set value = '{"host":"' + ipv4[0] + '"}' %}
#-------------------------------------------------------------------------------
# TODO: short-circuit
#-------------------------------------------------------------------------------
{# if salt['etcd.get'](key) != value #}
etcdctl set {{ key }}:
module.run:
- name: etcd.set
- key: {{ key }}
- value: |-
{{ value }}
- require:
- file: /etc/salt/minion.d/etcd.conf
{# endif #}
{% set key = '/skydns/arpa/in-addr/' + ipv4[0]|replace('.', '/') %}
{% set value = '{"host":"' + host + '.skydns.local"}' %}
#-------------------------------------------------------------------------------
# TODO: short-circuit
#-------------------------------------------------------------------------------
{# if salt['etcd.get'](key) != value #}
etcdctl set {{ key }}:
module.run:
- name: etcd.set
- key: {{ key }}
- value: |-
{{ value }}
- require:
- file: /etc/salt/minion.d/etcd.conf
{# endif #}
{% else %}
/etc/salt/minion.d/etcd.conf:
file.absent:
- watch_in:
- service: salt-minion
{% endif %}