瀏覽代碼

Optimize 'noservices' condition

pull/31/head
Martin Polreich 7 年之前
父節點
當前提交
cad6ed4421
共有 3 個文件被更改,包括 36 次插入35 次删除
  1. +15
    -19
      galera/master.sls
  2. +3
    -2
      galera/server.sls
  3. +18
    -14
      galera/slave.sls

+ 15
- 19
galera/master.sls 查看文件

@@ -138,11 +138,12 @@ galera_pre_config:
- require_in:
- pkg: galera_packages

{%- if not grains.get('noservices', False) %}

galera_init_start_service:
cmd.run:
- name: /usr/local/sbin/galera_init.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- file: galera_run_dir
- file: galera_init_script
@@ -150,24 +151,26 @@ galera_init_start_service:
galera_bootstrap_set_root_password:
cmd.run:
- name: mysqladmin password "{{ master.admin.password }}"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- cmd: galera_init_start_service

mysql_bootstrap_update_maint_password:
cmd.run:
- name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- cmd: galera_bootstrap_set_root_password

galera_bootstrap_stop_service:
service.dead:
- name: {{ master.service }}
{%- if not grains.get('noservices', False) %}
- require:
- cmd: mysql_bootstrap_update_maint_password
{%- endif %}

{%- endif %}

galera_bootstrap_init_config:
file.managed:
@@ -175,29 +178,24 @@ galera_bootstrap_init_config:
- source: salt://galera/files/my.cnf.init
- mode: 644
- template: jinja
{%- if not grains.get('noservices', False) %}
- require:
- service: galera_bootstrap_stop_service
{%- endif %}

{%- if not grains.get('noservices', False) %}

galera_bootstrap_start_service_final:
cmd.run:
- name: /usr/local/sbin/galera_bootstrap.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- file: galera_bootstrap_init_config
- file: galera_bootstrap_script

{%- endif %}

galera_bootstrap_finish_flag:
file.touch:
- name: /var/lib/mysql/.galera_bootstrap
{%- if not grains.get('noservices', False) %}
- require:
- cmd: galera_bootstrap_start_service_final
{%- endif %}
- watch_in:
- file: galera_config

@@ -209,18 +207,16 @@ galera_config:
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
{%- if not grains.get('noservices', False) %}
- require_in:
- service: galera_service
{%- endif %}

{%- if not grains.get('noservices', False) %}

galera_service:
service.running:
- name: {{ master.service }}
- enable: true
- reload: true
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}

{%- endif %}
{%- endif %}

+ 3
- 2
galera/server.sls 查看文件

@@ -54,7 +54,6 @@ restore_mysql_database_{{ database_name }}:

{%- endfor %}

{%- if not grains.get('noservices', False) %}
{%- for user in server.get('users', []) %}

mysql_user_{{ user.name }}_{{ user.host }}:
@@ -66,7 +65,9 @@ mysql_user_{{ user.name }}_{{ user.host }}:
{%- else %}
- allow_passwordless: True
{%- endif %}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}

{%- endfor %}
{%- endif %}
{%- endif %}

+ 18
- 14
galera/slave.sls 查看文件

@@ -138,11 +138,12 @@ galera_pre_config:
- require_in:
- pkg: galera_packages

{%- if not grains.get('noservices', False) %}

galera_init_start_service:
cmd.run:
- name: /usr/local/sbin/galera_init.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- file: galera_run_dir
- file: galera_init_script
@@ -150,39 +151,45 @@ galera_init_start_service:
galera_bootstrap_set_root_password:
cmd.run:
- name: mysqladmin password "{{ slave.admin.password }}"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- cmd: galera_init_start_service

mysql_bootstrap_update_maint_password:
cmd.run:
- name: mysql -u root -p{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- cmd: galera_bootstrap_set_root_password

galera_bootstrap_stop_service:
service.dead:
- name: {{ slave.service }}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- cmd: mysql_bootstrap_update_maint_password

{%- endif %}

galera_bootstrap_init_config:
file.managed:
- name: {{ slave.config }}
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
{%- if not grains.get('noservices', False) %}
- require:
- service: galera_bootstrap_stop_service
{%- endif %}

{%- if not grains.get('noservices', False) %}

galera_bootstrap_start_service_final:
cmd.run:
- name: /usr/local/sbin/galera_bootstrap.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- file: galera_bootstrap_init_config
- file: galera_bootstrap_script
@@ -196,7 +203,6 @@ galera_bootstrap_finish_flag:
- file: galera_config

{%- endif %}
{%- endif %}

galera_config:
file.managed:
@@ -204,18 +210,16 @@ galera_config:
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
{%- if not grains.get('noservices', False) %}
- require_in:
- service: galera_service
{%- endif %}

{%- if not grains.get('noservices', False) %}

galera_service:
service.running:
- name: {{ slave.service }}
- enable: true
- reload: true
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}

{%- endif %}
{%- endif %}

Loading…
取消
儲存