Last active
August 29, 2015 14:07
-
-
Save metalrufflez/c4c6da9deafc2b31668c to your computer and use it in GitHub Desktop.
Create Database Users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- salt.mysql | |
{% for db, db_details in pillar.get('db_config', {}).items() %} | |
{{ db }}_database: | |
mysql_database.present: | |
- name: {{ db }} | |
{% for user, user_details in db_details['users'].items() %} | |
{{ user }}_user_in_{{ db }}: | |
mysql_user.present: | |
- name: {{ user }} | |
- host: '{{ user_details['host'] }}' | |
- password: {{ user_details['pass'] }} | |
{% for grant, grant_details in user_details['grants'].items() %} | |
{{ grant }}_grant_for_{{ user }}_in_{{ db }}: | |
mysql_grants.present: | |
- user: {{ user }} | |
- host: '{{ user_details['host'] }}' | |
- grant: {{ grant_details['grant'] }} | |
- database: '{{ db }}.{{ grant_details['table'] }}' | |
- require: | |
- mysql_database: {{ db }} | |
- mysql_user: {{ user }} | |
{% endfor %} | |
{% endfor %} | |
{% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set app_name = "api" %} | |
db_config: | |
{{ app_name }}: | |
users: | |
{{ app_name }}_{{ grains['env'] }}: | |
host: '%' | |
pass: '$;B}ia=,2_' | |
grants: | |
all_on_all: | |
grant: all privileges | |
table: '*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment