Add support to conditionally setup the database.

This commit is contained in:
Dorian 2015-05-12 23:30:39 -04:00
parent ffae28aecc
commit 4cb24dd580
3 changed files with 7 additions and 0 deletions

View File

@ -47,6 +47,9 @@ Role Variables
- The database username for the above specified database. - The database username for the above specified database.
- password: - password:
- The database username for the above specified database. - The database username for the above specified database.
- setup_db:
- Flag whether or not to setup the MySQL database directly on the host.
- Default: true
- rookeries_app_name: - rookeries_app_name:
- Configures the unique name of the rookeries app. - Configures the unique name of the rookeries app.
- Default: rookeries - Default: rookeries

View File

@ -6,6 +6,7 @@ rookeries_db:
db_name: rookeries db_name: rookeries
username: rookeries username: rookeries
password: system_admin password: system_admin
setup_db: true
# Name of the rookeries app # Name of the rookeries app
rookeries_app_name: rookeries rookeries_app_name: rookeries

View File

@ -4,9 +4,12 @@
with_items: with_items:
- mysql-server - mysql-server
- python-mysqldb - python-mysqldb
when: rookeries_db.setup_db
- name: setup MySQL databases for rookeries. - name: setup MySQL databases for rookeries.
mysql_db: name={{ rookeries_db.db_name }} state=present mysql_db: name={{ rookeries_db.db_name }} state=present
when: rookeries_db.setup_db
- name: add MySQL database users for rookeries. - name: add MySQL database users for rookeries.
mysql_user: name={{ rookeries_db.username }} password={{ rookeries_db.password }} priv={{ rookeries_db.db_name }}:ALL mysql_user: name={{ rookeries_db.username }} password={{ rookeries_db.password }} priv={{ rookeries_db.db_name }}:ALL
when: rookeries_db.setup_db