Skip to content

Commit

Permalink
various: use set theory conditionals
Browse files Browse the repository at this point in the history
Using intersect to check for a list of tags is cleaner than using or.
  • Loading branch information
saltydk committed Jul 29, 2023
1 parent 3d83200 commit c474777
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion roles/backup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

- name: Cron
ansible.builtin.import_tasks: "cron.yml"
when: (('set-backup' in ansible_run_tags) or ('unset-backup' in ansible_run_tags)) and not ('backup' in ansible_run_tags)
when: (['set-backup', 'unset-backup'] | intersect(ansible_run_tags)) and not ('backup' in ansible_run_tags)
tags:
- set-backup
- unset-backup
Expand Down
2 changes: 1 addition & 1 deletion roles/backup2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

- name: Cron
ansible.builtin.import_tasks: "cron.yml"
when: (('set-backup2' in ansible_run_tags) or ('unset-backup2' in ansible_run_tags)) and not ('backup2' in ansible_run_tags)
when: (['set-backup2', 'unset-backup2'] | intersect(ansible_run_tags)) and not ('backup2' in ansible_run_tags)
tags:
- set-backup2
- unset-backup2
Expand Down
4 changes: 2 additions & 2 deletions roles/hetzner_nfs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- "../../defaults/hetzner_nfs.yml.default"

- name: Server Tasks
when: ('hetzner-nfs-server' in ansible_run_tags) or ('hetzner-nfs-server-uninstall' in ansible_run_tags)
when: (['hetzner-nfs-server', 'hetzner-nfs-server-uninstall'] | intersect(ansible_run_tags))
block:
- name: "Hetzner NFS Server Tasks"
ansible.builtin.include_tasks: "hetzner_nfs_server.yml"
Expand All @@ -25,7 +25,7 @@
when: ('hetzner-nfs-server-uninstall' in ansible_run_tags)

- name: Client Tasks
when: ('hetzner-nfs-client-mount' in ansible_run_tags) or ('hetzner-nfs-client-unmount' in ansible_run_tags)
when: (['hetzner-nfs-client-mount', 'hetzner-nfs-client-unmount'] | intersect(ansible_run_tags))
block:
- name: Fail when invalid hetzner_nfs.mount_client is specified
ansible.builtin.fail:
Expand Down
1 change: 0 additions & 1 deletion roles/lldap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@
- name: Wait for 60 seconds
ansible.builtin.wait_for:
timeout: 60
when: ('authelia' in ansible_run_tags) or ('authelia-reset' in ansible_run_tags) or ('lldap-reset' in ansible_run_tags)

0 comments on commit c474777

Please sign in to comment.