Skip to content

Instantly share code, notes, and snippets.

@omaciel
Last active January 19, 2023 15:42
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save omaciel/42b67894e080664d1746 to your computer and use it in GitHub Desktop.
Save omaciel/42b67894e080664d1746 to your computer and use it in GitHub Desktop.
Create Host Collection and Activation Keys, associating them as well as adding all available subscriptions to the Activation Key for a scenario where you have enabled and synchronized RHEL 5/6/7 i386, x86_64, ppc64 and s390x repositories.

Instructions

Please update 01-credentials.sh to include your credentials, and run these scripts in the order shown below:

  • 01-credentials.sh
  • 02-os-versions.sh
  • 03-initial-configuration.sh
  • 04-enable-content.sh
  • 05-content-views.sh
  • 06-activation-keys.sh
  • 07-provisioning.sh
  • 08-sync-plan.sh
  • 09-docker.sh
  • 10-puppet.sh
  • 11-hosts.sh
export ADMIN_USER="admin"
export ADMIN_PASSWORD="changeme"
export ORG='Default Organization'
export LOCATION='Default Location'
export RHN_USERNAME=''
export RHN_PASSWORD=''
export DISTRIBUTOR=''
export RHEL5='5.11'
export RHEL6='6.7'
export RHEL7='7.2'
export LOCATION_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv location list | grep 'Default Location' | cut -d ',' -f 1 | grep -vi 'id')
echo LOCATION ID: $LOCATION_ID
export CAPSULE_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv capsule list | cut -d ',' -f 1 | grep -vi 'id')
echo CAPSULE ID: $CAPSULE_ID
export DOMAIN_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv domain list | cut -d ',' -f 1 | grep -vi ID)
echo DOMAIN ID: $DOMAIN_ID
# Create an 'external' (local) Docker-based compute resource
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" compute-resource create --name='external_docker' --description='"External" Docker compute resource' --locations="${LOCATION}" --organizations="${ORG}" --provider='Docker' --url='http://localhost:2375'
# Create a (local) Docker-based compute resource
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" compute-resource create --name='local_docker' --description='Local Docker compute resource' --locations="${LOCATION}" --organizations="${ORG}" --provider='Docker' --url='unix:///var/run/docker.sock'
# Create a (local) Libvirt-based compute resource
## Manually update the compute profile, if desired
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" compute-resource create --name='local_libvirt' --description='Local Libvirt compute resource' --locations="${LOCATION}" --organizations="${ORG}" --provider='Libvirt' --set-console-password=yes --url='qemu+tcp://localhost:16509/system'
# Add organization, capsule and domain to default location
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" location add-organization --name="${LOCATION}" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" location add-domain --name="${LOCATION}" --domain-id=${DOMAIN_ID}
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" location add-smart-proxy --name="${LOCATION}" --smart-proxy-id="${CAPSULE_ID}"
# Add capsule and domain to default organization
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" organization add-domain --name="${ORG}" --domain-id=${DOMAIN_ID}
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" organization add-smart-proxy --name="${ORG}" --smart-proxy-id="${CAPSULE_ID}"
# Create a new subnet
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" subnet create --name='libvirt_subnet' --domain-ids="${DOMAIN_ID}" --dns-id="${CAPSULE_ID}" --dhcp-id="${CAPSULE_ID}" --tftp-id="${CAPSULE_ID}" --network='192.168.100.0' --mask='255.255.255.0' --locations="${LOCATION}" --organizations="${ORG}"
# Update the default domain to use the default capsule for DNS
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" domain update --id="${DOMAIN_ID}" --dns-id="${CAPSULE_ID}"
# Download manifest
curl -o /tmp/manifest.zip -u "${RHN_USERNAME}":"${RHN_PASSWORD}" -X GET "https://subscription.rhn.redhat.com/subscription/consumers/${DISTRIBUTOR}/export" --insecure --fail
# Import it into "Default Organization"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" subscription upload --organization "${ORG}" --file /tmp/manifest.zip
# Create two new lifecycle environments
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" lifecycle-environment create --name='DEV' --prior='Library' --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" lifecycle-environment create --name='QE' --prior='DEV' --organization="${ORG}"
# Enable Red Hat repositories (RPMs)
## Red Hat Enterprise Linux Server - x86_64
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Server (Kickstart)" --basearch="x86_64" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Server (RPMs)" --basearch="x86_64" --releasever="5Server" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Server (Kickstart)" --basearch="x86_64" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Server (RPMs)" --basearch="x86_64" --releasever="6Server" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Server (Kickstart)" --basearch="x86_64" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Server (RPMs)" --basearch="x86_64" --releasever="7Server" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
## Red Hat Enterprise Linux Server - i386
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Server (Kickstart)" --basearch="i386" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Server (RPMs)" --basearch="i386" --releasever="5Server" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Server) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Server (Kickstart)" --basearch="i386" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Server (RPMs)" --basearch="i386" --releasever="6Server" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Server) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Server" --organization "${ORG}"
## Red Hat Enterprise Linux for Power big endian (ppc64be)
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 for IBM Power (RPMs)" --basearch="ppc" --releasever="5Server" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 for IBM Power) (RPMs)" --basearch="ppc" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 for IBM Power (RPMs)" --basearch="ppc64" --releasever="6Server" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 for IBM Power) (RPMs)" --basearch="ppc64" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 for IBM Power (RPMs)" --basearch="ppc64" --releasever="7Server" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 for IBM Power) (RPMs)" --basearch="ppc64" --product "Red Hat Enterprise Linux for Power big endian" --organization "${ORG}"
## Red Hat Enterprise Linux for Power little endian (ppc64le)
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 for IBM Power LE (RPMs)" --basearch="ppc64le" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux for Power little endian" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 for IBM Power LE) (RPMs)" --basearch="ppc64le" --product "Red Hat Enterprise Linux for Power little endian" --organization "${ORG}"
## Red Hat Enterprise Linux for IBM z Systems (s390x)
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 for System Z (RPMs)" --basearch="s390x" --releasever="5Server" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 for System Z) (RPMs)" --basearch="s390x" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 for System Z (RPMs)" --basearch="s390x" --releasever="6Server" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 for System Z) (RPMs)" --basearch="s390x" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 for System Z (RPMs)" --basearch="s390x" --releasever="7Server" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 for System Z) (RPMs)" --basearch="s390x" --product "Red Hat Enterprise Linux for IBM z Systems" --organization "${ORG}"
## Red Hat Enterprise Linux Desktop - i386
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Desktop (Kickstart)" --basearch="i386" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Desktop (RPMs)" --basearch="i386" --releasever="5Client" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Desktop) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Desktop (Kickstart)" --basearch="i386" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Desktop (RPMs)" --basearch="i386" --releasever="6Client" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Desktop) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
## Red Hat Enterprise Linux Desktop - x86_64
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Desktop (Kickstart)" --basearch="x86_64" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Desktop (RPMs)" --basearch="x86_64" --releasever="5Client" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Desktop) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Desktop (Kickstart)" --basearch="x86_64" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Desktop (RPMs)" --basearch="x86_64" --releasever="6Client" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Desktop) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Desktop (Kickstart)" --basearch="x86_64" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Desktop (RPMs)" --basearch="x86_64" --releasever="7Client" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 Desktop) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Desktop" --organization "${ORG}"
## Red Hat Enterprise Linux for Scientific Computing
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 for Scientific Computing (Kickstart)" --basearch="x86_64" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 for Scientific Computing (RPMs)" --basearch="x86_64" --releasever="6ComputeNode" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 for Scientific Computing) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 for Scientific Computing (Kickstart)" --basearch="x86_64" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 for Scientific Computing (RPMs)" --basearch="x86_64" --releasever="7ComputeNode" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 for Scientific Computing) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux for Scientific Computing" --organization "${ORG}"
## Red Hat Enterprise Linux Workstation - i386
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Workstation (Kickstart)" --basearch="i386" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Workstation (RPMs)" --basearch="i386" --releasever="5Client" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Workstation) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Workstation (Kickstart)" --basearch="i386" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Workstation (RPMs)" --basearch="i386" --releasever="6Workstation" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Workstation) (RPMs)" --basearch="i386" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
## Red Hat Enterprise Linux Workstation - x86_64
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Workstation (Kickstart)" --basearch="x86_64" --releasever="${RHEL5}" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 5 Workstation (RPMs)" --basearch="x86_64" --releasever="5Client" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 5 Workstation) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Workstation (Kickstart)" --basearch="x86_64" --releasever="${RHEL6}" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 6 Workstation (RPMs)" --basearch="x86_64" --releasever="6Workstation" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 6 Workstation) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Workstation (Kickstart)" --basearch="x86_64" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Workstation (RPMs)" --basearch="x86_64" --releasever="7Workstation" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 Workstation) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Workstation" --organization "${ORG}"
# aarch64
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Enterprise Linux 7 Server for ARM (RPMs)" --basearch="aarch64" --releasever="${RHEL7}" --product "Red Hat Enterprise Linux Server for ARM" --organization "${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository-set enable --name="Red Hat Satellite Tools 6.1 (for RHEL 7 Server for ARM) (RPMs)" --basearch="aarch64" --product "Red Hat Enterprise Linux Server for ARM" --organization "${ORG}"
# Synchronize everything
## THIS an ASYNC call, so you will have to wait until all content is synchronized
for org in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv repository list --organization="${ORG}" --per-page=1000 | cut -d ',' -f 1 | grep -vi '^ID'); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository synchronize --id ${org} --organization="${ORG}" --async; done
# Create content views
# Server
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-server-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-server-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-server-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-server-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-server-x86_64-cv" --organization="${ORG}"
# ppc64be
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-ppc64be-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-ppc64be-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-ppc64be-cv" --organization="${ORG}"
# ppc64le
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-ppc64le-cv" --organization="${ORG}"
# System Z
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-systemz-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-systemz-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-systemz-cv" --organization="${ORG}"
# Desktop
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-desktop-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-desktop-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-desktop-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-desktop-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-desktop-x86_64-cv" --organization="${ORG}"
# Workstation
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-workstation-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-5-workstation-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-workstation-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-workstation-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-workstation-x86_64-cv" --organization="${ORG}"
# Scientific Computing
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-6-scientific-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="rhel-7-scientific-x86_64-cv" --organization="${ORG}"
# ...and add repos to them and publish
# Server
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 5 Server Kickstart i386 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 5 Server RPMs i386 5Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Server RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-server-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 5 Server Kickstart x86_64 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 5 Server RPMs x86_64 5Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Server RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-server-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 6 Server Kickstart i386 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 6 Server RPMs i386 6Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Server RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-server-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 6 Server Kickstart x86_64 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Server RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-server-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 7 Server Kickstart x86_64 ${RHEL7}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-server-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Server" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 Server RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-server-x86_64-cv" --organization="${ORG}"
# ppc64be
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Enterprise Linux 5 for IBM Power RPMs ppc 5Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 for IBM Power RPMs ppc"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-ppc64be-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Enterprise Linux 6 for IBM Power RPMs ppc64 6Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 for IBM Power RPMs ppc64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-ppc64be-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Enterprise Linux 7 for IBM Power RPMs ppc64 7Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-ppc64be-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power big endian" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 for IBM Power RPMs ppc64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-ppc64be-cv" --organization="${ORG}"
# ppc64le
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-ppc64le-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power little endian" --repository="Red Hat Enterprise Linux 7 for IBM Power LE RPMs ppc64le 7Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-ppc64le-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Power little endian" --repository="Red Hat Satellite Tools 6.1 (for RHEL 7 for IBM Power LE) (RPMs)"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-ppc64le-cv" --organization="${ORG}"
# System Z
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Enterprise Linux 5 for System Z RPMs s390x 5Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 for System Z RPMs s390x"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-systemz-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Enterprise Linux 6 for System Z RPMs s390x 6Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 for System Z RPMs s390x"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-systemz-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Enterprise Linux 7 for System Z RPMs s390x 7Server"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-systemz-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for IBM z Systems" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 for System Z RPMs s390x"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-systemz-cv" --organization="${ORG}"
# Desktop
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 5 Desktop Kickstart i386 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 5 Desktop RPMs i386 5Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Desktop RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-desktop-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 5 Desktop Kickstart x86_64 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 5 Desktop RPMs x86_64 5Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Desktop RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-desktop-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 6 Desktop Kickstart i386 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 6 Desktop RPMs i386 6Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Desktop RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-desktop-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 6 Desktop Kickstart x86_64 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 6 Desktop RPMs x86_64 6Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Desktop RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-desktop-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 7 Desktop Kickstart x86_64 ${RHEL7}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Enterprise Linux 7 Desktop RPMs x86_64 7Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-desktop-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Desktop" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 Desktop RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-desktop-x86_64-cv" --organization="${ORG}"
# Workstation
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 5 Workstation Kickstart i386 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 5 Workstation RPMs i386 5Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Workstation RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-workstation-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 5 Workstation Kickstart x86_64 ${RHEL5}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 5 Workstation RPMs x86_64 5Client"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-5-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Satellite Tools 6.1 for RHEL 5 Workstation RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-5-workstation-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 6 Workstation Kickstart i386 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 6 Workstation RPMs i386 6Workstation"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-i386-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Workstation RPMs i386"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-workstation-i386-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 6 Workstation Kickstart x86_64 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 6 Workstation RPMs x86_64 6Workstation"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 Workstation RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-workstation-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 7 Workstation Kickstart x86_64 ${RHEL7}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Enterprise Linux 7 Workstation RPMs x86_64 7Workstation"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-workstation-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux Workstation" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 Workstation RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-workstation-x86_64-cv" --organization="${ORG}"
# Scientific Computing
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Enterprise Linux 6 for Scientific Computing Kickstart x86_64 ${RHEL6}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Enterprise Linux 6 for Scientific Computing RPMs x86_64 6ComputeNode"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-6-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Satellite Tools 6.1 for RHEL 6 for Scientific Computing RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-6-scientific-x86_64-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Enterprise Linux 7 for Scientific Computing Kickstart x86_64 ${RHEL7}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Enterprise Linux 7 for Scientific Computing RPMs x86_64 7ComputeNode"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="rhel-7-scientific-x86_64-cv" --organization="${ORG}" --product="Red Hat Enterprise Linux for Scientific Computing" --repository="Red Hat Satellite Tools 6.1 for RHEL 7 for Scientific Computing RPMs x86_64"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="rhel-7-scientific-x86_64-cv" --organization="${ORG}"
# Promote all content views to 'DEV' lifecycle
for cvname in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv content-view list --organization="${ORG}" | cut -d ',' -f 2 | grep -vi '^Name' | grep -vi '^Default' |sort); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view version promote --id=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view info --name="${cvname}" --organization="${ORG}" | grep '^Versions:' -A10 | grep '1)' | cut -d ':' -f2 | sed -e 's/^[ \t]*//') --content-view="${cvname}" --organization="${ORG}" --to-lifecycle-environment='DEV' --async; done
# Create Host Collections
for version in 5 6 7; do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" host-collection create --name="RHEL ${version}" --organization="${ORG}"; done
# Create Activation Keys for each OS x Arch combination
## "ak-${name%-cv}" takes the content view name (eg. rhel-7-scientific-x86_64-cv) and lops off the '-cv' part
for name in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv content-view list --organization="${ORG}" | cut -d ',' -f 2 | grep -vi '^Name' | grep -vi '^Default' |sort); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key create --name="ak-${name%-cv}" --organization="${ORG}" --content-view="${name}" --lifecycle-environment="DEV"; done
# Add host collection to corresponding Activation Key
## ${name:8:1} takes the activationkey name (eg. ak-rhel-7-scientific-x86_64) and slice the 8th character (i.e '7')
for name in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv activation-key list --organization="${ORG}" | cut -d ',' -f2 | grep -vi '^Name'); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key add-host-collection --name="${name}" --host-collection="RHEL ${name:8:1}" --organization="${ORG}"; done
# Add all available subscriptions to all Activation Keys
## Use the Employee SKU
EMPLOYEE_SKU=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv subscription list --organization="${ORG}" | grep 'Employee SKU' | cut -d ',' -f 8)
for id in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv activation-key list --organization="${ORG}" | cut -d ',' -f1 | grep -vi '^id'); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key add-subscription --id="${id}" --organization="${ORG}" --subscription-id="${EMPLOYEE_SKU}"; done
# Associate existing OSes to provisioning templates
for template in "Kickstart default PXELinux" "Satellite Kickstart Default"; do for idx in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | cut -d ',' -f1 | grep -vi "^id"); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" template add-operatingsystem --name="${template}" --operatingsystem-id=${idx}; done; done
# Associate partition table to all OSes
for idx in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | cut -d ',' -f1 | grep -vi "^id"); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" os add-ptable --id=${idx} --partition-table="Kickstart default"; done
export KICKSTART_PXE=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv template info --name="Kickstart default PXELinux" | cut -d ',' -f1 | grep -vi '^id')
export KICKSTART_SAT=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv template info --name="Satellite Kickstart Default" | cut -d ',' -f1 | grep -vi '^id')
# Set provisioning templates as default for every OS
for idx in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | cut -d ',' -f1 | grep -vi "^id"); do for template in ${KICKSTART_PXE} ${KICKSTART_SAT}; do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" os set-default-template --id=${idx} --config-template-id=${template}; done; done
## Get puppet environment IDs
export RHEL_5_SERVER_32_ENV=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv environment list --organization="${ORG}" --search='name~"DEV_rhel_5_server_i386_cv"' | cut -d ',' -f1 | grep -vi "^id")
export RHEL_5_SERVER_64_ENV=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv environment list --organization="${ORG}" --search='name~"DEV_rhel_5_server_x86_64_cv"' | cut -d ',' -f1 | grep -vi "^id")
export RHEL_6_SERVER_32_ENV=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv environment list --organization="${ORG}" --search='name~"DEV_rhel_6_server_i386_cv"' | cut -d ',' -f1 | grep -vi "^id")
export RHEL_6_SERVER_64_ENV=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv environment list --organization="${ORG}" --search='name~"DEV_rhel_6_server_x86_64_cv"' | cut -d ',' -f1 | grep -vi "^id")
export RHEL_7_SERVER_64_ENV=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv environment list --organization="${ORG}" --search='name~"DEV_rhel_7_server_x86_64_cv"' | cut -d ',' -f1 | grep -vi "^id")
## Get medium names
export RHEL_5_SERVER_32_MEDIUM=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv medium list --search='name~"Linux_5_Server_Kickstart_i386"' | cut -d ',' -f 2 | grep -vi 'name')
export RHEL_5_SERVER_64_MEDIUM=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv medium list --search='name~"Linux_5_Server_Kickstart_x86_64"' | cut -d ',' -f 2 | grep -vi 'name')
export RHEL_6_SERVER_32_MEDIUM=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv medium list --search='name~"Linux_6_Server_Kickstart_i386"' | cut -d ',' -f 2 | grep -vi 'name')
export RHEL_6_SERVER_64_MEDIUM=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv medium list --search='name~"Linux_6_Server_Kickstart_x86_64"' | cut -d ',' -f 2 | grep -vi 'name')
export RHEL_7_SERVER_64_MEDIUM=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv medium list --search='name~"Linux_7_Server_Kickstart_x86_64"' | cut -d ',' -f 2 | grep -vi 'name')
## Get the OS ID
export RHEL5_OS_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | grep "${RHEL5}" | cut -d ',' -f1 | grep -vi "^id")
echo "RHEL 5 OS ID: ${RHEL5_OS_ID}"
export RHEL6_OS_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | grep "${RHEL6}" | cut -d ',' -f1 | grep -vi "^id")
echo "RHEL 6 OS ID: ${RHEL6_OS_ID}"
export RHEL7_OS_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv os list | grep "${RHEL7}" | cut -d ',' -f1 | grep -vi "^id")
echo "RHEL 7 OS ID: ${RHEL7_OS_ID}"
# Create host groups
## You will have to manually set the password and, if desired, compute profile since hammer won't let you
## No RHAI puppet module for RHEL 5 or 32-bit arches
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup create --name='RHEL 5 Server 32-bit HG' --content-view='rhel-5-server-i386-cv' --environment-id=${RHEL_5_SERVER_32_ENV} --lifecycle-environment='DEV' --content-source-id=${CAPSULE_ID} --puppet-proxy=$(hostname) --puppet-ca-proxy=$(hostname) --organizations="${ORG}" --domain-id=${DOMAIN_ID} --subnet='libvirt_subnet' --architecture='i386' --operatingsystem-id="${RHEL5_OS_ID}" --medium=${RHEL_5_SERVER_32_MEDIUM} --partition-table='Kickstart default' --locations="${LOCATION}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup set-parameter --hostgroup='RHEL 5 Server 32-bit HG' --name='kt_activation_keys' --value='ak-rhel-5-server-i386-cv'
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup create --name='RHEL 5 Server 64-bit HG' --content-view='rhel-5-server-x86_64-cv' --environment-id=${RHEL_5_SERVER_64_ENV} --lifecycle-environment='DEV' --content-source-id=${CAPSULE_ID} --puppet-proxy=$(hostname) --puppet-ca-proxy=$(hostname) --organizations="${ORG}" --domain-id=${DOMAIN_ID} --subnet='libvirt_subnet' --architecture='x86_64' --operatingsystem-id="${RHEL5_OS_ID}" --medium=${RHEL_5_SERVER_64_MEDIUM} --partition-table='Kickstart default' --locations="${LOCATION}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup set-parameter --hostgroup='RHEL 5 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-5-server-x86_64-cv'
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup create --name='RHEL 6 Server 32-bit HG' --content-view='rhel-6-server-i386-cv' --environment-id=${RHEL_6_SERVER_32_ENV} --lifecycle-environment='DEV' --content-source-id=${CAPSULE_ID} --puppet-proxy=$(hostname) --puppet-ca-proxy=$(hostname) --organizations="${ORG}" --domain-id=${DOMAIN_ID} --subnet='libvirt_subnet' --architecture='i386' --operatingsystem-id="${RHEL6_OS_ID}" --medium=${RHEL_6_SERVER_32_MEDIUM} --partition-table='Kickstart default' --locations="${LOCATION}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup set-parameter --hostgroup='RHEL 6 Server 32-bit HG' --name='kt_activation_keys' --value='ak-rhel-6-server-i386-cv'
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup create --name='RHEL 6 Server 64-bit HG' --content-view='rhel-6-server-x86_64-cv' --environment-id=${RHEL_6_SERVER_64_ENV} --lifecycle-environment='DEV' --content-source-id=${CAPSULE_ID} --puppet-proxy=$(hostname) --puppet-ca-proxy=$(hostname) --organizations="${ORG}" --puppet-classes='access_insights_client' --domain-id=${DOMAIN_ID} --subnet='libvirt_subnet' --architecture='x86_64' --operatingsystem-id="${RHEL6_OS_ID}" --medium=${RHEL_6_SERVER_64_MEDIUM} --partition-table='Kickstart default' --locations="${LOCATION}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup set-parameter --hostgroup='RHEL 6 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-6-server-x86_64-cv'
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup create --name='RHEL 7 Server 64-bit HG' --content-view='rhel-7-server-x86_64-cv' --environment-id=${RHEL_7_SERVER_64_ENV} --lifecycle-environment='DEV' --content-source-id=${CAPSULE_ID} --puppet-proxy=$(hostname) --puppet-ca-proxy=$(hostname) --organizations="${ORG}" --puppet-classes='access_insights_client' --domain-id=${DOMAIN_ID} --subnet='libvirt_subnet' --architecture='x86_64' --operatingsystem-id="${RHEL7_OS_ID}" --medium=${RHEL_7_SERVER_64_MEDIUM} --partition-table='Kickstart default' --locations="${LOCATION}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" hostgroup set-parameter --hostgroup='RHEL 7 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-7-server-x86_64-cv'
# Create a sync plan to handle 'Base OS' content synchronization for i386 and x86_64
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" sync-plan create --name="Sync Red Hat Daily" --enabled=yes --interval="daily" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" product set-sync-plan --name="Red Hat Enterprise Linux Server" --sync-plan="Sync Red Hat Daily" --organization="${ORG}"
# Related to Docker feature
export RHEL_6_DOCKER="rhel6.7"
export RHEL_7_DOCKER="rhel7.0"
export CENTOS_DOCKER="centos"
##########
# Install the katello cert RPM file
rpm -Uvh http://$(hostname)/pub/katello-ca-consumer-latest.noarch.rpm
##########
# Create a new registry pointed at Red Hat
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker registry create --name="Red Hat Docker Registry" --url="https://registry.access.redhat.com"
# Get its ID
# NOTE: Getting the ID is only available in UPSTREAM code so get the ID from the web ui
export REGISTRY_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv docker registry list | cut -d ',' -f 1 | grep -vi 'id')
echo $REGISTRY_ID
# Create a new container directly off the Registry using 'local' and 'external' compute resources
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-rhel-7-1-local" --registry-id="${REGISTRY_ID}" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${RHEL_7_DOCKER}" --tag="latest" --command="/bin/bash" --tty=yes
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-rhel-7-1-external" --registry-id="${REGISTRY_ID}" --compute-resource="external_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${RHEL_7_DOCKER}" --tag="latest" --command="/bin/bash" --tty=yes
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-rhel-6-7-local" --registry-id="${REGISTRY_ID}" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${RHEL_6_DOCKER}" --tag="latest" --command="top" --tty=yes
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-rhel-6-7-external" --registry-id="${REGISTRY_ID}" --compute-resource="external_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${RHEL_6_DOCKER}" --tag="latest" --command="top" --tty=yes
###########
# Create a new container directly off Docker Registry Hub
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-centos-latest-1-local" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${CENTOS_DOCKER}" --tag="latest" --command="top" --tty=yes
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-centos-latest-1-external" --compute-resource="external_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${CENTOS_DOCKER}" --tag="latest" --command="top" --tty=yes
# Create a custom product for Docker content
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" product create --name='Docker' --organization="${ORG}"
# Custom repository that uses Docker Registry Hub...
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository create --name='CentOS' --docker-upstream-name='centos' --url='https://registry-1.docker.io/' --organization="${ORG}" --product='Docker' --content-type=docker --publish-via-http=true
# ... and sync it
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository synchronize --name='CentOS' --product='Docker' --organization="${ORG}"
# Now provision a new container using the default content view
# First, get the repo ID for the Library x Default Organization View combination
export DOCKER_REPO_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv repository list --organization="${ORG}" --content-view="Default Organization View" --environment="Library" --name='CentOS' | cut -d ',' -f 1 | grep -vi 'id')
echo $DOCKER_REPO_ID
# Then, get the full repository name (usually includes the lifecycle name in it)
export DOCKER_REPO_NAME=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository info --id="${DOCKER_REPO_ID}" | grep -i "^Container Repository Name" | cut -d ':' -f 2 | sed -e 's/^[ \t]*//')
echo $DOCKER_REPO_NAME
# And provision container from default content view
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-centos-from-default-cv-01" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${DOCKER_REPO_NAME}" --tag="latest" --command="top" --tty=yes
# Now, let's create a content view and add Docker repo to it so we can provision another container from a different lifecycle
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="docker-cv" --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view add-repository --name="docker-cv" --organization="${ORG}" --product="Docker" --repository="CentOS"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="docker-cv" --organization="${ORG}"
# Provision container from Library
export DOCKER_REPO_LIBRARY_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv repository list --organization="${ORG}" --content-view="docker-cv" --environment="Library" --name='CentOS' | cut -d ',' -f 1 | grep -vi 'id')
echo $DOCKER_REPO_LIBRARY_ID
# Then, get the full repository name (usually includes the lifecycle name in it)
export DOCKER_REPO_NAME=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository info --id="${DOCKER_REPO_LIBRARY_ID}" | grep -i "^Container Repository Name" | cut -d ':' -f 2 | sed -e 's/^[ \t]*//')
echo $DOCKER_REPO_NAME
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-centos-from-library-01" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${DOCKER_REPO_NAME}" --tag="latest" --command="top" --tty=yes
# Promote it
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view version promote --id=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view info --name="docker-cv" --organization="${ORG}" | grep '^Versions:' -A10 | grep '1)' | cut -d ':' -f2 | sed -e 's/^[ \t]*//') --content-view="${cvname}" --organization="${ORG}" --to-lifecycle-environment='DEV'
# Provision container from DEV
export DOCKER_REPO_DEV_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv repository list --organization="${ORG}" --content-view="docker-cv" --environment="DEV" --name='CentOS' | cut -d ',' -f 1 | grep -vi 'id')
echo $DOCKER_REPO_DEV_ID
# Then, get the full repository name (usually includes the lifecycle name in it)
export DOCKER_REPO_NAME=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository info --id="${DOCKER_REPO_DEV_ID}" | grep -i "^Container Repository Name" | cut -d ':' -f 2 | sed -e 's/^[ \t]*//')
echo $DOCKER_REPO_NAME
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" docker container create --name="docker-centos-from-dev-01" --compute-resource="local_docker" --organizations="${ORG}" --locations="${LOCATION}" --repository-name="${DOCKER_REPO_NAME}" --tag="latest" --command="top" --tty=yes
# Custom product for Puppet modules
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" product create --name='Puppet Modules' --organization="${ORG}"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository create --name='MoTD' --organization="${ORG}" --product='Puppet Modules' --content-type=puppet --publish-via-http=true
wget -O jeffmccune-motd-1.0.3.tar.gz https://forgeapi.puppetlabs.com/v3/files/jeffmccune-motd-1.0.3.tar.gz
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository upload-content --name='MoTD' --organization="${ORG}" --product='Puppet Modules' --path=jeffmccune-motd-1.0.3.tar.gz
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository create --name='NTP' --organization="${ORG}" --product='Puppet Modules' --content-type=puppet --publish-via-http=true
wget -O puppetlabs-ntp-3.3.0.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-ntp-3.3.0.tar.gz
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" repository upload-content --name='NTP' --organization="${ORG}" --product='Puppet Modules' --path=puppetlabs-ntp-3.3.0.tar.gz
# Create a content view
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view create --name="puppet-modules-cv" --organization="${ORG}"
# Add puppet modules to content view
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view puppet-module add --content-view='puppet-modules-cv' --organization="${ORG}" --name=motd
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view puppet-module add --content-view='puppet-modules-cv' --organization="${ORG}" --name=ntp
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view publish --name="puppet-modules-cv" --organization="${ORG}"
# Promote it to 'DEV' lifecycle
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view version promote --id=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view info --name="puppet-modules-cv" --organization="${ORG}" | grep '^Versions:' -A10 | grep '1)' | cut -d ':' -f2 | sed -e 's/^[ \t]*//') --content-view="${cvname}" --organization="${ORG}" --to-lifecycle-environment='DEV'
# We need quite a few arguments now
export HALF_GIG="536870912"
export ONE_GIG="1073741824"
export TWO_GIG="2147483648"
# Some misc IDs
export ORG='Default Organization'
export LOCATION='Default Location'
export COMPUTE_RESOURCE_ID=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv compute-resource list --search='name="local_libvirt"' | cut -d ',' -f 1 | grep -vi ID)
# Host creation
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" host create --name='rhel-6-server-32-01' --root-pass='abracadabra' --organization="${ORG}" --location="${LOCATION}" --hostgroup="RHEL 6 Server 32-bit HG" --compute-resource-id="${COMPUTE_RESOURCE_ID}" --compute-attributes="cpus=1, memory=${HALF_GIG}, start=1" --interface="primary=true, type=network, network=foreman" --volume="capacity=10G,format_type=qcow2"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" host create --name='rhel-6-server-64-01' --root-pass='abracadabra' --organization="${ORG}" --location="${LOCATION}" --hostgroup="RHEL 6 Server 64-bit HG" --compute-resource-id="${COMPUTE_RESOURCE_ID}" --compute-attributes="cpus=1, memory=${HALF_GIG}, start=1" --interface="primary=true, type=network, network=foreman" --volume="capacity=10G,format_type=qcow2"
hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" host create --name='rhel-7-server-64-01' --root-pass='abracadabra' --organization="${ORG}" --location="${LOCATION}" --hostgroup="RHEL 7 Server 64-bit HG" --compute-resource-id="${COMPUTE_RESOURCE_ID}" --compute-attributes="cpus=1, memory=${ONE_GIG}, start=1" --interface="primary=true, type=network, network=foreman" --volume="capacity=10G,format_type=qcow2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment