blob: cc5857c019e4a6d899b8ac0c57909d4f013e71e3 [file] [log] [blame]
Ales Komarek67ef8062015-04-30 16:09:30 +02001{%- from "galera/map.jinja" import slave with context %}
2{%- if slave.enabled %}
3
4galera_packages:
5 pkg.installed:
6 - names: {{ slave.pkgs }}
7
8galera_log_dir:
9 file.directory:
10 - name: /var/log/mysql
11 - makedirs: true
12 - mode: 755
13 - require:
14 - pkg: galera_packages
15
16galera_init_script:
17 file.managed:
18 - name: /etc/init.d/mysql
19 - source: salt://galera/files/mysql
20 - mode: 755
21 - require:
22 - pkg: galera_packages
23
24{%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
25
26galera_bootstrap_temp_config:
27 file.managed:
28 - name: {{ slave.config }}
29 - source: salt://galera/files/my.cnf.bootstrap
30 - mode: 644
31 - template: jinja
32 - require:
33 - pkg: galera_packages
34 - file: galera_init_script
35
36galera_bootstrap_start_service:
37 service.running:
38 - name: mysql
39 - require:
40 - file: galera_bootstrap_temp_config
41
42galera_bootstrap_set_root_password:
43 cmd.run:
44 - name: mysqladmin password "{{ slave.admin.password }}"
45 - require:
46 - service: galera_bootstrap_start_service
47
48mysql_bootstrap_update_maint_password:
49 cmd.run:
50 - name: mysql -u root -p{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';"
51 - require:
52 - cmd: galera_bootstrap_set_root_password
53
54galera_bootstrap_stop_service:
55 service.dead:
56 - name: {{ slave.service }}
57 - require:
58 - cmd: mysql_bootstrap_update_maint_password
59
60galera_bootstrap_init_config:
61 file.managed:
62 - name: {{ slave.config }}
63 - source: salt://galera/files/my.cnf
64 - mode: 644
65 - template: jinja
66 - require:
67 - service: galera_bootstrap_stop_service
68
69galera_bootstrap_start_service_final:
70 service.running:
71 - name: {{ slave.service }}
72 - require:
73 - file: galera_bootstrap_init_config
74
75galera_bootstrap_finish_flag:
76 file.touch:
77 - name: /root/.galera_bootstrap
78 - require:
79 - service: galera_bootstrap_start_service_final
80 - watch_in:
81 - file: galera_config
82
83{%- endif %}
84
85galera_config:
86 file.managed:
87 - name: {{ slave.config }}
88 - source: salt://galera/files/my.cnf
89 - mode: 644
90 - template: jinja
91 - require_in:
92 - service: galera_service
93
94galera_service:
95 service.running:
96 - name: {{ slave.service }}
97 - enable: true
98 - reload: true
99
100{%- endif %}