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.
This commit is contained in:
Pavel Raiskup 2022-01-09 20:46:07 +01:00
parent f133711de5
commit 24a2466b06
2 changed files with 23 additions and 16 deletions

View file

@ -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

View file

@ -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__":