mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-10 11:50:18 +01:00
Allow creation of databases and users
Inspired by the Ansibles.mysql role.
This commit is contained in:
parent
cbf36a7920
commit
3a15b07608
3 changed files with 38 additions and 0 deletions
17
README.md
17
README.md
|
@ -20,6 +20,14 @@ The home directory inside which Python MySQL settings will be stored, which Ansi
|
||||||
|
|
||||||
The MySQL root user account password.
|
The MySQL root user account password.
|
||||||
|
|
||||||
|
mysql_databases: []
|
||||||
|
|
||||||
|
The MySQL databases to create. A database has the values `name`, `encoding` (defaults to `utf8`) and `collation` (defaults to `utf8_general_ci`). The formats of these are the same as in the `mysql_db` module.
|
||||||
|
|
||||||
|
mysql_users: []
|
||||||
|
|
||||||
|
The MySQL users and their privileges. A user has the values `name`, `host` (defaults to `localhost`), `password` and `priv` (defaults to `*.*:USAGE`). The formats of these are the same as in the `mysql_user` module.
|
||||||
|
|
||||||
mysql_packages:
|
mysql_packages:
|
||||||
- mysql
|
- mysql
|
||||||
- mysql-server
|
- mysql-server
|
||||||
|
@ -59,6 +67,15 @@ None.
|
||||||
*Inside `vars/main.yml`*:
|
*Inside `vars/main.yml`*:
|
||||||
|
|
||||||
mysql_root_password: super-secure-password
|
mysql_root_password: super-secure-password
|
||||||
|
mysql_databases:
|
||||||
|
- name: example_db
|
||||||
|
encoding: latin1
|
||||||
|
collation: latin1_general_ci
|
||||||
|
mysql_users:
|
||||||
|
- name: example_user
|
||||||
|
host: "%"
|
||||||
|
password: similarly-secure-password
|
||||||
|
priv: "example_db.*:ALL"
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -42,3 +42,7 @@ mysql_innodb_lock_wait_timeout: 50
|
||||||
|
|
||||||
# mysqldump settings
|
# mysqldump settings
|
||||||
mysql_mysqldump_max_allowed_packet: "64M"
|
mysql_mysqldump_max_allowed_packet: "64M"
|
||||||
|
|
||||||
|
# databases and users settings
|
||||||
|
mysql_databases: []
|
||||||
|
mysql_users: []
|
||||||
|
|
|
@ -70,3 +70,20 @@
|
||||||
mysql_db: >
|
mysql_db: >
|
||||||
name="test"
|
name="test"
|
||||||
state=absent
|
state=absent
|
||||||
|
|
||||||
|
- name: Ensure MySQL databases are present.
|
||||||
|
mysql_db: >
|
||||||
|
name="{{ item.name }}"
|
||||||
|
collation="{{ item.collation | default('utf8_general_ci') }}"
|
||||||
|
encoding="{{ item.encoding | default('utf8') }}"
|
||||||
|
state=present
|
||||||
|
with_items: mysql_databases
|
||||||
|
|
||||||
|
- name: Ensure MySQL users are present.
|
||||||
|
mysql_user: >
|
||||||
|
name="{{ item.name }}"
|
||||||
|
host="{{ item.host | default('localhost') }}"
|
||||||
|
password="{{ item.password }}"
|
||||||
|
priv="{{ item.priv | default('*.*:USAGE') }}"
|
||||||
|
state=present
|
||||||
|
with_items: mysql_users
|
||||||
|
|
Loading…
Reference in a new issue