You can use terraform on its own to spin up a number of Red Hat Enterprise Linux EC2 instances in AWS (version 9.x) with the resources needed to install AAP as a hybrid node configuration
Feel free to set the variables how you see fit
Terraform also produces a dynamic Ansible inventory file that can be used in playbooks for configuring this sytems.
Install the following on your local system:
- AWS cli
- terraform
- ansible (core)
terraform init
terraform apply
(type "yes" when prompted)
output shows all the public IP addresses, as well as a cli string to ssh into one of them.
delete everything by typing
terraform destroy
I have created a helper script called 'rhel-provision-and-config.sh' that calls terraform and then ansible
sh ./rhel-provision-and-config.sh <optional number of instances>
examples:
Just one ec2 instance (default)
sh ./rhel-provision-and-config.sh
ec2 instances == 3
sh ./rhel-provision-and-config.sh 3
you can also unregister the instance from Red Hat Insights and subscription by running the helper
script
rhel-deprovision-and-unregister.sh
this will also terminate the EC2 instance in AWS
run terraform destroy
afterwards if needed
Additional playbooks have been added to register your EC2 instances with a RHEL subscription and add them to Insights inventory:
rhel-reg-insights.yml
Usage:
ansible-playbook -i inventory rhel-reg-insights.yml --vault-id @prompt
Note:
vault data set in vars/reg-data.yml
and must be encrypted with ansible-vault
ansible-vault edit vars/reg-data.yml
.
.
username: <RH Subscription Username>
password: <RH Subscription Password>
Playbook to remove EC2 instances from the Insights inventory and unregister them:
rhel-unreg-insights.yml
Scripts to provision/deprovision and register/unregister have been created as well:
rhel-provision-and-register.sh
rhel-deprovision-and-unregister.sh
- Have a valid Red Hat Subscription
sudo subscription-manager register --username <username> --password <password> --auto-attach
- Activate your RHEL (see above)
- Check Insights on how to add based on version of RHEL
sudo insights-client --register
orsudo rhc connect -u <username> -p <password>
sudo insights-client --unregister
sudo subscription-manager unregister