From 0d5fce0097ea06f4b9c7b5dfccb0cb2d95d8569f Mon Sep 17 00:00:00 2001 From: handreas <andreas.hamacher@monash.edu> Date: Sun, 16 Feb 2020 22:30:17 +0000 Subject: [PATCH] added more contitionals on root pw change. In case the server gets rebuild but the existing db was re-attached as a volume Former-commit-id: c6853e230902909f649711649618f3a76edce503 --- roles/mysql/handlers/main.yml | 2 +- roles/mysql/tasks/mysql_server.yml | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/roles/mysql/handlers/main.yml b/roles/mysql/handlers/main.yml index a934d695..a4030845 100644 --- a/roles/mysql/handlers/main.yml +++ b/roles/mysql/handlers/main.yml @@ -1,4 +1,4 @@ --- -- name: "Restart MySQL" +- name: "Restart MySQL" service: name={{ sqlServiceName }} state=restarted become: true diff --git a/roles/mysql/tasks/mysql_server.yml b/roles/mysql/tasks/mysql_server.yml index f8edd4e6..63d528e8 100644 --- a/roles/mysql/tasks/mysql_server.yml +++ b/roles/mysql/tasks/mysql_server.yml @@ -10,7 +10,7 @@ with_items: "{{ server_packages }}" become: true when: ansible_os_family == "RedHat" - + - name: make sure mysql conf directory exists file: dest=/etc/mysql/conf.d state=directory become: true @@ -29,12 +29,18 @@ # - ::1 # - localhost -- name: update mysql root password for all root accounts # this will only work if a completely fresh db gets installed because it gets shipped with a blank root pw +- name: Check that the slurm_acct_db_directory exists + stat: + path: /var/lib/mysql/slurm_acct_db/ #defined in /vars/filesystems.yaml + register: slurm_acct_db_directory_result + +# this will only work if a completely fresh db gets installed because it gets shipped with a blank root pw +- name: update mysql root password for all root accounts mysql_user: name=root host=localhost password={{ mysql_root_password }} login_user=root - when: mysqldb_confdir_create.changed - + when: not slurm_acct_db_directory_result.stat.exists and mysqldb_confdir_create.changed + - name: "Adding user database" - mysql_db: name={{ mysql_user_db_name }} state=present login_user=root login_password={{ mysql_root_password }} + mysql_db: name={{ mysql_user_db_name }} state=present login_user=root login_password={{ mysql_root_password }} - name: "Giving priviliges to user" mysql_user: name={{ mysql_user_name }} host={{ mysql_user_host }} password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present -- GitLab