소스 검색

fixes

tags/1.0
Ales Komarek 9 년 전
부모
커밋
67ef806c7c
2개의 변경된 파일101개의 추가작업 그리고 1개의 파일을 삭제
  1. +1
    -1
      galera/map.jinja
  2. +100
    -0
      galera/slave.sls

+ 1
- 1
galera/map.jinja 파일 보기

@@ -15,7 +15,7 @@
'Debian': {
'pkgs': ['mysql-server-wsrep', 'galera', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup-21', 'socat'],
'service': 'mysql',
'config': '/etc/mysql/conf.d/wsrep.cnf',
'config': '/etc/mysql/my.cnf',
},
'RedHat': {
'pkgs': ['MySQL-server', 'galera', 'MySQL-client', 'MySQL-python', 'rsync'],

+ 100
- 0
galera/slave.sls 파일 보기

@@ -0,0 +1,100 @@
{%- from "galera/map.jinja" import slave with context %}
{%- if slave.enabled %}

galera_packages:
pkg.installed:
- names: {{ slave.pkgs }}

galera_log_dir:
file.directory:
- name: /var/log/mysql
- makedirs: true
- mode: 755
- require:
- pkg: galera_packages

galera_init_script:
file.managed:
- name: /etc/init.d/mysql
- source: salt://galera/files/mysql
- mode: 755
- require:
- pkg: galera_packages

{%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}

galera_bootstrap_temp_config:
file.managed:
- name: {{ slave.config }}
- source: salt://galera/files/my.cnf.bootstrap
- mode: 644
- template: jinja
- require:
- pkg: galera_packages
- file: galera_init_script

galera_bootstrap_start_service:
service.running:
- name: mysql
- require:
- file: galera_bootstrap_temp_config

galera_bootstrap_set_root_password:
cmd.run:
- name: mysqladmin password "{{ slave.admin.password }}"
- require:
- service: galera_bootstrap_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 }}';"
- require:
- cmd: galera_bootstrap_set_root_password

galera_bootstrap_stop_service:
service.dead:
- name: {{ slave.service }}
- require:
- cmd: mysql_bootstrap_update_maint_password

galera_bootstrap_init_config:
file.managed:
- name: {{ slave.config }}
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
- require:
- service: galera_bootstrap_stop_service

galera_bootstrap_start_service_final:
service.running:
- name: {{ slave.service }}
- require:
- file: galera_bootstrap_init_config

galera_bootstrap_finish_flag:
file.touch:
- name: /root/.galera_bootstrap
- require:
- service: galera_bootstrap_start_service_final
- watch_in:
- file: galera_config

{%- endif %}

galera_config:
file.managed:
- name: {{ slave.config }}
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
- require_in:
- service: galera_service

galera_service:
service.running:
- name: {{ slave.service }}
- enable: true
- reload: true

{%- endif %}

Loading…
취소
저장