From ac3ddb3ee0bb866c54e8e5ffc380b9d69a40829c Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Tue, 12 May 2015 23:48:10 -0400 Subject: [PATCH] Add database port and host configuration to role. --- README.md | 6 ++++++ defaults/main.yml | 4 +++- tasks/mysql_db.yaml | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aab42e8..b00c903 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,12 @@ Role Variables - setup_db: - Flag whether or not to setup the MySQL database directly on the host. - Default: true + - host: + - Flag whether or not to setup the MySQL database directly on the host. + - Default: localhost + - port: + - The port of which MySQL database directly on the host. + - Default: 3306 - rookeries_app_name: - Configures the unique name of the rookeries app. - Default: rookeries diff --git a/defaults/main.yml b/defaults/main.yml index 5f9b270..c0a9cd8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,8 @@ rookeries_db: username: rookeries password: system_admin setup_db: true + host: localhost + port: 3306 # Name of the rookeries app rookeries_app_name: rookeries @@ -26,7 +28,7 @@ rookeries_app_config: rookeries_secret_key: "development" # Database - rookeries_database_uri: "mysql+mysqlconnector://{{ rookeries_db. username}}:{{ rookeries_db.password }}@localhost:3306/{{ rookeries_db.db_name }}?charset=utf8" + rookeries_database_uri: "mysql+mysqlconnector://{{ rookeries_db. username}}:{{ rookeries_db.password }}@{{ rookeries_db.host }}:{{ rookeries_db.port }}/{{ rookeries_db.db_name }}?charset=utf8" # Mail server configuration rookeries_mail_server: "smtp.localhost.net" diff --git a/tasks/mysql_db.yaml b/tasks/mysql_db.yaml index 62b2390..0f3764d 100644 --- a/tasks/mysql_db.yaml +++ b/tasks/mysql_db.yaml @@ -7,9 +7,11 @@ when: rookeries_db.setup_db - name: setup MySQL databases for rookeries. - mysql_db: name={{ rookeries_db.db_name }} state=present + mysql_db: name={{ rookeries_db.db_name }} state=present login_host={{ rookeries_db.host }} + login_port={{ rookeries_db.port }} when: rookeries_db.setup_db - name: add MySQL database users for rookeries. mysql_user: name={{ rookeries_db.username }} password={{ rookeries_db.password }} priv={{ rookeries_db.db_name }}:ALL + login_host={{ rookeries_db.host }} login_port={{ rookeries_db.port }} when: rookeries_db.setup_db