Browse Source

Optimize 'noservices' condition

revert-bumpto57-2
Martin Polreich 7 years ago
parent
commit
cad6ed4421
3 changed files with 36 additions and 35 deletions
  1. +15
    -19
      galera/master.sls
  2. +3
    -2
      galera/server.sls
  3. +18
    -14
      galera/slave.sls

+ 15
- 19
galera/master.sls View File

- require_in: - require_in:
- pkg: galera_packages - pkg: galera_packages


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

galera_init_start_service: galera_init_start_service:
cmd.run: cmd.run:
- name: /usr/local/sbin/galera_init.sh - name: /usr/local/sbin/galera_init.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require: - require:
- file: galera_run_dir - file: galera_run_dir
- file: galera_init_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 }}"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require: - require:
- cmd: galera_init_start_service - cmd: galera_init_start_service


mysql_bootstrap_update_maint_password: mysql_bootstrap_update_maint_password:
cmd.run: 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 }}';" - 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: - require:
- cmd: galera_bootstrap_set_root_password - cmd: galera_bootstrap_set_root_password


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

{%- endif %}


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

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


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


{%- endif %}

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


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

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


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


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

+ 3
- 2
galera/server.sls View File



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


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


mysql_user_{{ user.name }}_{{ user.host }}: mysql_user_{{ user.name }}_{{ user.host }}:
{%- else %} {%- else %}
- allow_passwordless: True - allow_passwordless: True
{%- endif %} {%- endif %}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}


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

+ 18
- 14
galera/slave.sls View File

- require_in: - require_in:
- pkg: galera_packages - pkg: galera_packages


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

galera_init_start_service: galera_init_start_service:
cmd.run: cmd.run:
- name: /usr/local/sbin/galera_init.sh - name: /usr/local/sbin/galera_init.sh
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require: - require:
- file: galera_run_dir - file: galera_run_dir
- file: galera_init_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 }}"
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require: - require:
- cmd: galera_init_start_service - cmd: galera_init_start_service


mysql_bootstrap_update_maint_password: mysql_bootstrap_update_maint_password:
cmd.run: 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 }}';" - 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: - require:
- cmd: galera_bootstrap_set_root_password - cmd: galera_bootstrap_set_root_password


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


{%- endif %}

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

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


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


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


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

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


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


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

Loading…
Cancel
Save