Kaynağa Gözat

enforce database

tags/1.0
Ales Komarek 9 yıl önce
ebeveyn
işleme
cf92b4e75d
5 değiştirilmiş dosya ile 91 ekleme ve 1 silme
  1. +0
    -0
      galera/files/sensu.conf
  2. +8
    -0
      galera/init.sls
  3. +1
    -1
      galera/master.sls
  4. +0
    -0
      galera/monitor.sls
  5. +82
    -0
      galera/server.sls

+ 0
- 0
galera/files/sensu.conf Dosyayı Görüntüle


+ 8
- 0
galera/init.sls Dosyayı Görüntüle

@@ -7,4 +7,12 @@ include:
{%- if pillar.galera.slave is defined %}
- galera.slave
{%- endif %}
{%- if pillar.galera.monitor is defined %}
- galera.monitor
{%- endif %}
{%- endif %}
{%- if pillar.mysql is defined %}
{%- if pillar.mysql.server is defined %}
- galera.server
{%- endif %}
{%- endif %}

+ 1
- 1
galera/master.sls Dosyayı Görüntüle

@@ -21,7 +21,7 @@ galera_init_script:
- require:
- pkg: galera_packages

{%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
{%- if salt['cmd.run']('test -e /root/.galera_bootstrap; echo $?') != '0' %}

galera_bootstrap_temp_config:
file.managed:

+ 0
- 0
galera/monitor.sls Dosyayı Görüntüle


+ 82
- 0
galera/server.sls Dosyayı Görüntüle

@@ -0,0 +1,82 @@
{%- if pillar.get('mysql', {}).server is defined %}

{%- set server = pillar.mysql.server %}

{%- for database_name, database in server.get('database', {}).iteritems() %}

mysql_database_{{ database_name }}:
mysql_database.present:
- name: {{ database_name }}
- require:
{% if cluster.enabled %}
- cmd: mysql_cluster_init
{% else %}
- service: mysql_service
{% endif %}

{%- for user in database.users %}

mysql_user_{{ user.name }}_{{ database_name }}_{{ user.host }}:
mysql_user.present:
- host: '{{ user.host }}'
- name: '{{ user.name }}'
- password: {{ user.password }}
- require:
{% if cluster.enabled %}
- cmd: mysql_cluster_init
{% else %}
- service: mysql_service
{% endif %}

mysql_grants_{{ user.name }}_{{ database_name }}_{{ user.host }}:
mysql_grants.present:
- grant: {{ user.rights }}
- database: '{{ database_name }}.*'
- user: '{{ user.name }}'
- host: '{{ user.host }}'
- require:
- mysql_user: mysql_user_{{ user.name }}_{{ database_name }}_{{ user.host }}
- mysql_database: mysql_database_{{ database_name }}

{%- endfor %}

{%- if database.initial_data is defined %}

/root/mysql/scripts/restore_{{ database_name }}.sh:
file.managed:
- source: salt://mysql/conf/restore.sh
- mode: 770
- template: jinja
- defaults:
database_name: {{ database_name }}
- require:
- file: mysql_dirs
- mysql_database: mysql_database_{{ database_name }}

restore_mysql_database_{{ database_name }}:
cmd.run:
- name: /root/mysql/scripts/restore_{{ database_name }}.sh
- unless: "[ -f /root/mysql/flags/{{ database_name }}-installed ]"
- cwd: /root
- require:
- file: /root/mysql/scripts/restore_{{ database_name }}.sh

{%- endif %}

{%- endfor %}

{%- for user in server.get('users', []) %}

mysql_user_{{ user.name }}_{{ user.host }}:
mysql_user.present:
- host: '{{ user.host }}'
- name: '{{ user.name }}'
{%- if user.password is defined %}
- password: {{ user.password }}
{%- else %}
- allow_passwordless: True
{%- endif %}

{%- endfor %}

{%- endif %}

Yükleniyor…
İptal
Kaydet