A solution for automatically configuring RHEL-based High Availability (HA) clusters on AWS.
This README is also available in Korean. Please use the Korean version, README_KR.md
.
This project consists of two main components:
- CloudFormation Template (
deployment.yaml
) - AWS infrastructure configuration - SSM Document (
ha-cluster-setup-document.json
) - Automated HA cluster setup
- VPC: 10.0.0.0/16 CIDR block
- Subnets:
- SubnetB (ap-northeast-2b): 10.0.1.0/24
- SubnetD (ap-northeast-2d): 10.0.2.0/24
- EC2 Instances: 2x RHEL 9.6 (t3.medium)
- Security Groups: Allow internal cluster communication
- IAM Roles: STONITH and Elastic IP management permissions
- Pacemaker/Corosync based cluster
- STONITH: Using
fence_aws
- Ansible: Automated configuration with rhel-system-roles
- Optional Dummy Resource: For testing purposes
- AWS CLI installed and configured
- Appropriate AWS permissions (EC2, IAM, SSM)
- Seoul region (ap-northeast-2) usage
# Create CloudFormation stack
aws cloudformation create-stack \
--stack-name rhel-ha-cluster \
--template-body file://deployment.yaml \
--parameters ParameterKey=SameSubnet,ParameterValue=false \
--capabilities CAPABILITY_NAMED_IAM \
--region ap-northeast-2
SameSubnet
:false
(default): Deploy in different AZstrue
: Deploy in the same subnet
# Create SSM document
aws ssm create-document \
--name "HA-Cluster-Setup" \
--document-type "Command" \
--document-format "JSON" \
--content file://ha-cluster-setup-document.json \
--region ap-northeast-2
[CAUTION] HA cluster setup execution performs SSM document "Run Command" only on Node 1.
# Check instance information
aws cloudformation describe-stacks \
--stack-name rhel-ha-cluster \
--query 'Stacks[0].Outputs' \
--region ap-northeast-2
# Execute HA cluster setup > Run SSM document command on one instance to be used as Node 1
aws ssm send-command \
--document-name "HA-Cluster-Setup" \
--instance-ids "i-xxxxxxxxx" \
--parameters '{
"Node1InstanceId":"i-xxxxxxxxx",
"Node1PrivateIP":"10.0.1.10",
"Node2InstanceId":"i-yyyyyyyyy",
"Node2PrivateIP":"10.0.2.20",
"ClusterPassword":"secure-password",
"ClusterName":"my-ha-cluster",
"DeployDummyResource":"false"
}' \
--region ap-northeast-2
Parameter | Default | Description |
---|---|---|
SameSubnet | false | Instance placement method selection |
Parameter | Required | Default | Description |
---|---|---|---|
Node1InstanceId | ✓ | - | Node1 instance ID |
Node1PrivateIP | ✓ | - | Node1 private IP |
Node2InstanceId | ✓ | - | Node2 instance ID |
Node2PrivateIP | ✓ | - | Node2 private IP |
ClusterPassword | redhat | Cluster password | |
ClusterName | fast-aws-rh-cluster | Cluster name | |
DeployDummyResource | false | Deploy test dummy resource |
- System Updates: Automatic update to latest packages
- User Creation: Automatic haadm account creation
- Connect the Instance: Configure to use Session Manager
- Required Packages: Install rhel-system-roles, AWS CLI, and other tools
- Firewall/SELinux: Automatic deactivation
- Boot Start: Disabled (manual start)
- Cloud Agent: Automatic installation
- STONITH Configuration: Using
fence_aws
- Host File: Automatic update (
/etc/hosts
) - Ansible Inventory: Dynamic generation
rhel.ha-cluster_pacemaker_on_aws/
├── deployment.yaml # CloudFormation template
├── ha-cluster-setup-document.json # SSM document
├── README.md # This file
└── README_KR.md # README for Korean
When executing the SSM document, the following files are created in /usr/local/ha_cluster/
:
inventory.yml
: Ansible inventoryupdate-hosts.yaml
: Host file update playbookfast-aws-playbook.yaml
: HA cluster deployment playbookgroup_vars/${CLUSTER_NAME}.yml
: Cluster configuration variables
- IAM Permissions: Apply principle of least privilege
- Security Groups: Allow only VPC internal communication
- IMDS: Enhanced security using v2
- SSM Agent Connection Failure: Check IAM role
- Ansible Execution Failure: Check SSH connectivity
- STONITH Failure: Check IAM permissions
# Check SSM command execution status
aws ssm get-command-invocation \
--command-id "command-id" \
--instance-id "i-xxxxxxxxx" \
--region ap-northeast-2
# Check cluster status
sudo pcs status
sudo pcs config
# Delete CloudFormation stack
aws cloudformation delete-stack \
--stack-name rhel-ha-cluster \
--region ap-northeast-2
# Delete SSM document
aws ssm delete-document \
--name "HA-Cluster-Setup" \
--region ap-northeast-2
Please submit bug reports or feature requests through issues.