blob: 8460f31f3de5893a05a141efbf1b4b3749f8c17c [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
29{%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
30
31galera_bootstrap_temp_config:
32 file.managed:
33 - name: {{ master.config }}
Ales Komarek1fe9c702015-04-30 15:46:37 +020034 - source: salt://galera/files/my.cnf.bootstrap
Ales Komarekcba48ac2015-04-30 11:40:44 +020035 - mode: 644
36 - template: jinja
37 - require:
38 - pkg: galera_packages
39
40galera_bootstrap_start_service:
41 service.running:
42 - name: mysql
43 - require:
44 - file: galera_bootstrap_temp_config
45
46galera_bootstrap_set_root_password:
47 cmd.run:
48 - name: mysqladmin password "{{ master.admin.password }}"
49 - require:
50 - service: galera_bootstrap_start_service
51
52mysql_bootstrap_update_maint_password:
53 cmd.run:
54 - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
55 - require:
56 - cmd: galera_bootstrap_set_root_password
57
Ales Komarek41517c42015-04-30 15:58:19 +020058galera_bootstrap_stop_service:
Ales Komarekcba48ac2015-04-30 11:40:44 +020059 service.dead:
Ales Komarek41517c42015-04-30 15:58:19 +020060 - name: {{ master.service }}
Ales Komarekcba48ac2015-04-30 11:40:44 +020061 - require:
62 - cmd: mysql_bootstrap_update_maint_password
63
64galera_bootstrap_init_config:
65 file.managed:
66 - name: {{ master.config }}
Ales Komarek41517c42015-04-30 15:58:19 +020067 - source: salt://galera/files/my.cnf.init
Ales Komarekcba48ac2015-04-30 11:40:44 +020068 - mode: 644
69 - template: jinja
70 - require:
71 - service: galera_bootstrap_stop_service
72
Ales Komarek41517c42015-04-30 15:58:19 +020073galera_bootstrap_start_service_final:
74 service.running:
75 - name: {{ master.service }}
76 - require:
77 - file: galera_bootstrap_init_config
78
Ales Komarekb2824102015-04-30 15:43:17 +020079galera_bootstrap_finish_flag:
Ales Komarekcba48ac2015-04-30 11:40:44 +020080 file.touch:
81 - require:
Ales Komarek41517c42015-04-30 15:58:19 +020082 - service: galera_bootstrap_start_service_final
Ales Komarekcba48ac2015-04-30 11:40:44 +020083 - watch_in:
Ales Komarek41517c42015-04-30 15:58:19 +020084 - file: galera_config
Ales Komarekcba48ac2015-04-30 11:40:44 +020085
86{%- endif %}
87
Ales Komarek41517c42015-04-30 15:58:19 +020088galera_config:
89 file.managed:
90 - name: {{ master.config }}
91 - source: salt://galera/files/my.cnf
92 - mode: 644
93 - template: jinja
94 - require_in:
95 - service: galera_service
96
Ales Komarekcba48ac2015-04-30 11:40:44 +020097galera_service:
98 service.running:
99 - name: {{ master.service }}
100 - enable: true
101 - reload: true
102
103{%- endif %}