From d0542573c087f1d40f6e1fb0c137a267fccbd135 Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Sat, 2 Oct 2021 12:51:32 +1000 Subject: [PATCH] make roles with with ubuntu --- CICD/plays/nfssqlnodes.yml | 2 +- roles/mysql/tasks/Ubuntu_20_mysql_server.yml | 12 +++++++++--- roles/nfs-server/tasks/startServer.yml | 9 +++++++++ roles/slurmdb-config/tasks/main.yml | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CICD/plays/nfssqlnodes.yml b/CICD/plays/nfssqlnodes.yml index 670a7247..ba05c02b 100644 --- a/CICD/plays/nfssqlnodes.yml +++ b/CICD/plays/nfssqlnodes.yml @@ -36,7 +36,7 @@ gather_facts: True roles: # - { role: upgrade, tags: [ upgrade ] } - - { role: mysql, mysql_type: mysql_server, mysql_root_password: "{{ sqlrootPasswd }}", mysql_user_name: slurmdb, mysql_user_db_name: slurm_acct_db, mysql_user_hosts_group: "{{ groups['ManagementNodes'] }}", mysql_user_password: "{{ slurmdb_passwd }}", tags: [ database ] } + - { role: mysql, mysql_type: mysql_server, mysql_user_name: slurmdb, mysql_user_db_name: slurm_acct_db, mysql_user_hosts_group: "{{ groups['ManagementNodes'] }}", mysql_user_password: "{{ slurmdb_passwd }}", tags: [ database ] } - { role: slurm-mysql-config, tags: [database,slurmdb] } tags: [ sql ] diff --git a/roles/mysql/tasks/Ubuntu_20_mysql_server.yml b/roles/mysql/tasks/Ubuntu_20_mysql_server.yml index 71445f8d..945f6d9e 100644 --- a/roles/mysql/tasks/Ubuntu_20_mysql_server.yml +++ b/roles/mysql/tasks/Ubuntu_20_mysql_server.yml @@ -14,6 +14,7 @@ regexp: '^(bind.*)' replace: '#\1' become: true + register: bind_address - name: make sure mysql conf directory exists file: dest=/etc/mysql/conf.d state=directory @@ -24,6 +25,11 @@ service: name={{ sqlServiceName }} state=started enabled=true become: true +- name: "Starting MySQL" + service: name={{ sqlServiceName }} state=restarted enabled=true + become: true + when: bind_address.changed + - name: Check that the slurm_acct_db_directory exists stat: path: /var/lib/mysql/slurm_acct_db/ #defined in /vars/filesystems.yaml @@ -31,18 +37,18 @@ - name: "Adding user database" - mysql_db: name={{ mysql_user_db_name }} state=present login_user=root login_password={{ mysql_root_password }} login_unix_socket=/var/run/mysqld/mysqld.sock + mysql_db: name={{ mysql_user_db_name }} state=present login_user=root login_unix_socket=/var/run/mysqld/mysqld.sock become: true become_user: root - 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 login_unix_socket=/var/run/mysqld/mysqld.sock + mysql_user: name={{ mysql_user_name }} host={{ mysql_user_host }} password={{ mysql_user_password }} login_user=root priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present login_unix_socket=/var/run/mysqld/mysqld.sock when: mysql_user_host is defined become: true become_user: root - name: "Giving priviliges to user" - mysql_user: name={{ mysql_user_name }} host={{ hostvars[item].ansible_fqdn }} password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present login_unix_socket=/var/run/mysqld/mysqld.sock + mysql_user: name={{ mysql_user_name }} host={{ hostvars[item].ansible_fqdn }} password={{ mysql_user_password }} login_user=root priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present login_unix_socket=/var/run/mysqld/mysqld.sock with_items: "{{ mysql_user_hosts_group }}" when: mysql_user_hosts_group is defined become: true diff --git a/roles/nfs-server/tasks/startServer.yml b/roles/nfs-server/tasks/startServer.yml index 40b43124..77472e1f 100644 --- a/roles/nfs-server/tasks/startServer.yml +++ b/roles/nfs-server/tasks/startServer.yml @@ -9,6 +9,7 @@ copy: dest=/etc/exports src=files/etcExports mode=644 owner=root group=root become: true become_user: root + register: etcexports - name: "Starting rpcbind" service: "name=rpcbind state=started enabled=true" @@ -24,6 +25,7 @@ service: "name=nfs enabled=true" become: true when: ansible_os_family == "RedHat" and ansible_distribution_major_version < "7" + - name: "Enable the Server at boot" service: "name=nfs-server.service enabled=true" become: true @@ -33,11 +35,18 @@ command: /usr/sbin/exportfs -a become: true when: ansible_os_family == "Debian" + changed_when: false - name: "Start the Server" service: "name=nfs-kernel-server state=started enabled=true" become: true when: ansible_os_family == "Debian" +- name: "Start the Server" + service: "name=nfs-kernel-server state=restarted enabled=true" + become: true + when: ansible_os_family == "Debian" and etcexports.changed + + diff --git a/roles/slurmdb-config/tasks/main.yml b/roles/slurmdb-config/tasks/main.yml index 0304c45a..62546290 100644 --- a/roles/slurmdb-config/tasks/main.yml +++ b/roles/slurmdb-config/tasks/main.yml @@ -46,6 +46,9 @@ uid: 497 become: true +# +#This should be a template so the password isn't committed +# - name: install slurmdb.conf copy: src: files/slurmdbd.conf -- GitLab