Ansible 是否可以使用ec2_AMI模块创建实例存储AMI?

Ansible 是否可以使用ec2_AMI模块创建实例存储AMI?,ansible,ec2-ami,Ansible,Ec2 Ami,目前我正在使用Ansible 2.1.3.0,并且我正在尝试找出如何使用ec2_AMI模块创建实例存储AMI 如果实例具有实例存储根,则看起来不可能执行此操作-我得到的是实例在根上没有附加卷(null) 因此,我想知道如何创建intance store AMI(使用ec2_AMI模块)从EBS支持的实例?文档不允许我将第一个卷映射为ami,第二个卷需要映射为ephemeral0。我正在浏览ec2\U ami模块源代码,它似乎不支持这一点,但我可能忽略了一些东西 当我做curl时http://16

目前我正在使用Ansible 2.1.3.0,并且我正在尝试找出如何使用ec2_AMI模块创建实例存储AMI

如果实例具有实例存储根,则看起来不可能执行此操作-我得到的是
实例在根上没有附加卷(null)

因此,我想知道如何创建intance store AMI(使用ec2_AMI模块)从EBS支持的实例?文档不允许我将第一个卷映射为
ami
,第二个卷需要映射为
ephemeral0
。我正在浏览ec2\U ami模块源代码,它似乎不支持这一点,但我可能忽略了一些东西

当我做
curl时http://169.254.169.254/latest/meta-data/block-device-mapping/
在源EC2实例上,我得到以下信息:

ami
ephemeral0

我使用的是2.2,使用的是
ec2
,而不是
ec2\u ami
,但这将完成您所寻找的

- name: Launch instance
  ec2:
    aws_access_key: "{{ aws.access_key }}"
    aws_secret_key: "{{ aws.secret_key }}"
    instance_tags: "{{ instance.tags }}"
    count: 1
    state: started
    key_name: "{{ instance.key_name }}"
    group: "{{ instance.security_group }}"
    instance_type: "{{ instance.type }}"
    image: "{{ instance.image }}"
    wait: true
    region: "{{ aws.region }}"
    vpc_subnet_id: "{{ subnets_id }}"
    assign_public_ip: "{{ instance.public_ip }}"
    instance_profile_name: "{{ aws.iam_role }}"
    instance_initiated_shutdown_behavior: terminate
    volumes: 
      - device_name: /dev/sdb
        volume_type: ephemeral
        ephemeral: ephemeral0
  register: ec2

请特别注意
instance\u initiated\u shutdown\u行为
参数,因为默认值为
stop
,它与基于实例存储的系统不兼容,您需要将其设置为
terminate
才能工作。

我知道如何创建这样的EC2实例。但问题是创建AMI!我需要做的是创建
instance.image
在你的任务中…@DejanLekic抱歉,我误解了,你提到的错误把我甩了。我正试图实现同样的目标,我在这里也发布了一个新问题:@DejanLekic基于这个答案:我怀疑由于
ec2\u bundle\u实例
仅是Windows,所以
ec2\u ami
模块是pr可能在
实例存储
计算机上也有类似的限制,因此该过程可能需要使用Ansible
命令
任务手动编写脚本。