Skip to content

Commit

Permalink
settings: use old remote_is_defined for upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Jul 29, 2023
1 parent 5e7da7a commit 3d83200
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions inventories/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ rclone_remote_is_defined: "{{ (rclone is defined) and
(rclone.remotes is not none) and
(rclone.remotes | length > 0) }}"

rclone_old_remote_is_defined: "{{ (rclone is defined) and
(rclone is not none) and
(rclone | trim | length > 0) and
(rclone.remote is defined) and
(rclone.remote is not none) and
(rclone.remote | trim | length > 0) }}"

use_cloudplow: "{{ rclone_remote_is_defined and use_remote }}"

use_remote: "{{ rclone.enabled and not continuous_integration }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
yyq e -i '.rclone.remotes += [{"remote": "{{ rclone.remote }}", "template": "google", "cache": {"enabled": false, "size": "50G", "max_age": "504h"}, "port": 5572}]' {{ playbook_dir }}/{{ file }}
become: true
become_user: "{{ saltbox_yml.stat.pw_name }}"
when: (rclone.remotes is undefined) and rclone_remote_is_defined
when: (rclone.remotes is undefined) and rclone_old_remote_is_defined

- name: Migrator | 'settings.yml' | Migration 01 | Create 'rclone.remotes' dict
ansible.builtin.shell: |
yyq e -i '.rclone.remotes += [{"remote": "google", "template": "google", "cache": {"enabled": false, "size": "50G", "max_age": "504h"}, "port": 5572}]' {{ playbook_dir }}/{{ file }}
become: true
become_user: "{{ saltbox_yml.stat.pw_name }}"
when: (rclone.remotes is undefined) and not rclone_remote_is_defined
when: (rclone.remotes is undefined) and not rclone_old_remote_is_defined

- name: Migrator | 'settings.yml' | Migration 01 | Create 'rclone.enabled' dict
ansible.builtin.shell: |
yyq e -i '.rclone.enabled = {{ "true" if rclone_remote_is_defined else "false" }}' {{ playbook_dir }}/{{ file }}
yyq e -i '.rclone.enabled = {{ "true" if (rclone_old_remote_is_defined or rclone_remote_is_defined) else "false" }}' {{ playbook_dir }}/{{ file }}
become: true
become_user: "{{ saltbox_yml.stat.pw_name }}"
when: (rclone.enabled is undefined)
Expand Down

0 comments on commit 3d83200

Please sign in to comment.