{%- from "galera/map.jinja" import slave with context -%} | |||||
#!/bin/bash | #!/bin/bash | ||||
service {{ slave.service }} start | |||||
service {{ service.service }} start | |||||
counter=70 | |||||
counter=60 | |||||
while [ $counter -gt 0 ] | while [ $counter -gt 0 ] | ||||
do | do | ||||
service {{ slave.service }} status | |||||
mysql -u {{ service.admin.user }} -p{{ service.admin.password }} -e"quit" | |||||
if [[ $? -eq 0 ]]; then | if [[ $? -eq 0 ]]; then | ||||
exit 0 | exit 0 | ||||
fi | fi |
#!/bin/bash | |||||
service {{ service.service }} start | |||||
counter=60 | |||||
while [ $counter -gt 0 ] | |||||
do | |||||
mysql -u root -e"quit" | |||||
if [[ $? -eq 0 ]]; then | |||||
exit 0 | |||||
fi | |||||
counter=$(( $counter - 1 )) | |||||
sleep 2 | |||||
done | |||||
exit 1 |
{%- endif %} | {%- endif %} | ||||
galera_init_script: | |||||
file.managed: | |||||
- name: /usr/local/sbin/galera_init.sh | |||||
- mode: 755 | |||||
- source: salt://galera/files/init_bootstrap.sh | |||||
- defaults: | |||||
service: {{ master|yaml }} | |||||
- template: jinja | |||||
galera_bootstrap_script: | galera_bootstrap_script: | ||||
file.managed: | file.managed: | ||||
- name: /usr/local/sbin/galera_bootstrap.sh | - name: /usr/local/sbin/galera_bootstrap.sh | ||||
- mode: 755 | - mode: 755 | ||||
- source: salt://galera/files/bootstrap.sh | - source: salt://galera/files/bootstrap.sh | ||||
- defaults: | |||||
service: {{ master|yaml }} | |||||
- template: jinja | - template: jinja | ||||
{%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %} | {%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %} | ||||
galera_bootstrap_start_service: | |||||
galera_init_start_service: | |||||
cmd.run: | cmd.run: | ||||
- name: /usr/local/sbin/galera_bootstrap.sh | |||||
- name: /usr/local/sbin/galera_init.sh | |||||
- require: | - require: | ||||
- file: galera_run_dir | - file: galera_run_dir | ||||
- file: galera_bootstrap_script | |||||
- file: galera_init_script | |||||
galera_bootstrap_set_root_password: | galera_bootstrap_set_root_password: | ||||
cmd.run: | cmd.run: | ||||
- name: mysqladmin password "{{ master.admin.password }}" | - name: mysqladmin password "{{ master.admin.password }}" | ||||
- require: | - require: | ||||
- cmd: galera_bootstrap_start_service | |||||
- cmd: galera_init_start_service | |||||
mysql_bootstrap_update_maint_password: | mysql_bootstrap_update_maint_password: | ||||
cmd.run: | cmd.run: |
{%- endif %} | {%- endif %} | ||||
galera_init_script: | |||||
file.managed: | |||||
- name: /usr/local/sbin/galera_init.sh | |||||
- mode: 755 | |||||
- source: salt://galera/files/init_bootstrap.sh | |||||
- defaults: | |||||
service: {{ slave|yaml }} | |||||
- template: jinja | |||||
galera_bootstrap_script: | galera_bootstrap_script: | ||||
file.managed: | file.managed: | ||||
- name: /usr/local/sbin/galera_bootstrap.sh | - name: /usr/local/sbin/galera_bootstrap.sh | ||||
- mode: 755 | - mode: 755 | ||||
- defaults: | |||||
service: {{ slave|yaml }} | |||||
- source: salt://galera/files/bootstrap.sh | - source: salt://galera/files/bootstrap.sh | ||||
- template: jinja | - template: jinja | ||||
{%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %} | {%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %} | ||||
galera_bootstrap_start_service: | |||||
galera_init_start_service: | |||||
cmd.run: | cmd.run: | ||||
- name: /usr/local/sbin/galera_bootstrap.sh | |||||
- name: /usr/local/sbin/galera_init.sh | |||||
- require: | - require: | ||||
- file: galera_run_dir | - file: galera_run_dir | ||||
- file: galera_bootstrap_script | |||||
- file: galera_init_script | |||||
galera_bootstrap_set_root_password: | galera_bootstrap_set_root_password: | ||||
cmd.run: | cmd.run: | ||||
- name: mysqladmin password "{{ slave.admin.password }}" | - name: mysqladmin password "{{ slave.admin.password }}" | ||||
- require: | - require: | ||||
- cmd: galera_bootstrap_start_service | |||||
- cmd: galera_init_start_service | |||||
mysql_bootstrap_update_maint_password: | mysql_bootstrap_update_maint_password: | ||||
cmd.run: | cmd.run: |