9.2. 恢复 Ansible Automation Platform 部署


使用以下步骤确保平稳恢复过程。

注意

恢复的部署包含与原始备份部署相同的 VPC 网络设置。如果备份部署在现有 VPC 中部署,则其恢复的部署也会部署到那个 VPC 中。如果备份部署使用新的 VPC 部署,则恢复的部署也会使用新的 VPC 部署。

9.2.1. AWS 权限

您必须具有以下权限才能恢复计划恢复的部署。

注意

要验证权限或调试权限拒绝问题,AWS IAM Policy Simulator 会很有帮助。

下表包含必要的 IAM 策略列表

Expand
对于使用新 VPC 的部署对于使用现有 VPC 的部署

自动缩放

  • autoscaling:CreateAutoScalingGroup
  • autoscaling:CreateLaunchConfiguration
  • autoscaling:DeleteAutoScalingGroup
  • autoscaling:DeleteLaunchConfiguration
  • autoscaling:DescribeAutoScalingGroups
  • autoscaling:DescribeAutoScalingInstances
  • autoscaling:DescribeLaunchConfigurations
  • autoscaling:DescribeScalingActivities
  • autoscaling:UpdateAutoScalingGroup

自动缩放

  • autoscaling:CreateAutoScalingGroup
  • autoscaling:CreateLaunchConfiguration
  • autoscaling:DeleteAutoScalingGroup
  • autoscaling:DeleteLaunchConfiguration
  • autoscaling:DescribeAutoScalingGroups
  • autoscaling:DescribeAutoScalingInstances
  • autoscaling:DescribeLaunchConfigurations
  • autoscaling:DescribeScalingActivities
  • autoscaling:UpdateAutoScalingGroup

backup

  • backup:DescribeRestoreJob
  • backup:StartRestoreJob

backup

  • backup:DescribeRestoreJob
  • backup:StartRestoreJob

cloudformation

  • cloudformation:CreateChangeSet
  • cloudformation:CreateStack
  • cloudformation:CreateUploadBucket
  • cloudformation:DeleteStack
  • cloudformation:DescribeChangeSet
  • cloudformation:DescribeStackEvents
  • cloudformation:DescribeStacks
  • cloudformation:ExecuteChangeSet
  • cloudformation:GetStackPolicy
  • cloudformation:GetTemplateSummary
  • cloudformation:ListChangeSets
  • cloudformation:ListStackResources
  • cloudformation:ListStacks
  • cloudformation:TagResource
  • cloudformation:UpdateStack
  • cloudformation:ValidateTemplate

cloudformation

  • cloudformation:CreateChangeSet
  • cloudformation:CreateStack
  • cloudformation:CreateUploadBucket
  • cloudformation:DeleteStack
  • cloudformation:DescribeChangeSet
  • cloudformation:DescribeStackEvents
  • cloudformation:DescribeStacks
  • cloudformation:ExecuteChangeSet
  • cloudformation:GetStackPolicy
  • cloudformation:GetTemplateSummary
  • cloudformation:ListChangeSets
  • cloudformation:ListStackResources
  • cloudformation:ListStacks
  • cloudformation:TagResource
  • cloudformation:UpdateStack
  • cloudformation:ValidateTemplate

ec2

  • ec2:AllocateAddress
  • ec2:AssociateAddress
  • ec2:AssociateNatGatewayAddress
  • ec2:AssociateRouteTable
  • ec2:AssociateSubnetCidrBlock
  • ec2:AttachInternetGateway
  • ec2:AuthorizeSecurityGroupEgress
  • ec2:AuthorizeSecurityGroupIngress
  • ec2:CreateInternetGateway
  • ec2:CreateNatGateway
  • ec2:CreateRoute
  • ec2:CreateRouteTable
  • ec2:CreateSecurityGroup
  • ec2:CreateSubnet
  • ec2:CreateSubnetCidrReservation
  • ec2:CreateTags
  • ec2:CreateVpc
  • ec2:DeleteInternetGateway
  • ec2:DeleteNatGateway
  • ec2:DeleteRoute
  • ec2:DeleteRouteTable
  • ec2:DeleteSecurityGroup
  • ec2:DeleteSubnet
  • ec2:DeleteSubnetCidrReservation
  • ec2:DeleteVpc
  • ec2:DescribeAccountAttributes
  • ec2:DescribeAddresses
  • ec2:DescribeAddressesAttribute
  • ec2:DescribeAvailabilityZones
  • ec2:DescribeInstances
  • ec2:DescribeInternetGateways
  • ec2:DescribeKeyPairs
  • ec2:DescribeNatGateways
  • ec2:DescribeRouteTables
  • ec2:DescribeSecurityGroups
  • ec2:DescribeSubnets
  • ec2:DescribeVpcs
  • ec2:DetachInternetGateway
  • ec2:DisassociateAddress
  • ec2:DisassociateNatGatewayAddress
  • ec2:DisassociateRouteTable
  • ec2:DisassociateSubnetCidrBlock
  • ec2:GetSubnetCidrReservations
  • ec2:ModifyAddressAttribute
  • ec2:ModifyVpcAttribute
  • ec2:ReleaseAddress
  • ec2:RevokeSecurityGroupEgress
  • ec2:RevokeSecurityGroupIngress

ec2

  • ec2:RevokeSecurityGroupEgress
  • ec2:RevokeSecurityGroupIngress
  • ec2:DescribeKeyPairs
  • ec2:CreateSecurityGroup
  • ec2:DescribeSecurityGroups
  • ec2:DeleteSecurityGroup
  • ec2:CreateTags
  • ec2:AuthorizeSecurityGroupEgress
  • ec2:AuthorizeSecurityGroupIngress
  • ec2:DescribeInstances

elasticfilesystem

  • elasticfilesystem:CreateAccessPoint
  • elasticfilesystem:CreateFileSystem
  • elasticfilesystem:CreateMountTarget
  • elasticfilesystem:DeleteAccessPoint
  • elasticfilesystem:DeleteFileSystem
  • elasticfilesystem:DeleteMountTarget
  • elasticfilesystem:DescribeAccessPoints
  • elasticfilesystem:DescribeBackupPolicy
  • elasticfilesystem:DescribeFileSystemPolicy
  • elasticfilesystem:DescribeFileSystems
  • elasticfilesystem:DescribeLifecycleConfiguration
  • elasticfilesystem:DescribeMountTargets

elasticfilesystem

  • elasticfilesystem:CreateAccessPoint
  • elasticfilesystem:CreateFileSystem
  • elasticfilesystem:CreateMountTarget
  • elasticfilesystem:DeleteAccessPoint
  • elasticfilesystem:DeleteFileSystem
  • elasticfilesystem:DeleteMountTarget
  • elasticfilesystem:DescribeAccessPoints
  • elasticfilesystem:DescribeBackupPolicy
  • elasticfilesystem:DescribeFileSystemPolicy
  • elasticfilesystem:DescribeFileSystems
  • elasticfilesystem:DescribeLifecycleConfiguration
  • elasticfilesystem:DescribeMountTargets

elasticloadbalancing

  • elasticloadbalancing:AddTags
  • elasticloadbalancing:CreateListener
  • elasticloadbalancing:CreateLoadBalancer
  • elasticloadbalancing:CreateTargetGroup
  • elasticloadbalancing:DeleteListener
  • elasticloadbalancing:DeleteTargetGroup
  • elasticloadbalancing:DescribeListeners
  • elasticloadbalancing:DescribeTargetGroups
  • elasticloadbalancing:ModifyLoadBalancerAttributes
  • elasticloadbalancing:ModifyTargetGroupAttributes

elasticloadbalancing

  • elasticloadbalancing:AddTags
  • elasticloadbalancing:CreateListener
  • elasticloadbalancing:CreateLoadBalancer
  • elasticloadbalancing:CreateTargetGroup
  • elasticloadbalancing:DeleteListener
  • elasticloadbalancing:DeleteTargetGroup
  • elasticloadbalancing:DescribeListeners
  • elasticloadbalancing:DescribeTargetGroups
  • elasticloadbalancing:ModifyLoadBalancerAttributes
  • elasticloadbalancing:ModifyTargetGroupAttributes

iam

  • iam:AddRoleToInstanceProfile
  • iam:AttachRolePolicy
  • iam:CreateInstanceProfile
  • iam:CreateRole
  • iam:DeleteInstanceProfile
  • iam:DeleteRole
  • iam:DeleteRolePolicy
  • iam:DetachRolePolicy
  • iam:GetRolePolicy
  • iam:ListRoles
  • iam:PassRole
  • iam:PutRolePolicy
  • iam:RemoveRoleFromInstanceProfile
  • iam:TagRole

iam

  • iam:AddRoleToInstanceProfile
  • iam:AttachRolePolicy
  • iam:CreateInstanceProfile
  • iam:CreateRole
  • iam:DeleteInstanceProfile
  • iam:DeleteRole
  • iam:DeleteRolePolicy
  • iam:DetachRolePolicy
  • iam:GetRolePolicy
  • iam:ListRoles
  • iam:PassRole
  • iam:PutRolePolicy
  • iam:RemoveRoleFromInstanceProfile
  • iam:TagRole

kms

  • kms:CreateGrant
  • kms:Decrypt
  • kms:DescribeKey
  • kms:GenerateDataKey

kms

  • kms:CreateGrant
  • kms:Decrypt
  • kms:DescribeKey
  • kms:GenerateDataKey

rds

  • rds:AddTagsToResource
  • rds:CreateDBInstance
  • rds:CreateDBSubnetGroup
  • rds:DeleteDBInstance
  • rds:DeleteDBSubnetGroup
  • rds:DescribeDBInstances
  • rds:DescribeDBSnapshots
  • rds:DescribeDBSubnetGroups
  • rds:ModifyDBInstance
  • rds:RestoreDBInstanceFromDBSnapshot

rds

  • rds:AddTagsToResource
  • rds:CreateDBInstance
  • rds:CreateDBSubnetGroup
  • rds:DeleteDBInstance
  • rds:DeleteDBSubnetGroup
  • rds:DescribeDBInstances
  • rds:DescribeDBSnapshots
  • rds:DescribeDBSubnetGroups
  • rds:ModifyDBInstance
  • rds:RestoreDBInstanceFromDBSnapshot

s3

  • s3:CreateBucket
  • s3:GetObject
  • s3:PutObject

s3

  • s3:CreateBucket
  • s3:GetObject
  • s3:PutObject

secretsmanager

  • secretsmanager:CreateSecret
  • secretsmanager:DeleteSecret
  • secretsmanager:GetRandomPassword
  • secretsmanager:GetSecretValue
  • secretsmanager:PutSecretValue
  • secretsmanager:TagResource

secretsmanager

  • secretsmanager:CreateSecret
  • secretsmanager:DeleteSecret
  • secretsmanager:GetRandomPassword
  • secretsmanager:GetSecretValue
  • secretsmanager:PutSecretValue
  • secretsmanager:TagResource

sns

  • sns:ListTopics

sns

  • sns:ListTopics

9.2.2. 设置 ansible-on-clouds-ops 容器镜像

ansible-on-clouds-ops 镜像标签应与您的基础部署版本匹配。例如,如果您的基础部署版本是 2.4.20230630-00,请使用标签 2.4.20230630 拉取 ansible-on-clouds-ops 镜像。

流程

  1. 使用与基础部署相同的标签版本拉取 ansible-on-clouds-ops 容器镜像。

    注意

    在拉取 docker 镜像前,请确保使用 docker 登录到 registry.redhat.io。使用以下命令登录到 registry.redhat.io。

    $ docker login registry.redhat.io
    Copy to Clipboard Toggle word wrap

    有关 registry 登录的更多信息,请参阅 Registry 身份验证

    $ export IMAGE=registry.redhat.io/ansible-on-clouds/ansible-on-clouds-ops-rhel9:2.4.20230630
    $ docker pull $IMAGE --platform=linux/amd64
    Copy to Clipboard Toggle word wrap

9.2.3. 生成恢复数据文件

以下命令创建一个目录,并在恢复过程中使用空数据模板填充它。

流程

  1. 创建存放配置的文件夹

    $ mkdir command_generator_data
    Copy to Clipboard Toggle word wrap
  2. 使用配置文件模板填充 $(pwd)/command_generator_data 文件夹。

    注意

    在 Linux 上,命令生成器创建的任何文件或目录默认归 root:root 所有。要更改文件和目录的所有权,您可以在创建文件后运行 sudo chmod 命令。如需更多信息,请阅读 命令生成器 - 由 root 拥有的 Linux 文件

    $ docker run --rm -v $(pwd)/command_generator_data:/data $IMAGE \
      command_generator_vars aws_restore_stack \
      --output-data-file /data/restore.yml
    Copy to Clipboard Toggle word wrap
  3. 运行这些命令后,会创建一个 $(pwd)/command_generator_data/restore.yml 模板文件。此模板文件类似于以下内容:

    aws_restore_stack:
      ansible_config_path:
      cloud_credentials_path:
      deployment_name:
      extra_vars:
        aws_backup_iam_role_arn:
        aws_backup_name:
        aws_backup_restore_point_arn:
        aws_backup_vault_name:
        aws_rds_db_snapshot_arn:
        aws_region:
        aws_s3_bucket:
        aws_ssm_bucket_name:
    Copy to Clipboard Toggle word wrap

9.2.4. 更新恢复数据文件

在触发恢复前,您必须填充数据文件。以下变量是数据文件中列出的参数。

  • ansible_config_path (可选)仅在使用自定义 ansible_config 覆盖时使用。
  • cloud_credentials_path 是 AWS 凭证文件的路径。
  • DEPLOYMENT_ NAME 是您要恢复的部署的名称
  • aws_backup_iam_role_arn (可选)是 AWS IAM 角色的 Amazon 资源名称 (ARN),具有执行备份操作的权限。

    注意

    如果提供,playbook 将默认为这个值,超过 S3 上备份文件中引用的 IAM 角色的值。如需更多信息,请参阅备份 Ansible Automation Platform 部署

  • aws_backup_name 是 S3 中存储的备份文件夹的名称。此值在运行备份 playbook 后输出。
  • aws_backup_restore_point_arn (可选)是您要用于恢复的 EFS 恢复点的 ARN。

    注意

    如果提供,playbook 优先于 S3 的备份文件中引用的 EFS 恢复点。请参阅 AWS 权限

    您还必须确保提供的恢复点来自云上的 Ansible 版本(AoC),该版本与运行恢复的 ansible-on-clouds-ops 容器镜像的版本匹配。例如,从 AoC 版本 2.4.20230630-00 上的部署中获取的恢复点需要使用 ansible-on-clouds-ops 容器镜像 2.4.20230630

  • aws_backup_vault_name (可选)是保存 EFS 恢复点的备份库的名称。

    注意

    如果提供,playbook 优先于 S3 上备份文件中引用的备份库(在运行备份操作时生成的备份库)。请参阅 AWS 权限。您还必须确保此备份密码库与用于备份部署的内容匹配。

  • aws_rds_db_snapshot_arn (可选)是用于恢复的 RDS 快照的 ARN。

    注意

    如果提供,playbook 优先于 S3 上备份文件中引用的 RDS 快照。您还必须确保提供的 RDS 快照来自云上的 Ansible 版本,该版本与运行恢复的 ansible-on-clouds-ops 容器镜像的版本匹配。例如,从 AoC 版本 2.4.20230630-00 上的部署的 RDS 快照需要使用 ansible-on-clouds-ops 容器镜像 2.4.20230630

  • aws_region 是部署基础部署的区域。
  • aws_s3_bucket 是存储备份文件的 S3 存储桶的名称。这必须与用于备份的存储桶相同。
  • aws_ssm_bucket_name 是存储 AWS SSM 的临时配置文件的 S3 存储桶的名称。您可以使用现有存储桶或创建新存储桶。

    注意

    aws_ssm_bucket_name 参数仅适用于存储临时配置文件。不需要保存它以便在其他 playbook 中使用。可以使用任何有效的现有存储桶。有关创建 S3 存储桶的更多信息,请参阅 AWS 文档中的 AWS 创建 A Bucket

    填充数据文件后,它应类似于以下内容:此文件中的值作为示例提供。

    注意

    此数据文件示例中的可选值已被删除。如果您不想使用这些可选值并希望使用这些变量的默认值,则"必须"也为您的数据文件删除它们,如下例所示。如果要使用这些可选变量,则必须将"必须"包含在数据文件中,并分配一个值。

    aws_restore_stack:
      cloud_credentials_path: ~/.aws/credentials
      deployment_name: AnsibleAutomationPlatform
      extra_vars:
        aws_backup_name: ansible-automation-platform-bucket-20230706T163309
        aws_region: us-east-1
        aws_s3_bucket: ansible-automation-platform-bucket
        aws_ssm_bucket_name: aap-ssm-bucket
    Copy to Clipboard Toggle word wrap

