blob: 63bab465cbf87678622e11fc7e0cba61d9726be4 [file] [log] [blame]
Filip Pytloun4ab64a02015-10-06 16:28:32 +02001{% from "keepalived/map.jinja" import cluster with context %}
2
3{%- if cluster.enabled %}
4
5keepalived_packages:
6 pkg.installed:
7 - names: {{ cluster.pkgs }}
8
Simon Pasquier2f09ff72017-01-03 14:26:12 +01009{%- if pillar.collectd is defined %}
10keepalived_packages_for_collectd:
11 pkg.installed:
12 - names: {{ cluster.collectd_pkgs }}
13{%- endif %}
14
Filip Pytloun4ab64a02015-10-06 16:28:32 +020015keepalived_config:
16 file.managed:
17 - name: {{ cluster.config }}
18 - source: salt://keepalived/files/keepalived.conf
19 - template: jinja
20 - require:
21 - pkg: keepalived_packages
22
Jakub Pavlik2680d652016-08-26 17:35:40 +020023{% for instance_name, instance in cluster.instance.iteritems() %}
24
Jakub Pavlik7b75ce72016-08-26 18:04:58 +020025{%- if instance.notify_action is defined %}
Jakub Pavlik2680d652016-08-26 17:35:40 +020026
27keepalived_{{ instance_name }}_notify:
28 file.managed:
Filip Pytloun424120b2016-08-26 19:31:42 +020029 - name: /usr/local/bin/keepalived_notify_{{ instance_name }}.sh
30 - mode: 755
31 - source: salt://keepalived/files/keepalived_notify.sh
Jakub Pavlik2680d652016-08-26 17:35:40 +020032 - template: jinja
Ales Komarekc0e7d032016-08-26 17:46:28 +020033 - defaults:
Filip Pytloun424120b2016-08-26 19:31:42 +020034 notify_action: {{ instance.notify_action }}
Jakub Pavlik2680d652016-08-26 17:35:40 +020035 - require:
36 - pkg: keepalived_packages
37 - require_in:
38 - service: keepalived_service
39
40{%- endif %}
41
42{% endfor %}
43
Petr Michalec8863f472017-05-05 15:57:22 +020044{%- set _deployed = [] %}
Petr Michalec97aab162017-02-21 14:16:18 +010045{%- for name, script in cluster.get('vrrp_scripts', {}).iteritems() %}
Petr Michalec8863f472017-05-05 15:57:22 +020046{%- if script.get('name', name) not in _deployed %}keepalived_vrrp_script_{{ script.get('name', name) }}:{% else %}{% continue %}{% endif %}
47{%- do _deployed.append(script.get('name', name)) %}
Petr Michalec97aab162017-02-21 14:16:18 +010048 file.managed:
Petr Michalec8863f472017-05-05 15:57:22 +020049 - name: /usr/local/bin/vrrp_script_{{ script.get('name', name) }}.sh
Petr Michalec97aab162017-02-21 14:16:18 +010050 - mode: 755
51 - source:
Petr Michalec8863f472017-05-05 15:57:22 +020052 - salt://keepalived/files/vrrp_script_{{ script.get('name', name) }}.sh
Petr Michalec97aab162017-02-21 14:16:18 +010053 - salt://keepalived/files/vrrp_script.sh
54 - template: jinja
55 - defaults:
Petr Michalec8863f472017-05-05 15:57:22 +020056 script: {{ script|yaml }}
Petr Michalec97aab162017-02-21 14:16:18 +010057 - require_in:
58 - service: keepalived_service
59{% endfor %}
60
Filip Pytloun4ab64a02015-10-06 16:28:32 +020061keepalived_service:
62 service.running:
63 - name: {{ cluster.service }}
64 - enable: true
65 - reload: true
Aleš Komárek074ee812016-11-09 11:27:20 +010066 {%- if grains.get('init', None) != 'systemd' %}
67 - sig: keepalived
68 {%- endif %}
Filip Pytloun4ab64a02015-10-06 16:28:32 +020069 - watch:
70 - file: keepalived_config
71
Jakub Pavlik7b75ce72016-08-26 18:04:58 +020072{%- endif %}