From 24a2466b069a686f4660251cb6ba3ea101a32c01 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sun, 9 Jan 2022 20:46:07 +0100 Subject: [PATCH] copr-builders: other s390x IBM Cloud fixes Don't install subscription-manager when it is already installed. Don't even try to download the DNF metadata for that (at that point, the subscription is not yet activated, and so the attempt to install subscription-manager subjectively slows-down the spawning). Try to subscribe a bit sooner, so we don't wait till the end of the playbook for a potential subscription failure. Run subscription-manager clean to which seems to way-around the katello-* RPM hack. One forgotten ibm-cloud-vm typofix (name vs. opts.name). Define server_hostname to enforce the default rhsm server. --- .../provision/provision_builder_tasks.yml | 37 +++++++++++-------- .../templates/resalloc/ibm-cloud-vm.j2 | 2 +- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/roles/copr/backend/files/provision/provision_builder_tasks.yml b/roles/copr/backend/files/provision/provision_builder_tasks.yml index 15108de827..4c17d87648 100644 --- a/roles/copr/backend/files/provision/provision_builder_tasks.yml +++ b/roles/copr/backend/files/provision/provision_builder_tasks.yml @@ -1,7 +1,7 @@ --- - name: remove the hackish package breaking s390x subscriptions shell: - cmd: rpm -evh `rpm -qa | grep katello-` + cmd: rpm -evh `rpm -qa | grep katello-` ; subscription-manager clean when: - prepare_base_image is not defined - "'s390x' in lookup('env', 'RESALLOC_NAME')" @@ -81,6 +81,27 @@ - name: install subscription-manager package: name=subscription-manager state=present + # TODO: we should use 'when: prepare_base_image is defined' instead, but a new + # set of builder images needs to be generated first so the image contains the + # subscription-manager by default. + when: "'subscription-manager' not in ansible_facts.packages" + +- name: Activate Red Hat Subscription + community.general.redhat_subscription: + state: present + username: copr-team + force_register: true + password: "{{ copr_red_hat_subscription_password }}" + consumer_name: "{{ lookup('env', 'RESALLOC_NAME') | default('unknown-builder') }}" + server_hostname: subscription.rhsm.redhat.com + pool_ids: + - "8a85f9a17c71102f017ce611251c770f" + when: + - prepare_base_image is not defined + - copr_red_hat_subscription_password is defined + - devel + tags: + - red_hat_subscription - name: install copr-builder and other latest packages dnf: state=latest pkg={{ packages }} @@ -228,17 +249,3 @@ mode: 0644 when: - prepare_base_image is not defined - -- name: Activate Red Hat Subscription - community.general.redhat_subscription: - state: present - username: copr-team - force_register: true - password: "{{ copr_red_hat_subscription_password }}" - consumer_name: "{{ lookup('env', 'RESALLOC_NAME') | default('unknown-builder') }}" - pool_ids: - - "{% if 's390x' in lookup('env', 'RESALLOC_NAME') %}2c96015276f1cf9d0176f248febd1241{% else %}8a85f9a17c71102f017ce611251c770f{% endif %}" - when: - - prepare_base_image is not defined - - copr_red_hat_subscription_password is defined - - devel diff --git a/roles/copr/backend/templates/resalloc/ibm-cloud-vm.j2 b/roles/copr/backend/templates/resalloc/ibm-cloud-vm.j2 index 3d0e5372fa..4bff29be8a 100755 --- a/roles/copr/backend/templates/resalloc/ibm-cloud-vm.j2 +++ b/roles/copr/backend/templates/resalloc/ibm-cloud-vm.j2 @@ -241,7 +241,7 @@ def _main(): detect_floating_ip_name(opts) create_instance(service, name, opts, log) elif opts.subparser == "delete": - delete_instance(service, opts.name, log) + delete_instance(service, name, log) if __name__ == "__main__":