Chapter 10. Provisioning Cloud Instances in Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides public cloud compute resources. Using Red Hat Satellite 6, you can interact with Amazon EC2’s public API to create cloud instances and control their power management states. Use the procedures in this chapter to add a connection to an Amazon EC2 account and provision a cloud instance.
10.1. Prerequisites for Amazon EC2 Provisioning
The requirements for Amazon EC2 provisioning include:
- Synchronized content repositories for Red Hat Enterprise Linux 7. For more information, see Synchronizing Red Hat Repositories in the Content Management Guide.
- A Capsule Server managing a network in your EC2 environment. Use a Virtual Private Cloud (VPC) to ensure a secure network between the hosts and the Capsule Server.
- An Amazon Machine Image (AMI) for image-based provisioning.
- An activation key for host registration. For more information, see Creating An Activation Key in the Content Management guide.
10.2. Adding an Amazon EC2 Connection to the Satellite Server
Use this procedure to add the Amazon EC2 connection in the Satellite Server’s compute resources.
Time Settings and Amazon Web Services
Amazon Web Services uses time settings as part of the authentication process. Ensure that Satellite Server’s time is correctly synchronized. Ensure that an NTP service, such as
chronyd, is running properly on the Satellite Server. Failure to provide the correct time to Amazon Web Services can lead to authentication failures. For more information about synchronizing time in Satellite, see Synchronizing Time in Installing Satellite Server from a Connected Network.
To add an Amazon EC2 connection, complete the following steps:
- In the Satellite web UI, navigate to Infrastructure > Compute Resources and in the Compute Resources window, click Create Compute Resource.
- In the Name field, enter a name to identify the Amazon EC2 compute resource.
- From the Provider list, select EC2.
- In the Description field, enter information that helps distinguish the resource for future use.
- From the HTTP proxy list, select a HTTP proxy to connect to external API services. You must add HTTP proxies to Satellite before you can select a proxy from this list. For more information, see Configuring Satellite Server with HTTP Proxy in Installing Satellite Server from a Connected Network.
- In the Access Key and Secret Key fields, enter the access keys for your Amazon EC2 account. For more information, see Managing Access Keys for your AWS Account on the Amazon documentation website.
- Click the Load Regions button to populate the Regions list.
- From the Region list, select the Amazon EC2 region or data center to use.
- Click the Locations tab and ensure that the location you want to use is selected, or add a different location.
- Click the Organizations tab and ensure that the organization you want to use is selected, or add a different organization.
- Click Submit to save the Amazon EC2 connection.
For CLI Users
Create the connection with the
hammer compute-resource create command. Use
--password options to add the access key and secret key respectively.
# hammer compute-resource create --name "My_EC2" --provider "EC2" \ --description "Amazon EC2 Public Cloud` --user "user_name" \ --password "secret_key" --region "us-east-1" --locations "New York" \ --organizations "My_Organization"
10.3. Using an HTTP Smart Proxy with Compute Resources
In some cases, the EC2 compute resource that you use might require a specific HTTP proxy to communicate with Satellite. In Satellite, you can create an HTTP proxy entry and then assign the proxy to your EC2 compute resource.
However, if you configure a proxy for Satellite in Administer > Settings, and then add a proxy for your compute resource, the proxy that you define in Administer > Settings takes precedence.
To add an HTTP proxy that you can assign to a compute resource, complete the following steps:
- In the Satellite web UI, navigate to Infrastructure > HTTP Capsules, and select New HTTP Proxy.
- In the Name field, enter a name for the proxy.
- In the URL field, enter the URL for the proxy, including the port number.
- Optional: Enter a username and password to authenticate to the proxy, if your proxy requires authentication.
- Click Test Connection to ensure that you can connect to the proxy from Satellite.
- Click the Locations tab and add a location.
- Click the Organization tab and add an organization.
- Click Submit.
10.4. Adding Amazon EC2 Images to Satellite Server
Amazon EC2 uses image-based provisioning to create hosts. You must add image details to your Satellite Server. This includes access details and image location.
- In the Satellite web UI, navigate to Infrastructure > Compute Resources and select an Amazon EC2 connection.
- Click the Images tab, and then click New Image.
- In the Name field, enter a name to identify the image for future use.
- From the Operatingsystem list, select the operating system that corresponds with the image you want to add.
- From the Architecture list, select the operating system’s architecture.
In the Username field, enter the SSH user name for image access. This is normally the
- In the Password field, enter the SSH password for image access.
In the Image ID field, enter the Amazon Machine Image (AMI) ID for the image. This is usually in the following format:
From the User data list, select whether the images support user data input, such as
cloud-initdata. If you enable user data, the Finish scripts are automatically disabled. This also applies in reverse: if you enable the Finish scripts, this disables user data.
- From the IAM role list, select the Amazon security role used for creating the image.
- Click Submit to save the image details.
For CLI Users
Create the image with the
hammer compute-resource image create command. Use the
--uuid field to store the full path of the image location on the Amazon EC2 server.
# hammer compute-resource image create --name "Test Amazon EC2 Image" \ --operatingsystem "RedHat 7.2" --architecture "x86_64" --username root \ --user-data true --uuid "ami-my_ami_id" --compute-resource "My_EC2"
10.5. Adding Amazon EC2 Details to a Compute Profile
You can add hardware settings for instances on Amazon EC2 to a compute profile.
To add hardware settings, complete the following steps:
- In the Satellite web UI, navigate to Infrastructure > Compute Profiles and click the name of your profile, then click an EC2 connection.
- From the Flavor list, select the hardware profile on EC2 to use for the host.
- From the Image list, select the image to use for image-based provisioning.
- From the Availability zone list, select the target cluster to use within the chosen EC2 region.
- From the Subnet list, add the subnet for the EC2 instance. If you have a VPC for provisioning new hosts, use its subnet.
- From the Security Groups list, select the cloud-based access rules for ports and IP addresses to apply to the host.
From the Managed IP list, select either a
PublicIP or a
- Click Submit to save the compute profile.
For CLI Users
The compute profile CLI commands are not yet implemented in Red Hat Satellite 6.4. As an alternative, you can include the same settings directly during the host creation process.
10.6. Creating Image-Based Hosts on Amazon EC2
The Amazon EC2 provisioning process creates hosts from existing images on the Amazon EC2 server.
- In the Satellite web UI, navigate to Hosts > New Host.
- In the Name field, enter a name for the host.
- From the Host Group list, you can select a host group to populate most of the new host’s fields.
- From the Deploy on list, select the EC2 connection.
- From the Compute Profile list, select a profile to use to automatically populate virtual machine-based settings.
- Click the Interface tab, and then click Edit on the host’s interface, and verify that the fields are populated with values. Leave the Mac Address field blank. The Satellite Server automatically selects and IP address and the Managed, Primary, and Provision options for the first interface on the host.
- Click the Operating System tab and confirm that all fields are populated with values.
- Click the Virtual Machine tab and confirm that all fields are populated with values.
- Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.
- Click Submit to save your changes.
This new host entry triggers the Amazon EC2 server to create the instance, using the pre-existing image as a basis for the new volume.
For CLI Users
Create the host with the
hammer host create command and include
--provision-method image to use image-based provisioning.
# hammer host create --name "ec2-test1" --organization "My_Organization" \ --location "New York" --hostgroup "Base" \ --compute-resource "My_EC2" --provision-method image \ --image "Test Amazon EC2 Image" --enabled true --managed true \ --interface "managed=true,primary=true,provision=true,subnet_id=EC2" \ --compute-attributes="flavor_id=m1.small,image_id=TestImage,availability_zones=us-east-1a,security_group_ids=Default,managed_ip=Public"
For more information about host creation parameters for this compute resource, see Appendix B, Additional Host Parameters for Hammer CLI.
10.7. Connecting to an Amazon EC2 instance using SSH
You can connect remotely to an Amazon EC2 instance from Satellite Server using SSH. However, to connect to any Amazon Web Services EC2 instance that you provision through Red Hat Satellite, you must first access the private key that is associated with the compute resource in the Foreman database, and use this key for authentication.
To locate the private key and connect to an Amazon EC2 server using SSH, complete the following steps:
To locate the compute resource list, on your Satellite Server base system, enter the following command, and note the ID of the compute resource that you want to use:
# hammer compute-resource list
Switch user to the
# su - postgres
Connect to the Foreman database as the user
# postgres=# \c foreman
Select the secret from
compute_resource_id = 3:
# select secret from key_pairs where compute_resource_id = 3; secret
Copy the key from after
-----BEGIN RSA PRIVATE KEY-----until
-----END RSA PRIVATE KEY-----.
.pemfile and paste your key into the file:
# vim Keyname.pem
Ensure that you restrict access to the
# chmod 600 Keyname.pem
To connect to the Amazon EC2 instance, enter the following command:
ssh -i Keyname.pem firstname.lastname@example.org
10.8. Configuring a Finish Template for an Amazon Web Service EC2 Environment
You can use Red Hat Satellite finish templates during the provisioning of Red Hat Enterprise Linux instances in an Amazon EC2 environment.
To configure a finish template for Amazon EC2, complete the following steps:
- In the Red Hat Satellite 6 web UI, navigate to Hosts > Provisioning Templates.
In the Provisioning Templates page, enter
Kickstart default finishinto the search field and click Search.
- On the Kickstart default finish template, select Clone.
- In the Name field, enter a unique name for the template.
In the template, prefix each command that requires root privileges with
sudo, except for
yumcommands, or add the following line to run the entire template as the sudo user:
sudo -s << EOS _Template_ _Body_ EOS
- Click the Association tab, and associate the template with a Red Hat Enterprise Linux operating system that you want to use.
- Click the Locations tab, and add the the location where the host resides.
- Click the Organizations tab, and add the organization that the host belongs to.
- Make any additional customizations or changes that you require, then click Submit to save your template.
- Navigate to Hosts > Operating systems and select the operating system that you want for your host.
- Click the Templates tab, and from the Finish Template list, select your finish template.
- Navigate to Hosts > Create Host and enter the information about the host that you want to create.
- Click the Parameters tab and navigate to Host parameters.
In Host parameters, click the Add Parameter button three times to add three new parameter fields. Add the following three parameters:
In the Name field, enter
remote_execution_ssh_keys. In the corresponding Value field, enter the output of
In the Name field, enter
remote_execution_ssh_user. In the corresponding Value field, enter
In the Name field, enter
activation_keys. In the corresponding Value field, enter your activation key.
- In the Name field, enter
- Click Submit to save the changes.
10.9. More Information about Amazon Web Services and Satellite
For information about how to locate Red Hat Gold Images on Amazon Web Services EC2, see How to Locate Red Hat Cloud Access Gold Images on AWS EC2.
For information about how to install and use the Amazon Web Service Client on Linux, see Install the AWS Command Line Interface on Linux in the Amazon Web Services documentation.
For information about importing and exporting virtual machines in Amazon Web Services, see VM Import/Export in the Amazon Web Services documentation.