Skip to content

Commit

Permalink
Add ansible to rhel (vmware-samples#105)
Browse files Browse the repository at this point in the history
- Moves RSHM registration to the kickstart
- Moves installation of the EPEL repository to the kickstart
- Updates provisioner script to check RHSM (via refresh) before installing additional packages.

Related Issue: vmware-samples#54
  • Loading branch information
tenthirtyam committed Oct 4, 2021
1 parent f30e8cf commit 14e0694
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion builds/linux/redhat-linux-8/data/ks.pkrtpl.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ reboot
%end

%post
yum install -y sudo open-vm-tools perl
/usr/sbin/subscription-manager register --username ${rhsm_username} --password ${rhsm_password} --autosubscribe --force
dnf install -y -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf makecache
dnf install -y sudo open-vm-tools perl ansible
echo "${build_username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${build_username}
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
%end
2 changes: 2 additions & 0 deletions builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ locals {
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
build_username = var.build_username
build_password_encrypted = var.build_password_encrypted
rhsm_username = var.rhsm_username
rhsm_password = var.rhsm_password
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
Expand Down
9 changes: 3 additions & 6 deletions scripts/linux/redhat-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@ export BUILD_USERNAME
export BUILD_KEY
export ANSIBLE_USERNAME
export ANSIBLE_KEY
export RHSM_USERNAME
export RHSM_PASSWORD

#### Register Red Hat Subscription Manager to enable updates. ###
echo '> Registering Red Hat Subscription Manager to enable updates ...'
subscription-manager register --username $RHSM_USERNAME --password $RHSM_PASSWORD --auto-attach
#### Checking Red Hat Subscription Manager status. ###
echo '> Checking the Red Hat Subscription Manager status ...'
subscription-manager refresh

#### Update the guest operating system. ###
echo '> Updating the guest operating system ...'
sudo dnf update -y

### Install additional packages. ###
echo '> Installing additional packages ...'
sudo dnf install -y -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y \
curl \
wget \
Expand Down

0 comments on commit 14e0694

Please sign in to comment.