-
-
Save thecodeassassin/8d8f2df0f3870e41cb0d to your computer and use it in GitHub Desktop.
This file contains 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
db-user: | |
service: | |
- name: mysql | |
- running | |
- enable: True | |
- reload: True | |
- require: | |
- sls: database | |
# create all the required users | |
{% for user in pillar.get('database-users')} | |
mysql_user.present: | |
- name: {{ user["name"] }} | |
- password: {{ user["password"] }} | |
- allow_passwordless: False | |
- host: 'localhost' | |
- connection_user: root | |
- connection_pass: {{ pillar["root_password"] }} | |
- require: | |
- service: mysql | |
- sls: database | |
- mysql_user.present: root | |
# create all the databases for the given users | |
{% for database in user["databases"] %} | |
mysql_database.present: | |
- name: {{ database }} | |
- require: mysql_user.present: {{ user["name"] }} | |
mysql_grants.present: | |
- grant: 'ALL PRIVILEGES' | |
- database: {{ database }} | |
- host: '%' | |
- grant_option: False | |
- user: {{ user["name"] }} | |
- connection_user: root | |
- connection_pass: {{ pillar["root_password"] }} | |
- require: | |
- mysql_database.present: {{ database }} | |
- sls: database | |
{% endfor } | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment