mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-16 01:30:25 +00:00
Allow to remove DB
This commit is contained in:
parent
d1de0fdfc6
commit
3633a6ec84
2 changed files with 18 additions and 5 deletions
|
@ -13,19 +13,29 @@ include:
|
|||
|
||||
{% for database_obj in salt['pillar.get']('mysql:database', []) %}
|
||||
{% set state_id = 'mysql_db_' ~ loop.index0 %}
|
||||
{% set database = database_obj.get('name') if database_obj is mapping else database_obj %}
|
||||
{% if database_obj is mapping %}
|
||||
{% set database = database_obj.get('name') %}
|
||||
{% set present = database_obj.get('present', True) %}
|
||||
{% else %}
|
||||
{% set database = database_obj %}
|
||||
{% set present = True %}
|
||||
{% endif %}
|
||||
{{ state_id }}:
|
||||
{%- if present %}
|
||||
mysql_database.present:
|
||||
{% if database_obj is mapping %}
|
||||
- character_set: {{ database_obj.get('character_set', '') }}
|
||||
- collate: {{ database_obj.get('collate', '') }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
mysql_database.absent:
|
||||
{% endif %}
|
||||
- name: {{ database }}
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: '{{ mysql_salt_user }}'
|
||||
{% if mysql_salt_pass %}
|
||||
- connection_pass: '{{ mysql_salt_pass }}'
|
||||
{% endif %}
|
||||
{% if database_obj is mapping %}
|
||||
- character_set: {{ database_obj.get('character_set', '') }}
|
||||
- collate: {{ database_obj.get('collate', '') }}
|
||||
{% endif %}
|
||||
- connection_charset: utf8
|
||||
|
||||
{% if salt['pillar.get'](['mysql', 'schema', database, 'load']|join(':'), False) %}
|
||||
|
|
|
@ -72,6 +72,9 @@ mysql:
|
|||
- name: bar
|
||||
character_set: utf8
|
||||
collate: utf8_general_ci
|
||||
# Delete DB
|
||||
- name: obsolete_db
|
||||
present: False
|
||||
schema:
|
||||
foo:
|
||||
load: True
|
||||
|
|
Loading…
Add table
Reference in a new issue