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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
salt
mysql-formula
Commits
22b53e4e
Commit
22b53e4e
authored
10 years ago
by
Nitin Madhok
Browse files
Options
Downloads
Plain Diff
Merge pull request #55 from vschum/multiple-hosts-per-user
Add the ability to specify user pillar data in the form of either
parents
8d89326f
26e634cd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mysql/user.sls
+15
-3
15 additions, 3 deletions
mysql/user.sls
with
15 additions
and
3 deletions
mysql/user.sls
+
15
−
3
View file @
22b53e4e
...
@@ -3,16 +3,27 @@
...
@@ -3,16 +3,27 @@
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', 'somepass') %}
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', 'somepass') %}
{% set user_states = [] %}
{% set user_states = [] %}
{% set user_hosts = [] %}
include:
include:
- mysql.python
- mysql.python
{% for name, user in salt['pillar.get']('mysql:user', {}).items() %}
{% for name, user in salt['pillar.get']('mysql:user', {}).items() %}
{% set state_id = 'mysql_user_' ~ loop.index0 %}
{% set user_host = salt['pillar.get']('mysql:user:%s:host'|format(name)) %}
{% if user_host != '' %}
{% set user_hosts = [user_host] %}
{% else %}
{% set user_hosts = salt['pillar.get']('mysql:user:%s:hosts'|format(name)) %}
{% endif %}
{% for host in user_hosts %}
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
{{ state_id }}:
{{ state_id }}:
mysql_user.present:
mysql_user.present:
- name: {{ name }}
- name: {{ name }}
- host: '{{
user['
host
']
}}'
- host: '{{ host }}'
{%- if user['password_hash'] is defined %}
{%- if user['password_hash'] is defined %}
- password_hash: '{{ user['password_hash'] }}'
- password_hash: '{{ user['password_hash'] }}'
{%- elif user['password'] is defined and user['password'] != None %}
{%- elif user['password'] is defined and user['password'] != None %}
...
@@ -35,7 +46,7 @@ include:
...
@@ -35,7 +46,7 @@ include:
- database: '{{ db['database'] }}.{{ db['table'] | default('*') }}'
- database: '{{ db['database'] }}.{{ db['table'] | default('*') }}'
- grant_option: {{ db['grant_option'] | default(False) }}
- grant_option: {{ db['grant_option'] | default(False) }}
- user: {{ name }}
- user: {{ name }}
- host: '{{
user['
host
']
}}'
- host: '{{ host }}'
- connection_host: localhost
- connection_host: localhost
- connection_user: root
- connection_user: root
{% if mysql_root_pass -%}
{% if mysql_root_pass -%}
...
@@ -48,3 +59,4 @@ include:
...
@@ -48,3 +59,4 @@ include:
{% do user_states.append(state_id) %}
{% do user_states.append(state_id) %}
{% endfor %}
{% endfor %}
{% endfor %}
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