Skip to content

Commit

Permalink
Support tarball upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Ace authored and Eric Ace committed Sep 14, 2023
1 parent 6c81bed commit 975bea5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
8 changes: 4 additions & 4 deletions roles/rke2_common/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,20 @@
state: absent
changed_when: false

- name: Restart rke2-server if package installed and config changed
- name: Restart rke2-server if package installed and config changed or RKE2 version changed
service:
state: restarted
name: rke2-server
when:
- ansible_facts.services["rke2-server.service"] is defined
- "ansible_facts.services['rke2-server.service'].state == 'running'"
- tmp_sha1 != previous_rke2_config.stat.checksum
- (tmp_sha1 != previous_rke2_config.stat.checksum or (rke2_version_changed | default(false)))

- name: Restart rke2-agent if package installed and config changed
- name: Restart rke2-agent if package installed and config changed or RKE2 version changed
service:
state: restarted
name: rke2-agent
when:
- ansible_facts.services["rke2-agent.service"] is defined
- "ansible_facts.services['rke2-agent.service'].state == 'running'"
- tmp_sha1 != previous_rke2_config.stat.checksum
- (tmp_sha1 != previous_rke2_config.stat.checksum or (rke2_version_changed | default(false)))
22 changes: 20 additions & 2 deletions roles/rke2_common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

- name: Include images_tarball_install.yml
include_tasks: images_tarball_install.yml
when: not installed

- name: "Check for binary tarball in {{ playbook_dir }}/tarball_install/rke2.linux-amd64.tar.gz" # noqa name[template]
stat:
Expand All @@ -21,14 +20,33 @@
delegate_to: 127.0.0.1
become: no

- name: Detect RKE2 already installed and versions differ
block:
- name: Check for rke2 binary

Check failure on line 25 in roles/rke2_common/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

25:3 [indentation] wrong indentation: expected 4 but found 2

Check failure on line 25 in roles/rke2_common/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

25:3 [indentation] wrong indentation: expected 4 but found 2
stat:
path: /usr/local/bin/rke2
register: rke2_binary

- name: Determine the rke2 binary version
shell: /usr/local/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3
when: rke2_binary.stat.exists
register: installed_rke2_version
args:
executable: /usr/bin/bash

- name: Determine if current version differs what what is being installed
set_fact:
rke2_version_changed: true
when: "'stdout' in installed_rke2_version and installed_rke2_version['stdout'] != install_rke2_version"
ignore_errors: true

- name: SLES/Ubuntu/Tarball Installation
include_tasks: tarball_install.yml
when:
- |-
((ansible_facts['os_family'] != 'RedHat' and
ansible_facts['os_family'] != 'Rocky') or
rke2_binary_tarball_check.stat.exists )
and not installed
- name: RHEL/CentOS Installation
when:
Expand Down

0 comments on commit 975bea5

Please sign in to comment.