Last active
December 22, 2015 06:59
-
-
Save Kahn/6435303 to your computer and use it in GitHub Desktop.
Ansible MySQL database setup
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
# config | |
/etc/ansible/host_vars/dbserver | |
--- | |
dbs_inst: ['testdb1', 'testdb2'] | |
dbs: | |
- { name: 'testdb1', password: 'password1', priv: 'testdb1.*:ALL' } | |
- { name: 'testdb2', password: 'password2', priv: 'testdb2.*:SELECT' } | |
/etc/ansible/roles/mysql/tasks/main.yml | |
... | |
- name: create additional MySQL databases | |
action: mysql_db db={{ item.name }} state=present | |
with_items: dbs | |
tags: | |
- config | |
- mysql | |
- name: create additional MySQL users | |
action: mysql_user name={{ item.name }} password={{ item.password }} priv={{ item.priv }} state=present | |
with_items: dbs | |
tags: | |
- config | |
- mysql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment