이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 13. Provisioning cloud instances on Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides public cloud compute resources. Using Satellite, 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.
13.1. Prerequisites for Amazon EC2 provisioning 링크 복사링크가 클립보드에 복사되었습니다!
The requirements for Amazon EC2 provisioning include:
- 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 Capsule Server.
- An Amazon Machine Image (AMI) for image-based provisioning.
- You can use synchronized content repositories for Red Hat Enterprise Linux. For more information, see Syncing Repositories in Managing content.
- Provide an activation key for host registration. For more information, see Creating An Activation Key in Managing content.
13.2. Using an HTTP proxy to communicate with Amazon EC2 링크 복사링크가 클립보드에 복사되었습니다!
If your Amazon EC2 requires an HTTP proxy to communicate with Satellite, you have to setup and select the HTTP proxy in Satellite. If you have configured an HTTP proxy for Satellite in Administer > Settings, it takes precedence over the HTTP proxy for your compute resource.
Additional resources
- To add an HTTP proxy to Satellite, see Adding an HTTP proxy in Managing content.
13.3. Adding an Amazon EC2 connection to the Satellite Server 링크 복사링크가 클립보드에 복사되었습니다!
Use this procedure to add the Amazon EC2 connection in Satellite Server’s compute resources. To use the CLI instead of the Satellite web UI, see the CLI procedure.
Prerequisites
-
An AWS EC2 user performing this procedure needs the
AmazonEC2FullAccess
permissions. You can attach these permissions from AWS.
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 ntpd
or chronyd
, is running properly on Satellite Server. Failure to provide the correct time to Amazon Web Services can lead to authentication failures.
Procedure
- 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.
- Optional: From the HTTP proxy list, select an HTTP proxy to connect to external API services. You must add HTTP proxies to Satellite before you can select an HTTP proxy from this list. For more information, see Section 13.2, “Using an HTTP proxy to communicate with Amazon EC2”.
- 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.
- Optional: Click Load Regions 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.
- Select the new compute resource and then click the SSH keys tab, and click Download to save a copy of the SSH keys to use for SSH authentication. Until BZ1793138 is resolved, you can download a copy of the SSH keys only immediately after creating the Amazon EC2 compute resource. If you require SSH keys at a later stage, follow the procedure in Section 13.8, “Connecting to an Amazon EC2 instance using SSH”.
CLI procedure
Create the connection with the
hammer compute-resource create
command. Use--user
and--password
options to add the access key and secret key respectively.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.4. Creating an image for Amazon EC2 링크 복사링크가 클립보드에 복사되었습니다!
You can create images for Amazon EC2 from within Satellite.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your Amazon EC2 provider.
Click Create Image.
- In the Name field, enter a meaningful and unique name for your EC2 image.
- From the Operating System list, select an operating system to associate with the image.
- From the Architecture list, select an architecture to associate with the image.
- In the Username field, enter the username needed to SSH into the machine.
- In the Image ID field, enter the image ID provided by Amazon or an operating system vendor.
- Optional: Select the User Data check box to enable support for user data input.
- Optional: Set an Iam Role for Fog to use when creating this image.
- Click Submit to save your changes to Satellite.
13.5. 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.
To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources and select an Amazon EC2 connection.
- Click the Images tab, and then click Create Image.
- In the Name field, enter a name to identify the image for future use.
- From the Operating System 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
root
user. - 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:
ami-xxxxxxxx
. -
Optional: Select the User Data checkbox if the images support user data input, such as
cloud-init
data. 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. - Optional: In the IAM role field, enter the Amazon security role used for creating the image.
- Click Submit to save the image details.
CLI procedure
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.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6. Adding Amazon EC2 details to a compute profile 링크 복사링크가 클립보드에 복사되었습니다!
You can add hardware settings for instances on Amazon EC2 to a compute profile.
Procedure
- 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
Public
IP or aPrivate
IP. - Click Submit to save the compute profile.
CLI procedure
Set Amazon EC2 details to a compute profile:
hammer compute-profile values create
$ hammer compute-profile values create --compute-resource "My_Laptop" \ --compute-profile "My_Compute_Profile" \ --compute-attributes "flavor_id=1,availability_zone= My_Zone,subnet_id=1,security_group_ids=1,managed_ip=public_ip"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.7. Creating image-based hosts on Amazon EC2 링크 복사링크가 클립보드에 복사되었습니다!
The Amazon EC2 provisioning process creates hosts from existing images on the Amazon EC2 server. To use the CLI instead of the Satellite web UI, see the CLI procedure.
Procedure
- In the Satellite web UI, navigate to Hosts > Create Host.
- In the Name field, enter a name for the host.
- Optional: Click the Organization tab and change the organization context to match your requirement.
- Optional: Click the Location tab and change the location context to match your requirement.
- From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.
- 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 Interfaces tab, and on the interface of the host, click Edit.
Verify that the fields are populated with values. Note in particular:
- Satellite automatically assigns an IP address for the new host.
- Ensure that the MAC address field is blank. Amazon EC2 assigns a MAC address to the host during provisioning.
- The Name from the Host tab becomes the DNS name.
- Ensure that Satellite automatically selects the Managed, Primary, and Provision options for the first interface on the host. If not, select them.
- Click OK to save. To add another interface, click Add Interface. You can select only one interface for Provision and Primary.
- 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.
-
On the Parameters tab, click Add parameter. Add a parameter named
kt_activation_keys
, select the string type, and enter the name of the activation key as the value. The activation key has to belong to the same organization as your host. You can also enter a comma-separated list of multiple activation keys. - 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.
CLI procedure
Create the host with the
hammer host create
command and include--provision-method image
to use image-based provisioning.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information about additional host creation parameters for this compute resource, enter the hammer host create --help
command.
13.8. 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.
Procedure
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
$ hammer compute-resource list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to the Foreman database as the user
postgres
:su - postgres -c psql foreman
# su - postgres -c psql foreman
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Select the secret from
key_pairs
wherecompute_resource_id = 3
:select secret from key_pairs where compute_resource_id = 3; secret
# select secret from key_pairs where compute_resource_id = 3; secret
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Copy the key from after
-----BEGIN RSA PRIVATE KEY-----
until-----END RSA PRIVATE KEY-----
. Create a
.pem
file and paste your key into the file:vim Keyname.pem
# vim Keyname.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that you restrict access to the
.pem
file:chmod 600 Keyname.pem
# chmod 600 Keyname.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To connect to the Amazon EC2 instance, enter the following command:
ssh -i Keyname.pem ec2-user@example.aws.com
ssh -i Keyname.pem ec2-user@example.aws.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.9. 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.
If you want to use a Finish template with SSH, Satellite must reside within the EC2 environment and in the correct security group. Satellite currently performs SSH finish provisioning directly, not using Capsule Server. If Satellite Server does not reside within EC2, the EC2 virtual machine reports an internal IP rather than the necessary external IP with which it can be reached.
Procedure
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
-
In the Provisioning Templates page, enter
Kickstart default finish
into 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 forsubscription-manager register
andyum
commands, or add the following line to run the entire template as the sudo user:sudo -s << EOS _Template_ _Body_ EOS
sudo -s << EOS _Template_ _Body_ EOS
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.
- In the Satellite web UI, 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.
- In the Satellite web UI, navigate to Hosts > Create Host.
- In the Name field, enter a name for the host.
- Optional: Click the Organization tab and change the organization context to match your requirement.
- Optional: Click the Location tab and change the location context to match your requirement.
- From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.
- Click the Parameters tab and navigate to Host parameters.
In Host parameters, click Add Parameter two times to add two new parameter fields. Add the following parameters:
-
In the Name field, enter
activation_keys
. In the corresponding Value field, enter your activation key. -
In the Name field, enter
remote_execution_ssh_user
. In the corresponding Value field, enterec2-user
.
-
In the Name field, enter
- Click Submit to save the changes.
13.10. Deleting a virtual machine on Amazon EC2 링크 복사링크가 클립보드에 복사되었습니다!
You can delete virtual machines running on Amazon EC2 from within Satellite.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your Amazon EC2 provider.
- On the Virtual Machines tab, click Delete from the Actions menu. This deletes the virtual machine from the Amazon EC2 compute resource while retaining any associated hosts within Satellite. If you want to delete an orphaned host, navigate to Hosts > All Hosts and delete the host manually.
Additional resources
- You can configure Satellite to remove the associated virtual machine when you delete a host. For more information, see Section 2.22, “Removing a virtual machine upon host deletion”.
13.11. 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.