Skip to content

Commit

Permalink
update - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Oct 27, 2021
1 parent b01931b commit bf0d915
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
5 changes: 4 additions & 1 deletion setup/roles/update/tasks/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

- name: Getting python-version of core-venv
ansible.builtin.shell: "{{ ga_update_path_home_core }}/venv/bin/python3 --version | cut -d ' ' -f2"
changed_when: false
register: ga_raw_core_venv_version

- name: Checking core-venv version
ansible.builtin.set_fact:
ga_remove_core_venv: true
changed_when: false
when: ga_raw_core_venv_version.stdout|float < ga_python_version|float

- name: Getting python-version of web-venv
ansible.builtin.shell: "{{ ga_update_path_home_web }}/venv/bin/python3 --version | cut -d ' ' -f2"
changed_when: false
register: ga_raw_web_venv_version

- name: Checking web-venv version
ansible.builtin.set_fact:
ga_remove_web_venv: true
changed_when: false
when: ga_raw_web_venv_version.stdout|float < ga_python_version|float

23 changes: 12 additions & 11 deletions setup/roles/update/tasks/do.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
loop_control:
loop_var: venv
with_items:
- {path: "{{ ga_update_path_home_core }}/venv", remove: "{{ ga_remove_core_venv }}", label: 'core', mods: "{{ ga_core_mods }}"}
- {path: "{{ ga_update_path_home_web }}/venv", remove: "{{ ga_remove_web_venv }}", label: 'web', mods: "{{ ga_django_mods }}"}
- {path: "{{ ga_update_path_home_core }}/venv", remove: "{{ ga_remove_core_venv }}"}
- {path: "{{ ga_update_path_home_web }}/venv", remove: "{{ ga_remove_web_venv }}"}
ignore_errors: true
register: update_remove_venv

Expand All @@ -23,8 +23,8 @@
loop_control:
loop_var: venv
with_items:
- {path: "{{ ga_update_path_home_core }}/venv", label: 'core', mods: "{{ ga_core_mods }}"}
- {path: "{{ ga_update_path_home_web }}/venv", label: 'web', mods: "{{ ga_django_mods }}"}
- {path: "{{ ga_update_path_home_core }}/venv", mods: "{{ ga_core_mods }}"}
- {path: "{{ ga_update_path_home_web }}/venv", mods: "{{ ga_django_mods }}"}
ignore_errors: true
register: update_venv

Expand All @@ -35,14 +35,15 @@
recursive: yes
delete: yes
rsync_opts: "{{ item.opts | default([]) }}"
delegate_to: 'localhost'
with_items:
- {src: "{{ ga_update_path_repo }}/code/", dst: "{{ ga_update_path_core }}/", opts: [
'--exclude=secret/*', '--exclude=web/', '--exclude=update/', '--exclude=__pycache__/', '--exclude=*.conf', '--exclude=*.cnf',
]}
- {src: "{{ ga_update_path_repo }}/code/web/base/", dst: "{{ ga_update_path_web }}/", opts: [
'--exclude=*.cnf', '--exclude=*.conf', '--exclude=migrations/*', '--exclude=__pycache__/', '--exclude=static/', '--exclude=base/config.py',
]}
- {
src: "{{ ga_update_path_repo }}/code/", dst: "{{ ga_update_path_core }}/",
opts: ['--exclude=secret/*', '--exclude=web/', '--exclude=update/', '--exclude=__pycache__/', '--exclude=*.conf', '--exclude=*.cnf']
}
- {
src: "{{ ga_update_path_repo }}/code/web/base/", dst: "{{ ga_update_path_web }}/",
opts: ['--exclude=*.cnf', '--exclude=*.conf', '--exclude=migrations/*', '--exclude=__pycache__/', '--exclude=static/', '--exclude=base/config.py']
}
- {src: "{{ ga_update_path_repo }}/code/web/base/static/", dst: "{{ ga_update_path_web_static }}/"}
ignore_errors: true
register: update_code
Expand Down
1 change: 1 addition & 0 deletions setup/roles/update/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- name: GA | Update | Evaluating update result
ansible.builtin.set_fact:
ga_update_failed: true
changed_when: false
when: >
(update_remove_venv.failed is defined and update_remove_venv.failed) or
(update_venv.failed is defined and update_venv.failed) or
Expand Down
11 changes: 9 additions & 2 deletions setup/roles/update/tasks/preparations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
url: 'https://api.github.com/repos/superstes/growautomation/tags'
register: ga_release_list
delegate_to: localhost
changed_when: false
when:
- ga_update_method == 'online'
- ga_update_release is undefined or ga_update_release == 'None'
Expand All @@ -15,6 +16,7 @@
- name: GA | Update | Prep | Getting last release version
ansible.builtin.set_fact:
ga_update_release: "{{ ga_release_list.json | json_query('[*].name') | first }}"
changed_when: false
when:
- ga_update_method == 'online'
- ga_update_release is undefined or ga_update_release == 'None'
Expand All @@ -23,6 +25,7 @@
- name: GA | Update | Prep | Getting commit-id of last release version
ansible.builtin.set_fact:
ga_update_commit: "{{ ga_release_list.json | json_query('[*].commit.sha') | first }}"
changed_when: false
when:
- ga_update_method == 'online'
- ga_update_type != 'commit'
Expand All @@ -33,11 +36,13 @@
- name: GA | Update | Prep | Checking if repository exists
ansible.builtin.stat:
path: "{{ ga_update_path_repo }}"
changed_when: false
register: local_repo

- name: GA | Update | Prep | Checking if repository is valid
ansible.builtin.shell: "git ls-remote {{ ga_update_path_repo }} 2&> /dev/null; echo $?"
register: repo_exists
changed_when: false
when:
- local_repo.stat.exists
- local_repo.stat.isdir
Expand All @@ -48,8 +53,8 @@
Please download the repository from a remote pc via 'git clone https://github.com/superstes/growautomation.git' and copy it to the local disk!
Or try using the online-update functionality."
when: >
not offline_repo.stat.exists or
not offline_repo.stat.isdir or
not local_repo.stat.exists or
not local_repo.stat.isdir or
repo_exists.stdout != '0'
# setting repo to target version
Expand All @@ -65,11 +70,13 @@
- name: GA | Update | Prep | Getting release of commit
ansible.builtin.shell: "cd {{ ga_update_path_repo }} && git describe --tags | cut -d '-' -f1"
register: ga_raw_commit_release
changed_when: false
when: ga_update_type == 'commit'

# get 'parent'-release of commit if commit is used as a target version

- name: GA | Update | Prep | Setting release version
ansible.builtin.set_fact:
ga_update_release: "{{ ga_raw_commit_release.stdout }}"
changed_when: false
when: ga_update_type == 'commit'

0 comments on commit bf0d915

Please sign in to comment.