Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mysql-formula
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
salt
mysql-formula
Commits
52ed6ab6
Unverified
Commit
52ed6ab6
authored
6 years ago
by
alxwr
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #217 from alxwr/remove-db-or-user
Remove DB and/or user
parents
49e4a819
39915a49
Branches
Branches containing commit
Tags
v0.49.0
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mysql/database.sls
+17
-5
17 additions, 5 deletions
mysql/database.sls
mysql/user.sls
+20
-14
20 additions, 14 deletions
mysql/user.sls
pillar.example
+9
-0
9 additions, 0 deletions
pillar.example
with
46 additions
and
19 deletions
mysql/database.sls
+
17
−
5
View file @
52ed6ab6
...
...
@@ -13,19 +13,31 @@ 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 not database_obj %}{# in case database_obj == [] #}
{% continue %}
{% elif 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) %}
...
...
This diff is collapsed.
Click to expand it.
mysql/user.sls
+
20
−
14
View file @
52ed6ab6
...
...
@@ -34,6 +34,7 @@ include:
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
{{ state_id }}:
{%- if user.get('present', True) %}
mysql_user.present:
- name: {{ name }}
- host: '{{ host }}'
...
...
@@ -43,12 +44,17 @@ include:
- password: '{{ user['password'] }}'
{%- else %}
- allow_passwordless: True
{%- endif %}
{%- else %}
mysql_user.absent:
- name: {{ name }}
- host: '{{ host }}'
{%- endif %}
- connection_host: '{{ mysql_host }}'
- connection_user: '{{ mysql_salt_user }}'
{% if mysql_salt_pass %}
{%
-
if mysql_salt_pass %}
- connection_pass: '{{ mysql_salt_pass }}'
{% endif %}
{%
-
endif %}
- connection_charset: utf8
{%- if 'grants' in user %}
...
...
This diff is collapsed.
Click to expand it.
pillar.example
+
9
−
0
View file @
52ed6ab6
...
...
@@ -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
...
...
@@ -143,6 +146,12 @@ mysql:
- database: foo
grants: ['select', 'insert', 'update']
# Remove a user
obsoleteuser:
host: localhost
# defaults to True
present: False
# Override any names defined in map.jinja
# serverpkg: mysql-server
# clientpkg: mysql-client
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment