diff --git a/tasks/dbd.yml b/tasks/dbd.yml new file mode 100644 index 0000000..979735a --- /dev/null +++ b/tasks/dbd.yml @@ -0,0 +1,94 @@ +--- + - name: get munge key for distribution to nodes + copy: src=files/munge.key + dest=/etc/munge/munge.key + owner=munge + group=munge + mode=0400 + notify: + - restart munge + + - name: start munge + service: name=munge state=started enabled=yes + + - name: install slurmdbd specific packages for EL6 + yum: "name={{item}} state=present" + with_items: + - "mysql" + - "mysql-server" + - "mysql-devel" + - "MySQL-python" + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" + + - name: start and enable mysql + service: name=mysqld state=started enabled=yes + register: mysql_start + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" + + - name: install slurmdbd specific packages for EL7 + yum: "name={{item}} state=present" + register: install_slurm_packages + with_items: + - "mariadb" + - "mariadb-server" + - "mariadb-devel" + - "MySQL-python" + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + + - name: start and enable mariadb on EL7 + service: name=mariadb state=started enabled=yes + register: mariadb_start + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + + - name: restart mariadb after install + service: name=mariadb state=restarted + when: install_slurm_packages.changed + + - name: cat /etc/my.cnf + command: cat /etc/my.cnf + register: slurm_mariadb_cnf + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + changed_when: False + + - name: print slurm_mariadb_cnf + debug: "var=slurm_mariadb_cnf" + tags: debug + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + changed_when: False + + - name: systemctl status mariadb + command: systemctl status mariadb + register: systemctl_slurm_status + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + changed_when: False + + - name: wait for mysql in port 3306 to start + wait_for: port=3306 delay=10 timeout=60 + + - name: create slurm acct db + mysql_db: name=slurm_acct_db state=present + + - name: check if slurm db user exists + mysql_user: "name=slurm state=present" + register: mysqlslurmuser + ignore_errors: yes + tags: debug + + - name: print mysqlslurmuser + debug: "var=mysqlslurmuser" + tags: debug + changed_when: False + + - name: slurm_mysql_password variable must be set + assert: + that: "slurm_mysql_password is defined" + + - name: create slurm db user if it does not exist + mysql_user: "name=slurm password={{ slurm_mysql_password }} priv=slurm_acct_db.*:ALL state=present" + when: mysqlslurmuser|failed + + - name: slurmdbd.conf + template: src=slurmdbd.conf.j2 dest=/etc/slurm/slurmdbd.conf owner=root mode=0640 backup=yes + + - name: restart and enable slurmdbd + service: name=slurmdbd state=restarted enabled=yes diff --git a/tasks/main.yml b/tasks/main.yml index e8c1af3..7796417 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,9 @@ - include: common.yml when: ansible_os_family == "RedHat" +- include: dbd.yml + when: (slurm_accounting_storage_host == ansible_hostname) and ansible_os_family == "RedHat" + - include: service.yml when: slurm_type == "service" and ansible_os_family == "RedHat" diff --git a/tasks/service.yml b/tasks/service.yml index 930021b..545e383 100644 --- a/tasks/service.yml +++ b/tasks/service.yml @@ -2,88 +2,23 @@ - name: install service specific packages for EL6 yum: "name={{item}} state=present" with_items: - - "mysql" - - "mysql-server" - - "mysql-devel" - "lua-devel" - - "MySQL-python" - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" - - - name: start and enable mysql - service: name=mysqld state=started enabled=yes - register: mysql_start when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" - name: install service specific packages for EL7 yum: "name={{item}} state=present" register: install_slurm_packages with_items: - - "mariadb" - - "mariadb-server" - - "mariadb-devel" - "lua-devel" - - "MySQL-python" - "mailx" when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" - - name: start and enable mariadb on EL7 - service: name=mariadb state=started enabled=yes - register: mariadb_start - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" - - - name: restart mariadb after install - service: name=mariadb state=restarted - when: install_slurm_packages.changed - - - name: cat /etc/my.cnf - command: cat /etc/my.cnf - register: slurm_mariadb_cnf - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" - changed_when: False - - - name: print slurm_mariadb_cnf - debug: "var=slurm_mariadb_cnf" - tags: debug - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" - changed_when: False - - - name: systemctl status mariadb - command: systemctl status mariadb - register: systemctl_slurm_status - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" - changed_when: False - - name: print systemctl_slurm_status debug: "var=systemctl_slurm_status" tags: debug when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" changed_when: False - - name: wait for mysql in port 3306 to start - wait_for: port=3306 delay=10 timeout=60 - - - name: create slurm acct db - mysql_db: name=slurm_acct_db state=present - - - name: check if slurm db user exists - mysql_user: "name=slurm state=present" - register: mysqlslurmuser - ignore_errors: yes - tags: debug - - - name: print mysqlslurmuser - debug: "var=mysqlslurmuser" - tags: debug - changed_when: False - - - name: slurm_mysql_password variable must be set - assert: - that: "slurm_mysql_password is defined" - - - name: create slurm db user if it does not exist - mysql_user: "name=slurm password={{ slurm_mysql_password }} priv=slurm_acct_db.*:ALL state=present" - when: mysqlslurmuser|failed - - name: does the munge.key exist? stat: path=/etc/munge/munge.key register: mungekeystat @@ -180,9 +115,6 @@ command: /usr/bin/make -C /var/yp when: nis_server - - name: slurmdbd.conf - template: src=slurmdbd.conf.j2 dest=/etc/slurm/slurmdbd.conf owner=root mode=0640 backup=yes - - name: restart munge service: name=munge state=restarted when: mungekeygen.changed and mungekeygen is defined @@ -209,9 +141,6 @@ - name: add slurmstate tmp dir file: "path={{ slurm_state_dir }} state=directory owner=slurm group=slurm mode=0750" - - name: restart and enable slurmdbd - service: name=slurmdbd state=restarted enabled=yes - - name: sacctmgr show cluster siteName and store in slurm_clusterlist variable command: "sacctmgr -n show cluster {{ siteName }}" register: slurm_clusterlist diff --git a/templates/slurmdbd.conf.j2 b/templates/slurmdbd.conf.j2 index 78065a3..265b16a 100644 --- a/templates/slurmdbd.conf.j2 +++ b/templates/slurmdbd.conf.j2 @@ -14,8 +14,7 @@ AuthType=auth/munge #AuthInfo=/var/run/munge/munge.socket.2 # # slurmDBD info -DbdAddr={{ hostvars[groups['slurm_service'][0]]['ansible_hostname'] }} -DbdHost={{ hostvars[groups['slurm_service'][0]]['ansible_hostname'] }} +DbdHost={{ slurm_accounting_storage_host }} #DbdPort=7031 SlurmUser=slurm #MessageTimeout=300