From b527959ed73c04d7e8f7dd691fdf8c9898e08028 Mon Sep 17 00:00:00 2001 From: Eric Ace Date: Thu, 14 Sep 2023 10:08:01 -0400 Subject: [PATCH 1/7] Support tarball upgrade --- roles/rke2_common/tasks/config.yml | 8 ++++---- roles/rke2_common/tasks/main.yml | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/roles/rke2_common/tasks/config.yml b/roles/rke2_common/tasks/config.yml index 4a9f0b48..65df874b 100644 --- a/roles/rke2_common/tasks/config.yml +++ b/roles/rke2_common/tasks/config.yml @@ -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))) diff --git a/roles/rke2_common/tasks/main.yml b/roles/rke2_common/tasks/main.yml index f3bda769..9cc8999e 100644 --- a/roles/rke2_common/tasks/main.yml +++ b/roles/rke2_common/tasks/main.yml @@ -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: @@ -21,6 +20,26 @@ delegate_to: 127.0.0.1 become: no +- name: Check for the rke2 binary + stat: + path: /usr/local/bin/rke2 + register: rke2_binary + +- name: If the rke2 binary exists, determine if the version is changing + when: rke2_binary.stat.exists + block: + - name: Get current RKE2 version + shell: set -o pipefail && /usr/local/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 + register: installed_rke2_version + changed_when: false + 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" + - name: SLES/Ubuntu/Tarball Installation include_tasks: tarball_install.yml when: @@ -28,7 +47,6 @@ ((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: From 74d0f5121cd45ccf310f88d9d72633499d469c9a Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Fri, 22 Sep 2023 09:24:12 -0400 Subject: [PATCH 2/7] refactor tarball installation, version calculation, and added tar upgrade capability --- .../tasks/calculate_rke2_version.yml | 66 +++++ roles/rke2_common/tasks/main.yml | 26 +- roles/rke2_common/tasks/previous_install.yml | 18 ++ roles/rke2_common/tasks/rpm_install.yml | 64 ----- roles/rke2_common/tasks/tarball_install.yml | 254 +++++++++--------- roles/rke2_common/vars/main.yml | 13 +- 6 files changed, 225 insertions(+), 216 deletions(-) create mode 100644 roles/rke2_common/tasks/calculate_rke2_version.yml diff --git a/roles/rke2_common/tasks/calculate_rke2_version.yml b/roles/rke2_common/tasks/calculate_rke2_version.yml new file mode 100644 index 00000000..4b8720bb --- /dev/null +++ b/roles/rke2_common/tasks/calculate_rke2_version.yml @@ -0,0 +1,66 @@ +- name: "Calculate rke2 full version " + when: ( install_rke2_version is not defined ) or ( install_rke2_version | length == 0 ) # noqa var-spacing + block: + - name: Stop if the provided is not valid + fail: + msg: "Provided channel is not valid" + when: rke2_channel not in channels + + - name: Get full version name url + uri: + url: https://update.rke2.io/v1-release/channels/{{ rke2_channel }} + follow_redirects: all + register: rke2_version_url + + - name: Set full version name + shell: set -o pipefail && echo {{ rke2_version_url.url }} | sed -e 's|.*/||' + register: rke2_full_version + changed_when: false + args: + executable: /usr/bin/bash + +- name: Set rke2_full_version fact # noqa var-spacing + set_fact: + rke2_full_version: "{{ rke2_full_version.stdout if ((install_rke2_version is not defined) or (install_rke2_version|length == 0)) else install_rke2_version }}" # yamllint disable-line rule:line-length + +- name: Set dot version + shell: set -o pipefail && echo {{ rke2_full_version }} | /usr/bin/cut -d'+' -f1 + register: rke2_version_dot_tmp + changed_when: false + args: + executable: /usr/bin/bash + +- name: Set rke2_version_dot fact + set_fact: + rke2_version_dot: "{{ rke2_version_dot_tmp.stdout }}" + +- name: Set Maj.Min version + shell: set -o pipefail && echo {{ rke2_full_version }} | /bin/awk -F'.' '{ print $1"."$2 }' | sed "s|^v||g" + register: rke2_version_majmin_tmp + changed_when: false + args: + executable: /usr/bin/bash + +- name: Set rke2_version_majmin fact + set_fact: + rke2_version_majmin: "{{ rke2_version_majmin_tmp.stdout }}" + +- name: Set RPM version + shell: set -o pipefail && echo {{ rke2_full_version }} | sed -E -e "s/[\+-]/~/g" | sed -E -e "s/v(.*)/\1/" + register: rke2_version_rpm_tmp + changed_when: false + args: + executable: /usr/bin/bash + +- name: Set rke2_version_rpm fact + set_fact: + rke2_version_rpm: "{{ rke2_version_rpm_tmp.stdout }}" + + +- name: Describe versions + debug: + msg: + - "Full version, with revision indication: {{ rke2_full_version }}" + - "Version without revision indication: {{ rke2_version_dot }}" + - "Major and Minor Only: {{ rke2_version_majmin }}" + - "RPM Version (tilde): {{ rke2_version_rpm }}" \ No newline at end of file diff --git a/roles/rke2_common/tasks/main.yml b/roles/rke2_common/tasks/main.yml index 9cc8999e..3a8a3b70 100644 --- a/roles/rke2_common/tasks/main.yml +++ b/roles/rke2_common/tasks/main.yml @@ -18,28 +18,12 @@ path: "{{ playbook_dir }}/tarball_install/rke2.linux-amd64.tar.gz" register: rke2_binary_tarball_check delegate_to: 127.0.0.1 - become: no - -- name: Check for the rke2 binary - stat: - path: /usr/local/bin/rke2 - register: rke2_binary - -- name: If the rke2 binary exists, determine if the version is changing - when: rke2_binary.stat.exists - block: - - name: Get current RKE2 version - shell: set -o pipefail && /usr/local/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 - register: installed_rke2_version - changed_when: false - 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" + become: False +- name: Include calculate_rke2_version.yml + include_tasks: calculate_rke2_version.yml + when: not rke2_binary_tarball_check.stat.exists + - name: SLES/Ubuntu/Tarball Installation include_tasks: tarball_install.yml when: diff --git a/roles/rke2_common/tasks/previous_install.yml b/roles/rke2_common/tasks/previous_install.yml index ab87b3a3..e142d536 100644 --- a/roles/rke2_common/tasks/previous_install.yml +++ b/roles/rke2_common/tasks/previous_install.yml @@ -27,3 +27,21 @@ when: > ansible_facts.services["rke2-agent.service"] is defined and not ansible_facts.services["rke2-agent.service"].status == 'disabled' + +- name: Check for the rke2 binary + stat: + path: /usr/local/bin/rke2 + register: rke2_binary + +- name: Get current RKE2 version if already installed + shell: set -o pipefail && /usr/local/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 + register: installed_rke2_version_tmp + changed_when: false + args: + executable: /usr/bin/bash + when: rke2_binary.stat.exists + +- name: Determine if current version differs what what is being installed + set_fact: + installed_rke2_version: "{{installed_rke2_version_tmp.stdout}}" + when: rke2_binary.stat.exists \ No newline at end of file diff --git a/roles/rke2_common/tasks/rpm_install.yml b/roles/rke2_common/tasks/rpm_install.yml index 0f2f3e1e..5af5056b 100644 --- a/roles/rke2_common/tasks/rpm_install.yml +++ b/roles/rke2_common/tasks/rpm_install.yml @@ -1,69 +1,5 @@ --- -- name: "Calculate rke2 full version " - when: ( install_rke2_version is not defined ) or ( install_rke2_version | length == 0 ) # noqa var-spacing - block: - - name: Stop if the provided is not valid - fail: - msg: "Provided channel is not valid" - when: rke2_channel not in channels - - - name: Get full version name url - uri: - url: https://update.rke2.io/v1-release/channels/{{ rke2_channel }} - follow_redirects: all - register: rke2_version_url - - - name: Set full version name - shell: set -o pipefail && echo {{ rke2_version_url.url }} | sed -e 's|.*/||' - register: rke2_full_version - changed_when: false - args: - executable: /usr/bin/bash - -- name: Set rke2_full_version fact # noqa var-spacing - set_fact: - rke2_full_version: "{{ rke2_full_version.stdout if ((install_rke2_version is not defined) or (install_rke2_version|length == 0)) else install_rke2_version }}" # yamllint disable-line rule:line-length - -- name: Set dot version - shell: set -o pipefail && echo {{ rke2_full_version }} | /usr/bin/cut -d'+' -f1 - register: rke2_version_dot - changed_when: false - args: - executable: /usr/bin/bash - -- name: Set rke2_version_dot fact - set_fact: - rke2_version_dot: "{{ rke2_version_dot.stdout }}" - -- name: Set Maj.Min version - shell: set -o pipefail && echo {{ rke2_full_version }} | /bin/awk -F'.' '{ print $1"."$2 }' | sed "s|^v||g" - register: rke2_version_majmin - changed_when: false - args: - executable: /usr/bin/bash - -- name: Set rke2_version_majmin fact - set_fact: - rke2_version_majmin: "{{ rke2_version_majmin.stdout }}" - -- name: Set RPM version - shell: set -o pipefail && echo {{ rke2_full_version }} | sed -E -e "s/[\+-]/~/g" | sed -E -e "s/v(.*)/\1/" - register: rke2_version_rpm - changed_when: false - args: - executable: /usr/bin/bash - -- name: Set rke2_version_rpm fact - set_fact: - rke2_version_rpm: "{{ rke2_version_rpm.stdout }}" - -- name: Describe versions - debug: - msg: - - "Full version: {{ rke2_full_version }}, dot version: {{ rke2_version_dot }}" - - "Maj.Min version: {{ rke2_version_majmin }}, rpm version: {{ rke2_version_rpm }}" - # Does the Rancher RKE2 Common repo exist already - name: Check to see if rke2-common.repo exists stat: diff --git a/roles/rke2_common/tasks/tarball_install.yml b/roles/rke2_common/tasks/tarball_install.yml index 1c6b53bf..b21e318f 100644 --- a/roles/rke2_common/tasks/tarball_install.yml +++ b/roles/rke2_common/tasks/tarball_install.yml @@ -24,56 +24,54 @@ mode: '0644' when: rke2_binary_tarball_check.stat.exists -- name: Download tarball # noqa var-spacing - when: not rke2_binary_tarball_check.stat.exists +- name: Determine if current version differs what what is being installed + set_fact: + rke2_version_changed: true + when: + - not rke2_binary_tarball_check.stat.exists + - not installed or installed_rke2_version != rke2_full_version + +- name: TARBALL | Download the tarball + get_url: + url: https://github.com/rancher/rke2/releases/download/{{ rke2_full_version }}/rke2.linux-amd64.tar.gz + dest: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" + mode: "0644" + when: + - not rke2_binary_tarball_check.stat.exists + - rke2_version_changed + +- name: TARBALL | Install tar package + package: + name: tar + state: present + ignore_errors: true + +- name: Get version of provided tarball + when: + - rke2_binary_tarball_check.stat.exists block: - - name: Stop if the provided channel is not valid - fail: - msg: "Provided channel is not valid" - when: rke2_channel not in channels - - - name: TARBALL | Get full version name url - uri: - url: https://update.rke2.io/v1-release/channels/{{ rke2_channel }} - follow_redirects: all - register: rke2_version_url - - - name: Set full version name - shell: set -o pipefail && echo {{ rke2_version_url.url }} | sed -e 's|.*/||' - register: rke2_full_version - changed_when: false - args: - executable: /bin/bash - - - name: Set dot version - shell: set -o pipefail && echo {{ rke2_full_version.stdout }} | /usr/bin/cut -d'+' -f1 - register: rke2_version_dot - changed_when: false - args: - executable: /bin/bash - - - name: Set Maj.Min version - shell: >- - set -o pipefail && echo {{ rke2_full_version.stdout }} - | awk -F'.' '{ print $1"."$2 }' | sed "s|^v||g" - register: rke2_version - changed_when: false - args: - executable: /bin/bash - - - name: Describe versions - debug: - msg: - - "Full version: {{ rke2_full_version.stdout }}" - - "dot version: {{ rke2_version_dot.stdout }}" - - "Maj.Min version: {{ rke2_version.stdout }}" - run_once: yes - - - name: TARBALL | Download the tarball - get_url: - url: https://github.com/rancher/rke2/releases/download/{{ rke2_full_version.stdout }}/rke2.linux-amd64.tar.gz - dest: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" - mode: "0644" + - name: Unarchive tarball into temp location + ansible.builtin.unarchive: + src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" + dest: "{{ temp_dir.path }}" + remote_src: True + + - name: Get tarball RKE2 version from temp location + shell: set -o pipefail && {{ temp_dir.path }}/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 + register: tarball_rke2_version_tmp + changed_when: false + args: + executable: /usr/bin/bash + + - name: Set tarball RKE2 version var + set_fact: + tarball_rke2_version: "{{tarball_rke2_version_tmp.stdout}}" + + - name: Determine if current version differs what what is being installed + set_fact: + rke2_version_changed: true + when: + - not installed or installed_rke2_version != tarball_rke2_version - name: TARBALL | Check Target Mountpoint command: mountpoint -q {{ tarball_dir }} @@ -98,87 +96,85 @@ recurse: true when: tarball_dir is defined -- name: TARBALL | Install tar package - package: - name: tar - state: present - ignore_errors: true - -- name: TARBALL | Extract the tarball # noqa command-instead-of-module - command: - cmd: tar -xf "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" -C "{{ tarball_dir }}" - changed_when: false +- name: Final extraction/installation of RKE2 Tar + when: + - rke2_version_changed + block: -- name: TARBALL | Remove the temp_dir + - name: Unarchive rke2 tar + ansible.builtin.unarchive: + src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" + dest: "{{ tarball_dir }}" + remote_src: True + + - name: TARBALL | Updating rke2-server.service + ansible.builtin.replace: + path: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Updating rke2-agent.service + ansible.builtin.replace: + path: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Updating rke2-uninstall.sh + ansible.builtin.replace: + path: "{{ tarball_dir }}/bin/rke2-uninstall.sh" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" + dest: /etc/systemd/system/rke2-server.service + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups['rke2_servers'] + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.env" + dest: /etc/systemd/system/rke2-server.env + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups['rke2_servers'] + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" + dest: /etc/systemd/system/rke2-agent.service + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups.get('rke2_agents', []) + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.env" + dest: /etc/systemd/system/rke2-agent.env + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups.get('rke2_agents', []) + + - name: TARBALL | Refreshing systemd unit files + systemd: + daemon-reload: yes + +- name: Remove the temp_dir file: path: "{{ temp_dir.path }}" state: absent - when: temp_dir.path is defined - -- name: TARBALL | Updating tarball contents to reflect install path - block: - - name: TARBALL | Updating rke2-server.service - ansible.builtin.replace: - path: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - - - name: TARBALL | Updating rke2-agent.service - ansible.builtin.replace: - path: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - - - name: TARBALL | Updating rke2-uninstall.sh - ansible.builtin.replace: - path: "{{ tarball_dir }}/bin/rke2-uninstall.sh" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - -- name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" - dest: /etc/systemd/system/rke2-server.service - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups['rke2_servers'] - -- name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.env" - dest: /etc/systemd/system/rke2-server.env - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups['rke2_servers'] - -- name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" - dest: /etc/systemd/system/rke2-agent.service - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups.get('rke2_agents', []) - -- name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.env" - dest: /etc/systemd/system/rke2-agent.env - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups.get('rke2_agents', []) - -- name: TARBALL | Refreshing systemd unit files - systemd: - daemon-reload: yes + when: temp_dir.path is defined \ No newline at end of file diff --git a/roles/rke2_common/vars/main.yml b/roles/rke2_common/vars/main.yml index 78c915ac..b85bb915 100644 --- a/roles/rke2_common/vars/main.yml +++ b/roles/rke2_common/vars/main.yml @@ -3,7 +3,16 @@ channels: - stable - latest - - v1.19 - v1.18 - + - v1.19 + - v1.20 + - v1.21 + - v1.22 + - v1.23 + - v1.24 + - v1.25 + - v1.26 + - v1.27 + - v1.28 installed: false +rke2_version_changed: false \ No newline at end of file From c1da41556cfe3cb8c4598c46156bde74247aae35 Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Fri, 22 Sep 2023 15:21:21 -0400 Subject: [PATCH 3/7] changes for lint --- .ansible-lint | 7 +- roles/rke2_common/defaults/main.yml | 2 +- .../tasks/calculate_rke2_version.yml | 10 +- roles/rke2_common/tasks/main.yml | 6 +- roles/rke2_common/tasks/previous_install.yml | 2 +- roles/rke2_common/tasks/rpm_install.yml | 2 +- roles/rke2_common/tasks/tarball_install.yml | 200 +++++++++--------- roles/rke2_common/vars/main.yml | 4 +- roles/rke2_server/tasks/first_server.yml | 2 +- roles/rke2_server/tasks/other_servers.yml | 4 +- roles/testing/tasks/kubectl_basic.yml | 2 +- 11 files changed, 122 insertions(+), 119 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 836ced00..8d4982ed 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,10 +1,11 @@ exclude_paths: -- .github/ -- molecule/ -- .ansible-lint + - .github/ + - molecule/ + - .ansible-lint warn_list: - no-handler - var-spacing + - var-naming skip_list: - experimental - fqcn-builtins \ No newline at end of file diff --git a/roles/rke2_common/defaults/main.yml b/roles/rke2_common/defaults/main.yml index e7a261bc..71eca998 100644 --- a/roles/rke2_common/defaults/main.yml +++ b/roles/rke2_common/defaults/main.yml @@ -13,7 +13,7 @@ rke2_common_yum_repo: enabled: yes rke2_versioned_yum_repo: - name: "rke2-v{{ rke2_version_majmin }}" # noqa var-spacing + name: "rke2-v{{ rke2_version_majmin }}" # noqa jinja[spacing] description: "Rancher RKE2 Version" baseurl: "https://rpm.rancher.io/rke2/latest/{{ rke2_version_majmin }}/centos/$releasever/$basearch" gpgcheck: true diff --git a/roles/rke2_common/tasks/calculate_rke2_version.yml b/roles/rke2_common/tasks/calculate_rke2_version.yml index 4b8720bb..3dd963f4 100644 --- a/roles/rke2_common/tasks/calculate_rke2_version.yml +++ b/roles/rke2_common/tasks/calculate_rke2_version.yml @@ -1,5 +1,7 @@ -- name: "Calculate rke2 full version " - when: ( install_rke2_version is not defined ) or ( install_rke2_version | length == 0 ) # noqa var-spacing +--- + +- name: "Calculate rke2 full version" + when: ( install_rke2_version is not defined ) or ( install_rke2_version | length == 0 ) block: - name: Stop if the provided is not valid fail: @@ -19,7 +21,7 @@ args: executable: /usr/bin/bash -- name: Set rke2_full_version fact # noqa var-spacing +- name: Set rke2_full_version fact set_fact: rke2_full_version: "{{ rke2_full_version.stdout if ((install_rke2_version is not defined) or (install_rke2_version|length == 0)) else install_rke2_version }}" # yamllint disable-line rule:line-length @@ -63,4 +65,4 @@ - "Full version, with revision indication: {{ rke2_full_version }}" - "Version without revision indication: {{ rke2_version_dot }}" - "Major and Minor Only: {{ rke2_version_majmin }}" - - "RPM Version (tilde): {{ rke2_version_rpm }}" \ No newline at end of file + - "RPM Version (tilde): {{ rke2_version_rpm }}" diff --git a/roles/rke2_common/tasks/main.yml b/roles/rke2_common/tasks/main.yml index 3a8a3b70..c812d9da 100644 --- a/roles/rke2_common/tasks/main.yml +++ b/roles/rke2_common/tasks/main.yml @@ -13,17 +13,17 @@ - name: Include images_tarball_install.yml include_tasks: images_tarball_install.yml -- name: "Check for binary tarball in {{ playbook_dir }}/tarball_install/rke2.linux-amd64.tar.gz" # noqa name[template] +- name: "Check for binary tarball in tarball_install/rke2.linux-amd64.tar.gz" stat: path: "{{ playbook_dir }}/tarball_install/rke2.linux-amd64.tar.gz" register: rke2_binary_tarball_check delegate_to: 127.0.0.1 - become: False + become: false - name: Include calculate_rke2_version.yml include_tasks: calculate_rke2_version.yml when: not rke2_binary_tarball_check.stat.exists - + - name: SLES/Ubuntu/Tarball Installation include_tasks: tarball_install.yml when: diff --git a/roles/rke2_common/tasks/previous_install.yml b/roles/rke2_common/tasks/previous_install.yml index e142d536..60f6cabb 100644 --- a/roles/rke2_common/tasks/previous_install.yml +++ b/roles/rke2_common/tasks/previous_install.yml @@ -44,4 +44,4 @@ - name: Determine if current version differs what what is being installed set_fact: installed_rke2_version: "{{installed_rke2_version_tmp.stdout}}" - when: rke2_binary.stat.exists \ No newline at end of file + when: rke2_binary.stat.exists diff --git a/roles/rke2_common/tasks/rpm_install.yml b/roles/rke2_common/tasks/rpm_install.yml index 5af5056b..8e800036 100644 --- a/roles/rke2_common/tasks/rpm_install.yml +++ b/roles/rke2_common/tasks/rpm_install.yml @@ -30,7 +30,7 @@ # Does the Rancher RKE2 versioned repo exist already - name: Check to see if rke2 versioned repo exists stat: - path: '/etc/yum.repos.d/rke2-v{{ rke2_version_majmin }}.repo' # noqa var-spacing + path: '/etc/yum.repos.d/rke2-v{{ rke2_version_majmin }}.repo' register: stat_rke2_versioned_repo # Add RKE2 versioned repo if it doesn't exist diff --git a/roles/rke2_common/tasks/tarball_install.yml b/roles/rke2_common/tasks/tarball_install.yml index b21e318f..0d37c65e 100644 --- a/roles/rke2_common/tasks/tarball_install.yml +++ b/roles/rke2_common/tasks/tarball_install.yml @@ -28,50 +28,50 @@ set_fact: rke2_version_changed: true when: - - not rke2_binary_tarball_check.stat.exists - - not installed or installed_rke2_version != rke2_full_version + - not rke2_binary_tarball_check.stat.exists + - not installed or installed_rke2_version != rke2_full_version - name: TARBALL | Download the tarball get_url: url: https://github.com/rancher/rke2/releases/download/{{ rke2_full_version }}/rke2.linux-amd64.tar.gz dest: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" mode: "0644" - when: - - not rke2_binary_tarball_check.stat.exists - - rke2_version_changed + when: + - not rke2_binary_tarball_check.stat.exists + - rke2_version_changed - name: TARBALL | Install tar package package: name: tar state: present - ignore_errors: true + ignore_errors: true # noqa ignore-errors - name: Get version of provided tarball when: - rke2_binary_tarball_check.stat.exists block: - - name: Unarchive tarball into temp location - ansible.builtin.unarchive: - src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" - dest: "{{ temp_dir.path }}" - remote_src: True - - - name: Get tarball RKE2 version from temp location - shell: set -o pipefail && {{ temp_dir.path }}/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 - register: tarball_rke2_version_tmp - changed_when: false - args: - executable: /usr/bin/bash - - - name: Set tarball RKE2 version var - set_fact: - tarball_rke2_version: "{{tarball_rke2_version_tmp.stdout}}" - - - name: Determine if current version differs what what is being installed - set_fact: - rke2_version_changed: true - when: - - not installed or installed_rke2_version != tarball_rke2_version + - name: Unarchive tarball into temp location + ansible.builtin.unarchive: + src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" + dest: "{{ temp_dir.path }}" + remote_src: true + + - name: Get tarball RKE2 version from temp location + shell: set -o pipefail && {{ temp_dir.path }}/bin/rke2 -v | head -n 1 | cut -d ' ' -f 3 + register: tarball_rke2_version_tmp + changed_when: false + args: + executable: /usr/bin/bash + + - name: Set tarball RKE2 version var + set_fact: + tarball_rke2_version: "{{tarball_rke2_version_tmp.stdout}}" + + - name: Determine if current version differs what what is being installed + set_fact: + rke2_version_changed: true + when: + - not installed or installed_rke2_version != tarball_rke2_version - name: TARBALL | Check Target Mountpoint command: mountpoint -q {{ tarball_dir }} @@ -101,80 +101,80 @@ - rke2_version_changed block: - - name: Unarchive rke2 tar - ansible.builtin.unarchive: - src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" - dest: "{{ tarball_dir }}" - remote_src: True - - - name: TARBALL | Updating rke2-server.service - ansible.builtin.replace: - path: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - - - name: TARBALL | Updating rke2-agent.service - ansible.builtin.replace: - path: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - - - name: TARBALL | Updating rke2-uninstall.sh - ansible.builtin.replace: - path: "{{ tarball_dir }}/bin/rke2-uninstall.sh" - regexp: '/usr/local' - replace: '{{ tarball_dir }}' - - - name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" - dest: /etc/systemd/system/rke2-server.service - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups['rke2_servers'] - - - name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.env" - dest: /etc/systemd/system/rke2-server.env - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups['rke2_servers'] - - - name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" - dest: /etc/systemd/system/rke2-agent.service - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups.get('rke2_agents', []) - - - name: TARBALL | Moving Systemd units to /etc/systemd/system - copy: - src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.env" - dest: /etc/systemd/system/rke2-agent.env - mode: '0644' - owner: root - group: root - remote_src: yes - when: - - inventory_hostname in groups.get('rke2_agents', []) - - - name: TARBALL | Refreshing systemd unit files - systemd: - daemon-reload: yes + - name: Unarchive rke2 tar + ansible.builtin.unarchive: + src: "{{ temp_dir.path }}/rke2.linux-amd64.tar.gz" + dest: "{{ tarball_dir }}" + remote_src: true + + - name: TARBALL | Updating rke2-server.service + ansible.builtin.replace: + path: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Updating rke2-agent.service + ansible.builtin.replace: + path: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Updating rke2-uninstall.sh + ansible.builtin.replace: + path: "{{ tarball_dir }}/bin/rke2-uninstall.sh" + regexp: '/usr/local' + replace: '{{ tarball_dir }}' + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.service" + dest: /etc/systemd/system/rke2-server.service + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups['rke2_servers'] + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-server.env" + dest: /etc/systemd/system/rke2-server.env + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups['rke2_servers'] + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.service" + dest: /etc/systemd/system/rke2-agent.service + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups.get('rke2_agents', []) + + - name: TARBALL | Moving Systemd units to /etc/systemd/system + copy: + src: "{{ tarball_dir }}/lib/systemd/system/rke2-agent.env" + dest: /etc/systemd/system/rke2-agent.env + mode: '0644' + owner: root + group: root + remote_src: yes + when: + - inventory_hostname in groups.get('rke2_agents', []) + + - name: TARBALL | Refreshing systemd unit files + systemd: + daemon-reload: yes - name: Remove the temp_dir file: path: "{{ temp_dir.path }}" state: absent - when: temp_dir.path is defined \ No newline at end of file + when: temp_dir.path is defined diff --git a/roles/rke2_common/vars/main.yml b/roles/rke2_common/vars/main.yml index b85bb915..da8e48d7 100644 --- a/roles/rke2_common/vars/main.yml +++ b/roles/rke2_common/vars/main.yml @@ -13,6 +13,6 @@ channels: - v1.25 - v1.26 - v1.27 - - v1.28 + - v1.28 installed: false -rke2_version_changed: false \ No newline at end of file +rke2_version_changed: false diff --git a/roles/rke2_server/tasks/first_server.yml b/roles/rke2_server/tasks/first_server.yml index 2eb61ef4..fceab35b 100644 --- a/roles/rke2_server/tasks/first_server.yml +++ b/roles/rke2_server/tasks/first_server.yml @@ -30,7 +30,7 @@ delay: 10 changed_when: false -- name: Extract the hostname-override parameter from the kubelet process # noqa var-spacing +- name: Extract the hostname-override parameter from the kubelet process set_fact: kubelet_hostname_override_parameter: "{{ kubelet_check.stdout |\ regex_search('\\s--hostname-override=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))\\s',\ diff --git a/roles/rke2_server/tasks/other_servers.yml b/roles/rke2_server/tasks/other_servers.yml index 8c0b636f..87b48db7 100644 --- a/roles/rke2_server/tasks/other_servers.yml +++ b/roles/rke2_server/tasks/other_servers.yml @@ -30,7 +30,7 @@ when: - '"server:" not in server_url_check.stdout' -- name: Start and wait for healthy node # noqa var-spacing +- name: Start and wait for healthy node throttle: 1 block: - name: Start rke2-server @@ -55,7 +55,7 @@ delay: 10 changed_when: false - - name: Extract the hostname-override parameter from the kubelet process # noqa var-spacing + - name: Extract the hostname-override parameter from the kubelet process set_fact: kubelet_hostname_override_parameter: "{{ kubelet_check.stdout |\ regex_search('\\s--hostname-override=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))\\s',\ diff --git a/roles/testing/tasks/kubectl_basic.yml b/roles/testing/tasks/kubectl_basic.yml index f1c4bed9..bc8626f3 100644 --- a/roles/testing/tasks/kubectl_basic.yml +++ b/roles/testing/tasks/kubectl_basic.yml @@ -10,7 +10,7 @@ delay: 10 changed_when: false -- name: Extract the hostname-override parameter from the kubelet process # noqa var-spacing +- name: Extract the hostname-override parameter from the kubelet process # noqa jinja[spacing] set_fact: kubelet_hostname_override_parameter: "{{ kubelet_check.stdout |\ regex_search('\\s--hostname-override=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))\\s',\ From b9c8f3dc2b59e09ff931e0e74d149e7d77fe6c7a Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Fri, 22 Sep 2023 17:51:42 -0400 Subject: [PATCH 4/7] remove lsb core dependency and stop following redirects for calculating versions --- .../tasks/calculate_rke2_version.yml | 4 +-- roles/rke2_common/tasks/main.yml | 15 +------- roles/rke2_common/tasks/rpm_install.yml | 35 +++++++------------ 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/roles/rke2_common/tasks/calculate_rke2_version.yml b/roles/rke2_common/tasks/calculate_rke2_version.yml index 3dd963f4..0cc4e97d 100644 --- a/roles/rke2_common/tasks/calculate_rke2_version.yml +++ b/roles/rke2_common/tasks/calculate_rke2_version.yml @@ -11,7 +11,8 @@ - name: Get full version name url uri: url: https://update.rke2.io/v1-release/channels/{{ rke2_channel }} - follow_redirects: all + follow_redirects: safe + remote_src: true register: rke2_version_url - name: Set full version name @@ -58,7 +59,6 @@ set_fact: rke2_version_rpm: "{{ rke2_version_rpm_tmp.stdout }}" - - name: Describe versions debug: msg: diff --git a/roles/rke2_common/tasks/main.yml b/roles/rke2_common/tasks/main.yml index c812d9da..f9cc6d82 100644 --- a/roles/rke2_common/tasks/main.yml +++ b/roles/rke2_common/tasks/main.yml @@ -36,20 +36,7 @@ when: - ansible_os_family == 'RedHat' or ansible_os_family == 'Rocky' - not rke2_binary_tarball_check.stat.exists - block: - - name: Install redhat-lsb-core - when: "'redhat-lsb-core' not in ansible_facts.packages" - yum: - name: redhat-lsb-core - state: present - - - name: Reread ansible_lsb facts - when: "'redhat-lsb-core' not in ansible_facts.packages" - setup: - filter: ansible_lsb* - - - name: Include task file rpm_install.yml - include_tasks: rpm_install.yml + include_tasks: rpm_install.yml # Disable Firewalld # We recommend disabling firewalld. For Kubernetes 1.19+, firewalld must be turned off. diff --git a/roles/rke2_common/tasks/rpm_install.yml b/roles/rke2_common/tasks/rpm_install.yml index 8e800036..f2a20cff 100644 --- a/roles/rke2_common/tasks/rpm_install.yml +++ b/roles/rke2_common/tasks/rpm_install.yml @@ -7,7 +7,7 @@ register: stat_rke2_common_repo # Add RKE2 Common repo if it doesn't exist -- name: Add the rke2-common repo RHEL/CentOS 7 +- name: Add the rke2-common repo RHEL/CentOS/Rocky yum_repository: name: "{{ rke2_common_yum_repo.name }}" description: "{{ rke2_common_yum_repo.description }}" @@ -15,17 +15,10 @@ gpgcheck: "{{ rke2_common_yum_repo.gpgcheck }}" gpgkey: "{{ rke2_common_yum_repo.gpgkey }}" enabled: "{{ rke2_common_yum_repo.enabled }}" - when: not stat_rke2_common_repo.stat.exists and ansible_lsb.major_release == '7' - -- name: Add the rke2-common repo RHEL/CentOS 8 - yum_repository: - name: "{{ rke2_common_yum_repo.name }}" - description: "{{ rke2_common_yum_repo.description }}" - baseurl: "{{ rke2_common_yum_repo.baseurl }}" - gpgcheck: "{{ rke2_common_yum_repo.gpgcheck }}" - gpgkey: "{{ rke2_common_yum_repo.gpgkey }}" - enabled: "{{ rke2_common_yum_repo.enabled }}" - when: not stat_rke2_common_repo.stat.exists and ansible_lsb.major_release == '8' + when: + - not stat_rke2_common_repo.stat.exists + - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" + - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" # Does the Rancher RKE2 versioned repo exist already - name: Check to see if rke2 versioned repo exists @@ -34,7 +27,7 @@ register: stat_rke2_versioned_repo # Add RKE2 versioned repo if it doesn't exist -- name: Add the rke2 versioned repo CentOS/RHEL 7 +- name: Add the rke2 versioned repo CentOS/RHEL/Rocky yum_repository: name: "{{ rke2_versioned_yum_repo.name }}" description: "{{ rke2_versioned_yum_repo.description }}" @@ -42,17 +35,13 @@ gpgcheck: "{{ rke2_versioned_yum_repo.gpgcheck }}" gpgkey: "{{ rke2_versioned_yum_repo.gpgkey }}" enabled: "{{ rke2_versioned_yum_repo.enabled }}" - when: not stat_rke2_versioned_repo.stat.exists and ansible_lsb.major_release == '7' + when: + - not stat_rke2_common_repo.stat.exists + - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" + - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" + + -- name: Add the rke2 versioned repo CentOS/RHEL 8 - yum_repository: - name: "{{ rke2_versioned_yum_repo.name }}" - description: "{{ rke2_versioned_yum_repo.description }}" - baseurl: "{{ rke2_versioned_yum_repo.baseurl }}" - gpgcheck: "{{ rke2_versioned_yum_repo.gpgcheck }}" - gpgkey: "{{ rke2_versioned_yum_repo.gpgkey }}" - enabled: "{{ rke2_versioned_yum_repo.enabled }}" - when: not stat_rke2_versioned_repo.stat.exists and ansible_lsb.major_release == '8' - name: YUM-Based | Install rke2-server yum: From 92162e6a0e61dff19cd4380c88579c4ea279d51b Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Fri, 22 Sep 2023 17:53:58 -0400 Subject: [PATCH 5/7] more lint changes --- roles/rke2_common/tasks/rpm_install.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/roles/rke2_common/tasks/rpm_install.yml b/roles/rke2_common/tasks/rpm_install.yml index f2a20cff..e978834b 100644 --- a/roles/rke2_common/tasks/rpm_install.yml +++ b/roles/rke2_common/tasks/rpm_install.yml @@ -15,7 +15,7 @@ gpgcheck: "{{ rke2_common_yum_repo.gpgcheck }}" gpgkey: "{{ rke2_common_yum_repo.gpgkey }}" enabled: "{{ rke2_common_yum_repo.enabled }}" - when: + when: - not stat_rke2_common_repo.stat.exists - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" @@ -40,9 +40,6 @@ - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" - - - - name: YUM-Based | Install rke2-server yum: name: "rke2-server-{{ rke2_version_rpm }}" From 854fdb34390e851e62c48db256a8ce5ac1df34ac Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Thu, 28 Sep 2023 12:39:41 -0400 Subject: [PATCH 6/7] fix testing AMI to be rocky 8 --- .github/workflows/{centos7.yml => rocky8.yml} | 34 +++++++++---------- testing/variables.tf | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) rename .github/workflows/{centos7.yml => rocky8.yml} (84%) diff --git a/.github/workflows/centos7.yml b/.github/workflows/rocky8.yml similarity index 84% rename from .github/workflows/centos7.yml rename to .github/workflows/rocky8.yml index e5ad682a..6fa58f82 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/rocky8.yml @@ -1,5 +1,5 @@ --- -name: CentOS 7 +name: Rocky 8 on: pull_request: @@ -40,7 +40,7 @@ jobs: - name: Run ansible-lint. run: ansible-lint - centos7-test: + rocky8-test: name: Initial build test runs-on: ubuntu-latest needs: ['lint-test'] @@ -75,7 +75,7 @@ jobs: id: plan run: | cd testing/ - terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=centos7" -no-color + terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=rocky8" -no-color continue-on-error: true - name: Terraform Plan Status @@ -85,7 +85,7 @@ jobs: - name: Terraform Apply run: | cd testing/ - terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=centos7" -auto-approve + terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=rocky8" -auto-approve - name: Set up Python id: setup_python @@ -122,26 +122,26 @@ jobs: - name: Prep inventory run: | - cp -R inventory/sample inventory/centos7 - cp hosts.ini inventory/centos7/hosts.ini + cp -R inventory/sample inventory/rocky8 + cp hosts.ini inventory/rocky8/hosts.ini - name: Run playbook run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos -vv --private-key .key site.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vv --private-key .key site.yml - name: Run playbook again for idempotency run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos -vv --private-key .key site.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vv --private-key .key site.yml - name: Run Ansible Tests run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml - name: Run Python Tests run: | export DEFAULT_PRIVATE_KEY_FILE=.key - pytest --hosts=rke2_servers --ansible-inventory=inventory/centos7/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py - pytest --hosts=rke2_agents --ansible-inventory=inventory/centos7/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py + pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py + pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py - name: Create new inventory hosts.ini with added hosts run: | @@ -154,26 +154,26 @@ jobs: aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=ExtraNode" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text >> hosts.ini echo "[all:vars]" >> hosts.ini echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini - cp hosts.ini inventory/centos7/hosts.ini + cp hosts.ini inventory/rocky8/hosts.ini - name: Run playbook again with added hosts run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos --verbose --private-key .key site.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --private-key .key site.yml - name: Run Ansible Tests with added hosts run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml - name: Run Python Tests with added hosts run: | export DEFAULT_PRIVATE_KEY_FILE=.key - pytest --hosts=rke2_servers --ansible-inventory=inventory/centos7/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py - pytest --hosts=rke2_agents --ansible-inventory=inventory/centos7/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py + pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py + pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py - name: Run troubleshoot tasks if: ${{ failure() }} run: | - ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/centos7/hosts.ini -u centos -vvv --tags "troubleshooting" --private-key .key testing.yml + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vvv --tags "troubleshooting" --private-key .key testing.yml - name: Delete Stack if: ${{ always() }} diff --git a/testing/variables.tf b/testing/variables.tf index c37dc896..6975af0b 100644 --- a/testing/variables.tf +++ b/testing/variables.tf @@ -74,8 +74,8 @@ variable "amis" { user = "centos" } "rocky8" = { - ami = "ami-06370d1e5ddbf1f76" - user = "ec2-user" + ami = "ami-01c3e8e014e8b0c7a" + user = "centos" } } } From fdbc1c27cfb242d2be3f9b6915d0b7dc87513631 Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Thu, 28 Sep 2023 13:27:42 -0400 Subject: [PATCH 7/7] fix typo in test job [skip ci] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4f97724e..9d9d6528 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ --- -name: CentOS 7 +name: Lint Test on: push: