From: Kienan Stewart Date: Wed, 31 Jan 2024 15:19:15 +0000 (-0500) Subject: ansible: Register SLES nodes if necessary X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a895f79d2bd441f011775b7afb039bdb33a57fc2;p=lttng-ci.git ansible: Register SLES nodes if necessary Signed-off-by: Kienan Stewart Change-Id: Iae950177ebddf2ecec67f9f719d088051cdaee2f --- diff --git a/automation/ansible/roles/common/tasks/setup-Suse.yml b/automation/ansible/roles/common/tasks/setup-Suse.yml index da745d8..23b681b 100644 --- a/automation/ansible/roles/common/tasks/setup-Suse.yml +++ b/automation/ansible/roles/common/tasks/setup-Suse.yml @@ -1,4 +1,31 @@ --- +- name: Register with SLES + when: ansible_distribution == 'SLES' + block: + - name: Check registration + ansible.builtin.command: + argv: ['SUSEConnect', '--status'] + register: registration_status + ignore_errors: true + - name: Cleanup registration + when: registration_status.rc != 0 + ansible.builtin.command: + argv[ 'SUSEConnect', '--cleanup'] + - ansible.builtin.set_fact: + registration_status_data: "{{registration_status.stdout|ansible.builtin.from_json|first}}" + - name: Get key from host environment + when: registration_status_data['status'] == 'Not Registered' + ansible.builtin.set_fact: + registration_key: "{{lookup('ansible.builtin.env', 'SLES_REGISTRATION_CODE_' + ansible_architecture, default='')}}" + - name: Get key from bitwarden + when: registration_key|default('') == '' and registration_status_data['status'] == 'Not Registered' + ansible.builtin.set_fact: + registration_key: "{{lookup('community.general.bitwarden', 'bec75018-99e8-4064-9cd9-addd011947e5', search='id', field='SLES_REGISTRATION_CODE_' +ansible_architecture)[0]}}" + - name: Perform registration + when: registration_status_data['status'] == 'Not Registered' + ansible.builtin.command: + argv: ['SUSEConnect', '-r', "{{registration_key}}"] + - name: Connect SLES Repo when: ansible_distribution == 'SLES' ansible.builtin.command: