我正在使用一本剧本来创建ami并尝试获取新创建的ami id。但是调试正在进行中,而且#34; AMI没有更新"''请帮忙
- name: Create AMI
ec2_ami:
region: "{{ec2_region}}"
name: "aws-{{ec2_region}}"
state: present
instance_id: "{{ec2_info.instances.0.id}}"
wait: yes
tags:
Name: "aws-{{ec2_region}}-mr-ami"
deployment_type: "{{deployment_type}}"
pop_type: "{{pop_type}}"
register: image
- pause:
seconds: 10
- debug:
msg: "{{image}}"
- name: Set image id as fact
set_fact:
mr_ami_id: "{{image.image_id}}"
Playbook输出
任务[创建AMI] ************************************************** ************************************************** ***********************好的:[localhost] => { "改变了#34;:错误, "调用":{ " module_args":{ " architecture":" x86_64", " aws_access_key":null, " aws_secret_key":null, " delete_snapshot":false, "描述":"", " device_mapping":null, " ec2_url":null, " image_id":null, " instance_id":" i-065404d0d37e0acfb", " kernel_id":null, " launch_permissions":null, " name":" aws-ap-southeast-2-MessageRelay", " no_reboot":false, "个人资料":null, "地区":" ap-southeast-2", " root_device_name":null, " security_token":null, "州":"现在", "标签":{ "姓名":" aws-ap-southeast-2-mr-ami", " deployment_type":" dev", " pop_type":" mgmt" }, " validate_certs":是的, " virtualization_type":" hvm", "等待":是的, " wait_timeout":" 900" } }, " launch_permissions":{}, " msg":" AMI未更新" }
任务[暂停] ************************************************** ************************************************** ****************************任务路径:/ root / **************** ***** / create_ami.yml:24暂停10秒(ctrl + C然后' C' =提前继续,ctrl + C然后' A' = abort)确定:[ localhost] => { "改变了#34;:错误, " delta":10, " rc":0, "开始":" 2017-08-01 08:48:29.756546", " stderr":"", " stdout":"暂停了10.0秒", "停止":" 2017-08-01 08:48:39.756843", " user_input":"" }
任务[调试] ************************************************** ************************************************** ****************************任务路径:/ root / **************** * / create_ami.yml:27 ok:[localhost] => { "改变了#34;:错误, " msg":{ "改变了#34;:错误, " launch_permissions":{}, " msg":" AMI未更新" }}
任务[将图片ID设为事实] ************************************************** ************************************************** *************任务路径:/ root / *********** / trunk / ncs / pop-deployment / ******** _ asg / tasks /create_ami.yml:30致命:[localhost]:失败了! => { "失败":是的, " msg":"字段' args'具有无效值,似乎包含未定义的变量。错误是:' dict object'没有属性' image_id' \ n \ n错误似乎出现在' / root / ********************** **** / create_ami.yml':第30行第3列,但可能在文件的其他位置,具体取决于确切的语法问题。\ n \ n违规行似乎是:\ n \ n \ n- name:将图片ID设置为事实\ n ^ here \ n" }
PLAY RECAP ************************************************** ************************************************** ****************************** ip-10-10-5-111.ap-southeast-2.compute.internal: ok = 13 changed = 9 unreachable = 0 failed = 0 localhost:ok = 69 changed = 31 unreachable = 0 failed = 1
答案 0 :(得分:0)
这种情况正在发生,因为AMI的名字是" aws - {{ec2_region}}"已经存在,因此没有创建新的ami。我删除了旧的AMI并再次运行了剧本而没有任何问题。