Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version when files in tarball_install change #126

Closed
lynchmaniac opened this issue Sep 2, 2022 · 5 comments
Closed

Update version when files in tarball_install change #126

lynchmaniac opened this issue Sep 2, 2022 · 5 comments

Comments

@lynchmaniac
Copy link

Hi, This role work fine when i want to install, in an airgap way, a version of RKE2 on multi node (3 masters and 3 workers for example). But if i replace the actual rke2-images.linux-amd64.tar.zst and rke2.linux-amd64.tar.gz by some nexer artefact, the update doesn't work.

Scenario :

  • Install RKE2 with rke2-images.linux-amd64-1.23.5.tar.zst and rke2.linux-amd64-1.23.5.tar.gz
  • Files are in a tarball_install folder with name rke2-images.linux-amd64.tar.zst and rke2.linux-amd64.tar.gz
  • Check the node version and it's good 😃=> version 1.23.5
  • Remove current file
  • Replace with files rke2-images.linux-amd64-1.24.3.tar.zst and rke2.linux-amd64-1.24.3.tar.gz
  • Relaunch role for install RKE2
  • The role doesn't try to install new version of tarball

It's logical if you look at the code :

main/roles/rke2_common/tasks/main.yml

- include: images_tarball_install.yml
  when: not installed

Is it in the roadmap to implement the update of the version of RKE2 when files in tarball_install folder change ?

@audig
Copy link

audig commented Sep 4, 2022

Hi, thanks for the issue I try the same scenario as you.

I've developed a playbook which download tarball, with versions passed in parameters of the playbook.

I can check if version is différent from installed rke2 and i have added some variables to disable or enable downgrade or upgrade.

Something like this :

- name: Get installed version
  shell: /usr/local/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3
  register: rke2_installed_version
  changed_when: false
  args:
    executable: /bin/bash
  when: installed

- name: Check if upgrade is required
  ansible.builtin.debug:
    msg: "rke2 must be upgraded"
  when:
    - installed
    - tarball_upgrade_enabled
    - rke2_installed_version | regex_replace('^v(.*)$','\\1') is version( rke2_version | regex_replace('^v(.*)$','\\1'), '<', version_type='semver')

- name: Set fact for upgrade
  set_fact:
    upgrade_is_required: true
  when:
    - installed
    - tarball_upgrade_enabled
    - rke2_installed_version | regex_replace('^v(.*)$','\\1') is version(rke2_version | regex_replace('^v(.*)$','\\1'), '<', version_type='semver')

- name: Check if downgrade is required
  ansible.builtin.debug:
    msg: "rke2 must be downgraded"
  when:
    - installed
    - tarball_downgrade_enabled
    - rke2_installed_version | regex_replace('^v(.*)$','\\1') is version(rke2_version | regex_replace('^v(.*)$','\\1'), '>', version_type='semver')

- name: Set fact for downgrade
  set_fact:
    downgrade_is_required: true
  when:
    - installed
    - tarball_downgrade_enabled
    - rke2_installed_version | regex_replace('^v(.*)$','\\1') is version(rke2_version | regex_replace('^v(.*)$','\\1'), '>', version_type='semver')

And I've updated the main.yaml in common file by updating the when block:

- include: images_tarball_install.yml
  when: not installed or upgrade_is_required or downgrade_is_required
....
- name: SLES/Ubuntu/Tarball Installation
  include: tarball_install.yml
  when:
    - |-
      ((ansible_facts['os_family'] != 'RedHat' and
      ansible_facts['os_family'] != 'Rocky') or
      rke2_binary_tarball_check.stat.exists == true)
      and ( not installed or upgrade_is_required )

I don't know if I can open a PR, because it's a special use case which a version for rke2 is mandatory in my playbook, but it doesn't exist in this rke2 install role

@lynchmaniac
Copy link
Author

@audig thxs for the code. From my point of view, i think it's a good idea that you create a PR with your code. The possibility to upgrade or downgrade an installation is a good feature.

@Richardswe
Copy link

@lynchmaniac Just as a tip, you can automate this by using the upgrade-system-controller in your RKE2 cluster and adding 2 plans. 1 for the servers and 1 for the agent nodes, then you only need to change the RKE2 versions in those files then the controller do the upgrade for you.

@lynchmaniac
Copy link
Author

@Richardswe Thanks a lot for the tip 😃

@aceeric aceeric mentioned this issue Sep 14, 2023
4 tasks
@aleiner
Copy link
Contributor

aleiner commented May 20, 2024

resolved in #153

@aleiner aleiner closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants