ちょっと勉強しておこうかなと。
この記事に記載すること
- AAPの概要
- AAPをEC2(RHEL9)にインストールする手順
以上。(それ以上のことは気が向いたら書くかも)
Ansible Automation Platform(AAP)とは
Ansible Automation Platform(AAP)は、Red Hatが提供するエンタープライズ向けの自動化ソリューションです。シンプルな記述でインフラ構成やアプリケーション展開の自動化を実現する「Ansible」のエンジンに加え、エンタープライズ環境で求められる信頼性・拡張性・セキュリティを備えたコンポーネント群を提供します。
主な特徴
-
Automation Controller(旧Tower)
- プレイブックの実行・スケジューリング・権限管理・ログ収集をGUI/REST API経由で操作可能。
-
Automation Hub
- Red Hat認定コレクションを含むAnsibleコンテンツをホストし、内部向けの共有リポジトリとしても機能。
-
Automation Mesh
- ハイブリッド/分散環境でも自動化を実行可能にする通信基盤。冗長性・拡張性に優れる
-
Insights & Analytics
- 自動化の利用状況・成功率などを可視化。ボトルネックや改善ポイントを発見できる。
ユースケース
- サーバー構築の自動化(オンプレミス/クラウド)
- ネットワーク・ストレージの構成管理
- セキュリティパッチの一括適用
- アプリケーションの継続的デプロイ
- インシデント対応や定型オペレーションの自動化
AAPのインストール手順
前提条件
- AWSの管理者相当の権限が設定されたAWS CLIが使えること
- Red Hat アカウントを持っていること
-
こちらからAAPの60日トライアルを申し込むこと
- 申込後、Subscriptions Inventryから、 60 Day Product Trial of Red Hat Ansible Automation Platform, Self-Supported (100 Managed Nodes) のSKUが追加されていることを確認する。
クレデンシャル情報のSSMへの登録
-
--value
の値は書き換えること - Red Hatアカウントは通常ログインに使うユーザ名とパスワードをそのまま用いる
- Registry Service Accountsはこちらにアクセスして、New Service Accountからアカウントを作成し、ユーザ名とトークンを用いる
aws ssm get-parameter --name "RedHatUsername" --value "Red Hatアカウントのユーザ名" --type "SecureString" --overwrite --region ap-northeast-1
aws ssm get-parameter --name "RedHatPassword" --value "Red Hatアカウントのパスワード" --type "SecureString" --overwrite --region ap-northeast-1
aws ssm put-parameter --name "RegistryUsername" --value "Registry Service Accountsのユーザ名" --type "SecureString" --overwrite --region ap-northeast-1
aws ssm put-parameter --name "RegistryToken" --value "Registry Service Accountsのトークン" --type "SecureString" --overwrite --region ap-northeast-1
CloudFormationでCreateStack
- 以下のYAMLをap-northeast-1のCloudFormationに放り込む
-
CREATE_COMPLETE 後も、しばらくはインストールが走っているので、15分後ぐらいに当該StackのOutputsに出力される、
AAPAccessURL
にアクセスする。
AWSTemplateFormatVersion: '2010-09-09'
Description: >
CloudFormation Template to deploy RHEL9 EC2 with Ansible Automation Platform (AAP).
Includes IAM Role and Policy for accessing SSM Parameter Store.
Parameters:
VpcCidr:
Type: String
Default: "10.0.0.0/16"
Description: CIDR block for the VPC
PublicSubnetCidr:
Type: String
Default: "10.0.1.0/24"
Description: CIDR block for the public subnet
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Default: "my-key-pair"
Description: Name of an existing EC2 KeyPair to enable SSH access
AllowedIp:
Type: String
Description: IP address allowed to access SSH and AAP GUI
Resources:
AAPVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: AAP-VPC
InternetGateway:
Type: AWS::EC2::InternetGateway
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref AAPVPC
InternetGatewayId: !Ref InternetGateway
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref AAPVPC
CidrBlock: !Ref PublicSubnetCidr
MapPublicIpOnLaunch: true
AvailabilityZone: ap-northeast-1a
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref AAPVPC
PublicRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref RouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
SubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet
RouteTableId: !Ref RouteTable
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable SSH and HTTPS from specific IP
VpcId: !Ref AAPVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref AllowedIp
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: !Ref AllowedIp
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref AllowedIp
InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: ec2.amazonaws.com
Action: sts:AssumeRole
Path: "/"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess
- arn:aws:iam::aws:policy/AWSKeyManagementServicePowerUser
InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref InstanceRole
EC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t3.large
KeyName: !Ref KeyName
ImageId: ami-04a74182910a57498
SubnetId: !Ref PublicSubnet
SecurityGroupIds:
- !Ref InstanceSecurityGroup
IamInstanceProfile: !Ref InstanceProfile
UserData:
Fn::Base64: !Sub |
#!/bin/bash
yum -y update
yum -y install git unzip curl
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
export PATH=$PATH:/usr/local/bin
RH_USER=$(aws ssm get-parameter --name "RedHatUsername" --with-decryption --query "Parameter.Value" --output text --region ${AWS::Region})
RH_PASS=$(aws ssm get-parameter --name "RedHatPassword" --with-decryption --query "Parameter.Value" --output text --region ${AWS::Region})
subscription-manager register --username "$RH_USER" --password "$RH_PASS"
subscription-manager config --rhsm.manage_repos=1
subscription-manager repos --enable ansible-automation-platform-2.4-for-rhel-9-x86_64-rpms
yum -y install ansible automation-controller ansible-automation-platform-installer
# ホスト名の取得
HOSTNAME=$(hostname)
# SSMパラメータの取得
REGISTRY_USERNAME=$(aws ssm get-parameter --name "RegistryUsername" --with-decryption --query "Parameter.Value" --output text --region ${AWS::Region})
REGISTRY_PASSWORD=$(aws ssm get-parameter --name "RegistryToken" --with-decryption --query "Parameter.Value" --output text --region ${AWS::Region})
# inventoryファイルの作成
cat <<EOF > /opt/ansible-automation-platform/installer/inventory
[automationcontroller]
$HOSTNAME ansible_connection=local
[all:vars]
admin_password='RedHat123!'
pg_host=''
pg_port='5432'
pg_database='awx'
pg_username='awx'
pg_password='awxpass'
pg_sslmode='prefer'
registry_url='registry.redhat.io'
registry_username='$REGISTRY_USERNAME'
registry_password='$REGISTRY_PASSWORD'
EOF
# setup.sh の実行
cd /opt/ansible-automation-platform/installer
sudo ./setup.sh | tee /var/log/aap-setup.log
systemctl enable automation-controller
systemctl start automation-controller
Outputs:
InstancePublicIP:
Description: Public IP of the AAP EC2 instance
Value: !GetAtt EC2Instance.PublicIp
AAPAccessURL:
Description: HTTPS URL to access AAP GUI
Value: !Sub "https://${EC2Instance.PublicDnsName}"
GUIにアクセス
- ユーザ名は
admin
、パスワードはRedHat123!
- 途中で入力を求められるユーザ名、パスワードはRed Hatアカウントのものと同じで良い
終わりに
- 動作確認していません。明日またやる。