Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 1 | {%- from "galera/map.jinja" import master with context %} |
| 2 | {%- if master.enabled %} |
| 3 | |
| 4 | {%- if grains.os_family == "Debian2" %} |
| 5 | |
| 6 | galera_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 | |
| 17 | galera_packages: |
| 18 | pkg.installed: |
| 19 | - names: {{ master.pkgs }} |
| 20 | |
| 21 | galera_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 | |
| 31 | galera_bootstrap_temp_config: |
| 32 | file.managed: |
| 33 | - name: {{ master.config }} |
Ales Komarek | 1fe9c70 | 2015-04-30 15:46:37 +0200 | [diff] [blame] | 34 | - source: salt://galera/files/my.cnf.bootstrap |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 35 | - mode: 644 |
| 36 | - template: jinja |
| 37 | - require: |
| 38 | - pkg: galera_packages |
| 39 | |
| 40 | galera_bootstrap_start_service: |
| 41 | service.running: |
| 42 | - name: mysql |
| 43 | - require: |
| 44 | - file: galera_bootstrap_temp_config |
| 45 | |
| 46 | galera_bootstrap_set_root_password: |
| 47 | cmd.run: |
| 48 | - name: mysqladmin password "{{ master.admin.password }}" |
| 49 | - require: |
| 50 | - service: galera_bootstrap_start_service |
| 51 | |
| 52 | mysql_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 Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 58 | galera_bootstrap_stop_service: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 59 | service.dead: |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 60 | - name: {{ master.service }} |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 61 | - require: |
| 62 | - cmd: mysql_bootstrap_update_maint_password |
| 63 | |
| 64 | galera_bootstrap_init_config: |
| 65 | file.managed: |
| 66 | - name: {{ master.config }} |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 67 | - source: salt://galera/files/my.cnf.init |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 68 | - mode: 644 |
| 69 | - template: jinja |
| 70 | - require: |
| 71 | - service: galera_bootstrap_stop_service |
| 72 | |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 73 | galera_bootstrap_start_service_final: |
| 74 | service.running: |
| 75 | - name: {{ master.service }} |
| 76 | - require: |
| 77 | - file: galera_bootstrap_init_config |
| 78 | |
Ales Komarek | b282410 | 2015-04-30 15:43:17 +0200 | [diff] [blame] | 79 | galera_bootstrap_finish_flag: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 80 | file.touch: |
| 81 | - require: |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 82 | - service: galera_bootstrap_start_service_final |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 83 | - watch_in: |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 84 | - file: galera_config |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 85 | |
| 86 | {%- endif %} |
| 87 | |
Ales Komarek | 41517c4 | 2015-04-30 15:58:19 +0200 | [diff] [blame^] | 88 | galera_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 Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 97 | galera_service: |
| 98 | service.running: |
| 99 | - name: {{ master.service }} |
| 100 | - enable: true |
| 101 | - reload: true |
| 102 | |
| 103 | {%- endif %} |