templates/packer: subscribe packer machines
To avoid a mismatch between the RPMs (which are build using CDN content) and the packer instances (RHUI, which might be older).
This commit is contained in:
parent
41d98c85a7
commit
ca8a05bd3a
6 changed files with 56 additions and 1 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# Subscribe
|
||||||
|
- include_tasks: subscribe.yml
|
||||||
|
|
||||||
# Install various software packages.
|
# Install various software packages.
|
||||||
- include_tasks: packages.yml
|
- include_tasks: packages.yml
|
||||||
|
|
||||||
|
|
@ -9,5 +12,8 @@
|
||||||
# Configure the worker.
|
# Configure the worker.
|
||||||
- include_tasks: worker-config.yml
|
- include_tasks: worker-config.yml
|
||||||
|
|
||||||
|
# Unsubscribe
|
||||||
|
- include_tasks: unsubscribe.yml
|
||||||
|
|
||||||
- name: Ensure SELinux contexts are updated
|
- name: Ensure SELinux contexts are updated
|
||||||
command: restorecon -Rv /etc
|
command: restorecon -Rv /etc
|
||||||
|
|
|
||||||
26
templates/packer/ansible/roles/common/tasks/subscribe.yml
Normal file
26
templates/packer/ansible/roles/common/tasks/subscribe.yml
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
# Subscribe the machine to avoid a mismatch between the RPMs (which are build using CDN content) and
|
||||||
|
# the packer instances (RHUI, which might be older).
|
||||||
|
- name: Subscribe
|
||||||
|
tags:
|
||||||
|
- subscribe
|
||||||
|
community.general.redhat_subscription:
|
||||||
|
activationkey: "{{ RH_ACTIVATION_KEY }}"
|
||||||
|
org_id: "{{ RH_ORG_ID }}"
|
||||||
|
|
||||||
|
- name: Enable repo mgmt through subman
|
||||||
|
become: yes
|
||||||
|
tags:
|
||||||
|
- subscribe
|
||||||
|
shell: >-
|
||||||
|
subscription-manager config --rhsm.manage_repos 1
|
||||||
|
|
||||||
|
- name: Enable cdn repos
|
||||||
|
become: yes
|
||||||
|
tags:
|
||||||
|
- subscribe
|
||||||
|
shell: >-
|
||||||
|
subscription-manager repos \
|
||||||
|
--enable rhel-9-for-x86_64-appstream-rpms \
|
||||||
|
--enable rhel-9-for-x86_64-baseos-rpms \
|
||||||
|
--enable codeready-builder-for-rhel-9-x86_64-rpms
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Unsubscribe
|
||||||
|
tags:
|
||||||
|
- subscribe
|
||||||
|
community.general.redhat_subscription:
|
||||||
|
state: absent
|
||||||
|
|
@ -37,3 +37,15 @@ variable "ansible_skip_tags" {
|
||||||
type = string
|
type = string
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Subscription variables
|
||||||
|
|
||||||
|
variable "rh_org_id" {
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "rh_activation_key" {
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,8 @@ EOF
|
||||||
user = build.User
|
user = build.User
|
||||||
extra_arguments = [
|
extra_arguments = [
|
||||||
"-e", "COMPOSER_COMMIT=${var.composer_commit}",
|
"-e", "COMPOSER_COMMIT=${var.composer_commit}",
|
||||||
|
"-e", "RH_ACTIVATION_KEY=${var.rh_activation_key}",
|
||||||
|
"-e", "RH_ORG_ID=${var.rh_org_id}",
|
||||||
"--skip-tags", "${var.ansible_skip_tags}",
|
"--skip-tags", "${var.ansible_skip_tags}",
|
||||||
]
|
]
|
||||||
inventory_directory = "${path.root}/ansible/inventory/${source.name}"
|
inventory_directory = "${path.root}/ansible/inventory/${source.name}"
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ function cleanup {
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
# Use prebuilt rpms on CI
|
# Use prebuilt rpms on CI
|
||||||
SKIP_TAGS="rpmcopy"
|
SKIP_TAGS="rpmcopy,subscribe"
|
||||||
if [ "$ON_JENKINS" = true ]; then
|
if [ "$ON_JENKINS" = true ]; then
|
||||||
# Build RPMs when running on AppSRE's infra
|
# Build RPMs when running on AppSRE's infra
|
||||||
BUILD_RPMS=true
|
BUILD_RPMS=true
|
||||||
|
|
@ -143,5 +143,7 @@ $CONTAINER_RUNTIME run --rm \
|
||||||
-e PKR_VAR_composer_commit="$COMMIT_SHA" \
|
-e PKR_VAR_composer_commit="$COMMIT_SHA" \
|
||||||
-e PKR_VAR_ansible_skip_tags="$SKIP_TAGS" \
|
-e PKR_VAR_ansible_skip_tags="$SKIP_TAGS" \
|
||||||
-e PKR_VAR_skip_create_ami="$SKIP_CREATE_AMI" \
|
-e PKR_VAR_skip_create_ami="$SKIP_CREATE_AMI" \
|
||||||
|
-e PKR_VAR_rh_activation_key="$RH_ACTIVATION_KEY" \
|
||||||
|
-e PKR_VAR_rh_org_id="$RH_ORG_ID" \
|
||||||
-e PYTHONUNBUFFERED=1 \
|
-e PYTHONUNBUFFERED=1 \
|
||||||
"packer:$COMMIT_SHA" /osbuild-composer/tools/appsre-worker-packer-container.sh
|
"packer:$COMMIT_SHA" /osbuild-composer/tools/appsre-worker-packer-container.sh
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue