Skip to content

Commit

Permalink
cloudplow: simplify filtering tasks
Browse files Browse the repository at this point in the history
moved path check into config generation block so we skip it otherwise
  • Loading branch information
saltydk committed Nov 28, 2023
1 parent 41c6b44 commit 03f9780
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 1 addition & 9 deletions roles/cloudplow/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@

- name: Filter Rclone remotes
ansible.builtin.set_fact:
cloudplow_remotes: "{{ cloudplow_remotes + [item] }}"
loop: "{{ rclone.remotes }}"
when: item.settings.upload

- name: Filter Rclone upload_from on remotes
ansible.builtin.set_fact:
cloudplow_upload_paths_unique: "{{ cloudplow_upload_paths_unique + [item.settings.upload_from] }}"
loop: "{{ rclone.remotes }}"
when: item.settings.upload and (item.settings.upload_from not in cloudplow_upload_paths_unique)
cloudplow_remotes: "{{ rclone.remotes | selectattr('settings.upload', 'equalto', True) | list }}"

- name: Cloudplow tasks
when: (cloudplow_remotes | length > 0)
Expand Down
8 changes: 8 additions & 0 deletions roles/cloudplow/tasks/subtasks/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
- name: Settings | New 'config.json' tasks
when: (not cloudplow_config.stat.exists)
block:
- name: Filter Rclone upload_from on remotes
ansible.builtin.set_fact:
cloudplow_upload_paths_unique: "{{ rclone.remotes
| selectattr('settings.upload', 'defined')
| selectattr('settings.upload', 'equalto', true)
| map(attribute='settings.upload_from')
| unique }}"

- name: Settings | Fail if duplicate folders where found.
ansible.builtin.fail:
msg:
Expand Down

0 comments on commit 03f9780

Please sign in to comment.