9.2.5. 运行恢复 playbook

以下流程将恢复 playbook 作为容器运行。

流程

  1. 要运行恢复,请运行命令生成器。

    $ docker run --rm -v $(pwd)/command_generator_data:/data $IMAGE command_generator aws_restore_stack --data-file /data/restore.yml
    Copy to Clipboard Toggle word wrap

    这会生成 restore CLI 命令

    ----------------------------------------------
    docker run --rm --env PLATFORM=AWS -v ~/.aws/credentials:/home/runner/.aws/credentials:ro --env ANSIBLE_CONFIG=../aws-ansible.cfg \
    --env DEPLOYMENT_NAME=AnsibleAutomationPlatform --env GENERATE_INVENTORY=true --env CHECK_GENERATED_INVENTORY=false  \
    $IMAGE redhat.ansible_on_clouds.aws_restore_stack -e 'aws_foundation_stack_name=AnsibleAutomationPlatform \
    aws_backup_name=ansible-automation-platform-bucket-20230706T163309 aws_region=us-east-1 \
    aws_s3_bucket=ansible-automation-platform-bucket aws_ssm_bucket_name=aap-ssm-bucket'
    ===============================================
    Copy to Clipboard Toggle word wrap
  2. 运行生成的命令来触发恢复。

    $ docker run --rm --env PLATFORM=AWS -v ~/.aws/credentials:/home/runner/.aws/credentials:ro --env ANSIBLE_CONFIG=../aws-ansible.cfg \
    --env DEPLOYMENT_NAME=AnsibleAutomationPlatform --env GENERATE_INVENTORY=true --env CHECK_GENERATED_INVENTORY=false  \
    $IMAGE redhat.ansible_on_clouds.aws_restore_stack -e 'aws_foundation_stack_name=AnsibleAutomationPlatform \
    aws_backup_name=ansible-automation-platform-bucket-20230706T163309 aws_region=us-east-1 \
    aws_s3_bucket=ansible-automation-platform-bucket aws_ssm_bucket_name=aap-ssm-bucket'
    Copy to Clipboard Toggle word wrap
  3. 创建恢复的部署需要一些时间。当您成功运行 playbook 时,AWS CloudFormation 中提供了恢复的部署,与 restore.yml 文件中为它提供的名称匹配。
注意

恢复的部署包含与原始备份部署相同的 VPC 网络设置。如果备份部署在现有 VPC 中部署,则其恢复的部署也会部署到那个 VPC 中。如果备份部署使用新的 VPC 部署,则恢复的部署也会使用新的 VPC 部署。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat