使用saltstack创建AWS EC2实例映像?

Vas*_*han 6 amazon-ec2 amazon-web-services salt-stack devops salt-cloud

有没有人尝试使用saltstack创建AWS AMI(图像).

我尝试使用它能够从现有的AMI创建新实例,但如何使用salt-cloud创建图像?

也尝试使用boto_ec2,但它给出了模块'boto_ec2'不可用的错误.

Fré*_*nri 1

您可以通过 2 个步骤完成此操作:

  1. 您需要拍摄卷的快照
  2. 您可以从给定快照创建 AMI

您可以在https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.ec2.html查看所有 saltstack ec2 命令

  1. 创建快照:create_snapshot

    salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826
    salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826 \
    description="My Snapshot Description"
    
    Run Code Online (Sandbox Code Playgroud)
  2. 创建 AMI:register_image

此命令从快照创建 ami

salt-cloud -f register_image my-ec2-config ami_name=my_ami \
description="my description" root_device_name=/dev/xvda snapshot_id=snap-xxxxxxxx
Run Code Online (Sandbox Code Playgroud)

  • 然后你应该做的是使用 [CloudClient](https://docs.saltstack.com/en/latest/ref/clients/#salt.cloud.CloudClient) 并编写一个 python 脚本来自动在所有服务器上运行它您想要的图像。 (3认同)