From ae5e64ba8092fdfd819ca6b49fb954df14782eb5 Mon Sep 17 00:00:00 2001 From: Chris Krelle Date: Wed, 16 Mar 2016 14:50:47 -0700 Subject: [PATCH] Allow mysql_username and mysql_password to be passed via env var. This change allows mysql_username and mysql_password to be passed to bifrost-ironic-install via the environment variables mysql_user and mysql_pass. This is useful when there is a preexisting mysql installation with passwords alreay set. Change-Id: I6dfd3ec0e769f0af6b157cde106885eabc24d120 --- playbooks/roles/bifrost-ironic-install/tasks/main.yml | 10 ++++++++++ ...pport-for-mysql-user-password-3ac520eea7ea9807.yaml | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 releasenotes/notes/Add-env-var-support-for-mysql-user-password-3ac520eea7ea9807.yaml diff --git a/playbooks/roles/bifrost-ironic-install/tasks/main.yml b/playbooks/roles/bifrost-ironic-install/tasks/main.yml index 2f98d702a..641f96e02 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/main.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/main.yml @@ -136,6 +136,16 @@ write_priv: ".*" read_priv: ".*" no_log: true +- name: "Set mysql_username if environment variable mysql_user is set" + set_fact: + mysql_username: "{{ lookup('env', 'mysql_user') }}" + when: lookup('env', 'mysql_user') | length > 0 + no_log: true +- name: "Set mysql_password if environment variable mysql_pass is set" + set_fact: + mysql_password: "{{ lookup('env', 'mysql_pass') }}" + when: lookup('env', 'mysql_pass') | length > 0 + no_log: true - name: "MySQL - Creating DB" mysql_db: name: "ironic" diff --git a/releasenotes/notes/Add-env-var-support-for-mysql-user-password-3ac520eea7ea9807.yaml b/releasenotes/notes/Add-env-var-support-for-mysql-user-password-3ac520eea7ea9807.yaml new file mode 100644 index 000000000..868e88390 --- /dev/null +++ b/releasenotes/notes/Add-env-var-support-for-mysql-user-password-3ac520eea7ea9807.yaml @@ -0,0 +1,7 @@ +--- +features: + - Add support for passing a Mysql username and password + via environment variables mysql_user for username and + mysql_pass for password. Useful for cases where Mysql + server may be existing and have usernames with password + already set.