diff --git a/defaults/main.yml b/defaults/main.yml index 357e3b4..e157e2e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,7 +19,7 @@ slurmdbd_service_name: slurmdbd __slurm_user_name: "{{ (slurm_user | default({})).name | default('slurm') }}" # TODO: this could be incorrect, use the group collection from galaxyproject.galaxy -__slurm_group_name: "{{ (slurm_user | default({})).group | default((slurm_user | default({})).name) | default('slurm') }}" +__slurm_group_name: "{{ (slurm_user | default({})).group | default(omit) }}" __slurm_debian: "{{ ansible_os_family == 'Debian' }}" __slurm_redhat: "{{ ansible_os_family == 'RedHat' }}" @@ -29,35 +29,37 @@ __slurm_config_default: CryptoType: crypto/munge SlurmUser: "{{ __slurm_user_name }}" ClusterName: cluster + # default is proctrack/cgroup which is the best but also less than 100% chance of working e.g. in docker + ProctrackType: proctrack/pgid # slurmctld options SlurmctldPort: 6817 - SlurmctldLogFile: "{{ '/var/log/slurm-llnl/slurmctld.log' if __slurm_debian else null }}" + SlurmctldLogFile: "{{ '/var/log/slurm-llnl/slurmctld.log' if __slurm_debian else None }}" SlurmctldPidFile: >- {{ '/var/run/slurm-llnl/slurmctld.pid' if __slurm_debian else ( '/var/run/slurmctld.pid' if __slurm_redhat else - null) + None) }} StateSaveLocation: >- {{ '/var/lib/slurm-llnl/slurmctld' if __slurm_debian else ( '/var/lib/slurm/slurmctld' if __slurm_redhat else - null) + None) }} # slurmd options SlurmdPort: 6818 - SlurmdLogFile: "{{ '/var/log/slurm-llnl/slurmd.log' if __slurm_debian else null }}" + SlurmdLogFile: "{{ '/var/log/slurm-llnl/slurmd.log' if __slurm_debian else None }}" SlurmdPidFile: >- {{ '/var/run/slurm-llnl/slurmd.pid' if __slurm_debian else ( '/var/run/slurm.pid' if __slurm_redhat else - null) + None) }} SlurmdSpoolDir: >- {{ '/var/lib/slurm-llnl/slurmd' if __slurm_debian else ( '/var/spool/slurm/slurmd' if __slurm_redhat else - null) + None) }} __slurm_config_merged: "{{ __slurm_config_default | combine(slurm_config | default({})) }}" @@ -83,7 +85,7 @@ __slurmdbd_config_default: {{ '/var/run/slurm-llnl/slurmdbd.pid' if __slurm_debian else ( '/var/run/slurmdbd.pid' if __slurm_redhat else - null) + None) }} - LogFile: "{{ '/var/log/slurm-llnl/slurmdbd.log' if __slurm_debian else null }}" + LogFile: "{{ '/var/log/slurm-llnl/slurmdbd.log' if __slurm_debian else None }}" __slurmdbd_config_merged: "{{ __slurmdbd_config_default | combine(slurmdbd_config | default({})) }}" diff --git a/tasks/main.yml b/tasks/main.yml index fe81947..b25a374 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +2,7 @@ - name: Include user creation tasks include_tasks: user.yml - when: slurm_user is defined + when: slurm_create_user - name: Include controller installation tasks include_tasks: slurmctld.yml diff --git a/tasks/munge.yml b/tasks/munge.yml index 0a6181d..dcf7b60 100644 --- a/tasks/munge.yml +++ b/tasks/munge.yml @@ -10,12 +10,12 @@ - name: Install munge key copy: - src: "{{ slurm_munge_key_src }}" + src: "{{ slurm_munge_key }}" dest: /etc/munge/munge.key owner: munge group: munge mode: 0400 - when: slurm_munge_key_src is defined + when: slurm_munge_key is defined - name: Ensure Munge is enabled and running service: diff --git a/tasks/slurmctld.yml b/tasks/slurmctld.yml index eb27077..1356b4f 100644 --- a/tasks/slurmctld.yml +++ b/tasks/slurmctld.yml @@ -23,4 +23,4 @@ group: "{{ __slurm_group_name }}" mode: 0755 state: directory - when: slurm_create_dirs and __slurm_config_merged.SlurmctldLogFile != None + when: slurm_create_dirs and __slurm_config_merged.SlurmctldLogFile diff --git a/tasks/slurmd.yml b/tasks/slurmd.yml index 5d3eb48..6948e58 100644 --- a/tasks/slurmd.yml +++ b/tasks/slurmd.yml @@ -23,7 +23,7 @@ group: "{{ __slurm_group_name }}" mode: 0755 state: directory - when: slurm_create_dirs and __slurm_config_merged.SlurmdLogFile != None + when: slurm_create_dirs and __slurm_config_merged.SlurmdLogFile - name: Include config dir creation tasks include_tasks: _inc_create_config_dir.yml diff --git a/tasks/slurmdbd.yml b/tasks/slurmdbd.yml index 7c84a55..ca4fd2f 100644 --- a/tasks/slurmdbd.yml +++ b/tasks/slurmdbd.yml @@ -22,4 +22,4 @@ group: "{{ __slurm_group_name }}" mode: 0755 state: directory - when: slurm_create_dirs and __slurmdbd_config_merged.LogFile != None + when: slurm_create_dirs and __slurmdbd_config_merged.LogFile diff --git a/tasks/user.yml b/tasks/user.yml index a65aa68..6038828 100644 --- a/tasks/user.yml +++ b/tasks/user.yml @@ -2,17 +2,18 @@ - name: Create slurm group group: - name: "{{ slurm_user.name | default('slurm') }}" - gid: "{{ slurm_user.gid | default(omit) }}" - system: "{{ slurm_user.system | default('yes') }}" + name: "{{ (slurm_user | default({})).group }}" + gid: "{{ (slurm_user | default({})).gid | default(omit) }}" + system: "{{ (slurm_user | default({})).system | default('yes') }}" + when: (slurm_user | default({})).group is defined - name: Create slurm user user: - name: "{{ slurm_user.name | default('slurm') }}" - comment: "{{ slurm_user.comment | default(omit) }}" - uid: "{{ slurm_user.uid | default(omit) }}" - group: "{{ slurm_user.group | default(slurm_user.name | default('slurm')) }}" - groups: "{{ slurm_user.groups | default(omit) }}" - home: "{{ slurm_user.home | default(omit) }}" - shell: "{{ slurm_user.shell | default(omit) }}" - system: "{{ slurm_user.system | default('yes') }}" + name: "{{ (slurm_user | default({})).name | default('slurm') }}" + comment: "{{ (slurm_user | default({})).comment | default(omit) }}" + uid: "{{ (slurm_user | default({})).uid | default(omit) }}" + group: "{{ (slurm_user | default({})).group | default(omit) }}" + groups: "{{ (slurm_user | default({})).groups | default(omit) }}" + home: "{{ (slurm_user | default({})).home | default(omit) }}" + shell: "{{ (slurm_user | default({})).shell | default(omit) }}" + system: "{{ (slurm_user | default({})).system | default('yes') }}" diff --git a/templates/slurm.conf.j2 b/templates/slurm.conf.j2 index 001a343..3b9ac94 100644 --- a/templates/slurm.conf.j2 +++ b/templates/slurm.conf.j2 @@ -9,18 +9,22 @@ ControlMachine=localhost # Configuration options {% for key in __slurm_config_merged | sort %} -{% if __slurm_config_merged[key] != None %} +{% if __slurm_config_merged[key] %} {{ key }}={{ __slurm_config_merged[key] }} {% endif %} {% endfor %} # Nodes {% for i in slurm_nodes %} -NodeName={{ i.name }}{% for k in i %} {{ k }}={{ i[k] }}{% endfor %} +NodeName={{ i.name }}{% for k in i | sort %} {{ k }}={{ i[k] }}{% endfor %} +{% else %} +NodeName=localhost State=UNKNOWN {% endfor %} # Partitions {% for i in slurm_partitions %} -PartitionName={{ i.name }}{% for k in i %} {{ k }}={{ i[k] }}{% endfor %} +PartitionName={{ i.name }}{% for k in i | sort %} {{ k }}={{ i[k] }}{% endfor %} +{% else %} +PartitionName=debug Default=YES Nodes={{ slurm_nodes[0] | default('localhost') }} State=UP {% endfor %}