Skip to content

Commit

Permalink
cloudplow: parse upload_from paths and fail if not unique
Browse files Browse the repository at this point in the history
Rework config template to properly support the remotes with paths format.
  • Loading branch information
saltydk committed Aug 21, 2023
1 parent 134d3c8 commit 908c50e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions roles/cloudplow/tasks/subtasks/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
loop: "{{ rclone.remotes }}"
when: item.upload

- name: Settings | Filter Rclone upload_from on remotes
ansible.builtin.set_fact:
cloudplow_upload_paths_unique: "{{ cloudplow_upload_paths_unique + [item.upload_from] }}"
loop: "{{ rclone.remotes }}"
when: item.upload and (item.upload_from not in cloudplow_upload_paths_unique)

- name: Settings | Fail if duplicate folders where found.
ansible.builtin.fail:
msg:
- "Duplicate upload folders found. This is likely an error on your part."
- "If not then supply your own configuration file at '{{ cloudplow_config_path }}' and rerun the previous tag."
when: (cloudplow_remotes | length) != (cloudplow_upload_paths_unique | length)

- name: Settings | Check if 'config.json' exists
ansible.builtin.stat:
path: "{{ cloudplow_config_path }}"
Expand Down
8 changes: 4 additions & 4 deletions roles/cloudplow/templates/config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"remotes": {
{% for remote in cloudplow_remotes %}
"{{ remote.remote }}": {
"{{ remote.remote.split(':')[0] if ':' in remote.remote else remote.remote }}": {
"hidden_remote": "",
"rclone_command": "move",
"rclone_excludes": [
Expand All @@ -56,9 +56,9 @@
}
},
"remove_empty_dir_depth": 2,
"sync_remote": "{{ remote.remote }}",
"sync_remote": "{{ remote.remote if ':' in remote.remote else remote.remote + ':' }}",
"upload_folder": "{{ remote.upload_from }}",
"upload_remote": "{{ remote.remote }}"
"upload_remote": "{{ remote.remote if ':' in remote.remote else remote.remote + ':' }}"
{% if loop.index == loop.length %}}{% else %}},{{ '\n' }}{% endif %}
{% endfor %}

Expand All @@ -71,7 +71,7 @@
"syncer": {},
"uploader": {
{% for remote in cloudplow_remotes %}
"{{ remote.remote }}": {
"{{ remote.remote.split(':')[0] if ':' in remote.remote else remote.remote }}": {
"check_interval": 30,
"exclude_open_files": false,
"max_size_gb": 200,
Expand Down

0 comments on commit 908c50e

Please sign in to comment.