From d9373234daddba322dad9af421039b34d462d6aa Mon Sep 17 00:00:00 2001 From: Bill Anastasiadis Date: Tue, 5 Nov 2024 18:37:40 +0100 Subject: [PATCH] Add support for additional module registration --- ansible/playbooks/registration.yaml | 25 +++++++++++++++++++++++++ docs/playbooks/README.md | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/ansible/playbooks/registration.yaml b/ansible/playbooks/registration.yaml index ae93ae6e..30a3d337 100644 --- a/ansible/playbooks/registration.yaml +++ b/ansible/playbooks/registration.yaml @@ -97,6 +97,31 @@ - not_registered_found - "(rcg.rc != 0) or (use_suseconnect | bool)" + # Latest version of cloud-regionsrv-client is needed in PAYG, and image + # needs to be registered in order for zypper up to work. + # see https://www.suse.com/c/long-term-service-pack-support-for-payg-instances-simplified/ + - name: Ensure cloud-regionsrv-client is on latest version. + community.general.zypper: + name: cloud-regionsrv-client + state: latest + when: + - ansible_facts['distribution_major_version'] == "12" + - not not_registered_found + - sles_modules is defined and sles_modules | length > 0 + + - name: Add additional authenticated modules + ansible.builtin.command: SUSEConnect -p {{ item.key }} -r {{ item.value }} + register: result + until: result is succeeded + retries: 10 + delay: 60 + when: + - not_registered_found + - sles_modules is defined and sles_modules | length > 0 + loop: "{{ sles_modules }}" + loop_control: + label: "{{ item.key }}" + - name: Check if repos are added after registration ansible.builtin.command: zypper lr -u register: repos_after diff --git a/docs/playbooks/README.md b/docs/playbooks/README.md index 8ab9da82..65ea1340 100644 --- a/docs/playbooks/README.md +++ b/docs/playbooks/README.md @@ -33,6 +33,7 @@ Variables: * reg_code * email_address +* sles_modules Variable Source = ./variables.sh @@ -46,6 +47,17 @@ using `registercloudguest`. If the command is available, it will be used for registration. If `registercloudguest` is not available then `SUSEConnect` will be used. + +There's a task allowing register additional modules that require a dedicated regcode. +The module names and regcodes can be provided in the `ansible-playbook` command line as list of hashes (named sles_modules). + +The format should be like this: + +``` +create: + - registration.yaml (.......other variables here......) -e sles_modules='[{"key":"","value":""},{"key":""}]' +``` + ## pre-cluster Target hosts: