blob: 2e739a558810f0a0ac406a3f379a77816e327bdf [file] [log] [blame]
Ales Komarekcba48ac2015-04-30 11:40:44 +02001{%- from "galera/map.jinja" import master with context %}
2{%- if master.enabled %}
3
4{%- if grains.os_family == "Debian2" %}
5
6galera_debconf:
7 debconf.set:
8 - name: mariadb-galera-server
9 - data:
10 'mysql-server/root_password': {'type':'string','value':'{{ server.admin.password }}'}
11 'mysql-server/root_password_again': {'type':'string','value':'{{ server.admin.password }}'}
12 - require_in:
13 - pkg: galera_packages
14
15{%- endif %}
16
17galera_packages:
18 pkg.installed:
19 - names: {{ master.pkgs }}
20
21galera_log_dir:
22 file.directory:
23 - name: /var/log/mysql
24 - makedirs: true
25 - mode: 755
26 - require:
27 - pkg: galera_packages
28
Ales Komarek90da78d2015-04-30 16:01:11 +020029galera_init_script:
30 file.managed:
31 - name: /etc/init.d/mysql
32 - source: salt://galera/files/mysql
33 - mode: 755
34 - require:
35 - pkg: galera_packages
36
Ales Komarekcba48ac2015-04-30 11:40:44 +020037{%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
38
39galera_bootstrap_temp_config:
40 file.managed:
41 - name: {{ master.config }}
Ales Komarek1fe9c702015-04-30 15:46:37 +020042 - source: salt://galera/files/my.cnf.bootstrap
Ales Komarekcba48ac2015-04-30 11:40:44 +020043 - mode: 644
44 - template: jinja
45 - require:
46 - pkg: galera_packages
Ales Komarek90da78d2015-04-30 16:01:11 +020047 - file: galera_init_script
Ales Komarekcba48ac2015-04-30 11:40:44 +020048
49galera_bootstrap_start_service:
50 service.running:
51 - name: mysql
52 - require:
53 - file: galera_bootstrap_temp_config
54
55galera_bootstrap_set_root_password:
56 cmd.run:
57 - name: mysqladmin password "{{ master.admin.password }}"
58 - require:
59 - service: galera_bootstrap_start_service
60
61mysql_bootstrap_update_maint_password:
62 cmd.run:
63 - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
64 - require:
65 - cmd: galera_bootstrap_set_root_password
66
Ales Komarek41517c42015-04-30 15:58:19 +020067galera_bootstrap_stop_service:
Ales Komarekcba48ac2015-04-30 11:40:44 +020068 service.dead:
Ales Komarek41517c42015-04-30 15:58:19 +020069 - name: {{ master.service }}
Ales Komarekcba48ac2015-04-30 11:40:44 +020070 - require:
71 - cmd: mysql_bootstrap_update_maint_password
72
73galera_bootstrap_init_config:
74 file.managed:
75 - name: {{ master.config }}
Ales Komarek41517c42015-04-30 15:58:19 +020076 - source: salt://galera/files/my.cnf.init
Ales Komarekcba48ac2015-04-30 11:40:44 +020077 - mode: 644
78 - template: jinja
79 - require:
80 - service: galera_bootstrap_stop_service
81
Ales Komarek41517c42015-04-30 15:58:19 +020082galera_bootstrap_start_service_final:
83 service.running:
84 - name: {{ master.service }}
85 - require:
86 - file: galera_bootstrap_init_config
87
Ales Komarekb2824102015-04-30 15:43:17 +020088galera_bootstrap_finish_flag:
Ales Komarekcba48ac2015-04-30 11:40:44 +020089 file.touch:
90 - require:
Ales Komarek41517c42015-04-30 15:58:19 +020091 - service: galera_bootstrap_start_service_final
Ales Komarekcba48ac2015-04-30 11:40:44 +020092 - watch_in:
Ales Komarek41517c42015-04-30 15:58:19 +020093 - file: galera_config
Ales Komarekcba48ac2015-04-30 11:40:44 +020094
95{%- endif %}
96
Ales Komarek41517c42015-04-30 15:58:19 +020097galera_config:
98 file.managed:
99 - name: {{ master.config }}
100 - source: salt://galera/files/my.cnf
101 - mode: 644
102 - template: jinja
103 - require_in:
104 - service: galera_service
105
Ales Komarekcba48ac2015-04-30 11:40:44 +0200106galera_service:
107 service.running:
108 - name: {{ master.service }}
109 - enable: true
110 - reload: true
111
112{%- endif %}