Skip to content

Commit

Permalink
Make sure slurm_start_services is a boolean
Browse files Browse the repository at this point in the history
When ansible-playbook is called with `-e slurm_start_services=false`,
the variable is evaluated as a string (which is true). Apply the
`| bool` filter to evaluate the variable as a boolean.
  • Loading branch information
btravouillon committed Oct 9, 2023
1 parent e265c54 commit 7344fe3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ansible.builtin.service:
name: "{{ slurmdbd_service_name }}"
state: reloaded
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

- name: Restart slurmdbd
ansible.builtin.systemd:
Expand All @@ -17,13 +17,13 @@
masked: no
enabled: yes
daemon_reload: yes
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Reload slurmctld
ansible.builtin.service:
name: "{{ slurmctld_service_name }}"
state: reloaded
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Restart slurmctld
ansible.builtin.systemd:
Expand All @@ -32,16 +32,16 @@
masked: no
enabled: yes
daemon_reload: yes
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Reload slurmd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
state: reloaded
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"

- name: Restart slurmd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
state: restarted
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@
name: "{{ slurmdbd_service_name }}"
enabled: true
state: started
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

- name: Ensure slurmctld is enabled and running
ansible.builtin.service:
name: "{{ slurmctld_service_name }}"
enabled: true
state: started
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Ensure slurmd is enabled and running
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
enabled: true
state: started
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"

- name: Setup cluster on slurmdb
include_tasks: slurmdbd_cluster.yml
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"
when: "(slurm_start_services | bool) and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

0 comments on commit 7344fe3

Please sign in to comment.