Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnsimcall/7c0409f39f3ceaf0378be6d3761407d9 to your computer and use it in GitHub Desktop.
Save johnsimcall/7c0409f39f3ceaf0378be6d3761407d9 to your computer and use it in GitHub Desktop.
MachineConfig template that applies Red Hat subscription information
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 50-worker-rhsm-entitlement
spec:
config:
ignition:
version: 3.2.0
storage:
files:
- path: /etc/rhsm/rhsm.conf
mode: 0644
contents:
source: data:text/plain;charset=utf-8;base64,ENCODED_rhsm.conf
- path: /etc/pki/entitlement/entitlement.pem
mode: 0644
contents:
source: data:text/plain;charset=utf-8;base64,ENCODED_entitlement.pem
- path: /etc/pki/entitlement/entitlement-key.pem
mode: 0644
contents:
source: data:text/plain;charset=utf-8;base64,ENCODED_entitlement-key.pem
@johnsimcall
Copy link
Author

These steps assume the executing host has a RHEL8 entitlement applied. The long series of numbers in the .pem files need to be adjusted.

# cp 50-worker-rhsm-entitlement-template.yaml 50-worker-rhsm-entitlement.yaml
# sed -i "s/ENCODED_rhsm.conf/$(base64 -w0 /etc/rhsm/rhsm.conf)/" 50-worker-rhsm-entitlement.yaml
# sed -i "s/ENCODED_entitlement.pem/$(base64 -w0 /etc/pki/entitlement/4864804418326397803.pem)/" 50-worker-rhsm-entitlement.yaml
# sed -i "s/ENCODED_entitlement-key.pem/$(base64 -w0 /etc/pki/entitlement/4864804418326397803-key.pem)/" 50-worker-rhsm-entitlement.yaml
# oc create -f 50-worker-rhsm-entitlement.yaml

@johnsimcall
Copy link
Author

@kincl has improved this by fetching the entitlement content from the secrets created by the Insights Operator when Simple Content Access has been turned on.

@kincl
Copy link

kincl commented Feb 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment