为什么 ec2_ami 抱怨未知参数 WaiterConfig?
Why is ec2_ami complaining about unknown parameter WaiterConfig?
我正在尝试使用 Ansible 的 ec2_ami 模块从 EC2 实例创建 AMI。为此,我是运行这个角色:
---
- name: Stop instance
ec2:
instance_id: "{{ instanceId }}"
region: "{{ region }}"
state: stopped
wait: yes
- name: Create AMI
ec2_ami:
region: "{{ region }}"
instance_id: "{{ instanceId }}"
name: "{{ asg_name }}-{{ ansible_date_time.iso8601 | regex_replace('[^a-zA-Z0-9]', '-') }}"
wait: yes
state: present
register: ami
我收到这个错误:
Traceback (most recent call last):
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 701, in <module>
main()
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 697, in main
create_image(module, connection)
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 470, in create_image
waiter.wait(ImageIds=[image_id], WaiterConfig=dict(Delay=delay, MaxAttempts=max_attempts))
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 53, in wait
Waiter.wait(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 295, in wait
response = self._operation_method(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 84, in __call__
return self._client_method(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 159, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 470, in _make_api_call
api_params, operation_model, context=request_context)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 523, in _convert_to_request_dict
api_params, operation_model)
File "/usr/local/lib/python2.7/dist-packages/botocore/validate.py", line 270, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "WaiterConfig", must be one of: DryRun, ImageIds, Owners, ExecutableUsers, Filters
我在 linux Ubuntu 14.04 运行 Ansible 版本 2.5.0。这些是我安装的 boto 模块:
boto==2.45.0
boto3==1.7.0
botocore==1.4.50
我猜我遇到了版本问题,但不确定是什么问题。这个角色以前是 运行 但我从版本 2.0 升级了 Ansible。
问题是 botocore 需要升级。
sudo pip install awscli botocore boto3 -U
现在我的boto版本是
boto==2.45.0
boto3==1.7.0
botocore==1.10.0
角色运行很好。
在 Ansible 2.5 上,按照有关更新 awscli、boto3 和 botocore 的说明进行操作,问题仍然存在。
TASK [Create AMI Image from the instance just created] ***********************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Unknown parameter in input: "WaiterConfig", must be one of: DryRun, ImageIds, Owners, ExecutableUsers, Filters
fatal: [a_flap_prod_door_21841_a -> localhost]: FAILED!
pip 模块
- awscli==1.15.2
- boto==2.48.0
- boto3==1.7.2
- botocore==1.10.2
AMI 已创建,但标签 none。这在 Ansible 2.4 上不是问题。
这可以通过告诉任务不要等待来解决:
# CREATE THE AMI IMAGE
- name: Create AMI Image from the instance just created
local_action:
module: ec2_ami
instance_id: "{{ ec2_id }}"
wait: no
它 运行 通过了 - 没有错误并且标签已创建
我已经告诉任务不要等待
# CREATE THE AMI IMAGE
- name: Create AMI Image from the instance just created
local_action:
module: ec2_ami
instance_id: "{{ ec2_id }}"
wait: no
并且 "waiterconfig" 错误消息消失了。
如果你想查看AMI镜像创建的进度,因为你已经不在等待任务中了:
- name: Check the created AMI Image exists
local_action:
module: ec2_ami_facts
owners: self
region: "{{ region }}"
aws_access_key: "{{ aws_akey }}"
aws_secret_key: "{{ aws_skey }}"
filters:
"tag:Name": "NameOfAMI"
"tag:ami_completeness": "someOtherTag"
register: ami_find
until: ami_find.images|length > 0
retries: 5
delay: 10
这将每 10 秒检查一次,持续 5 秒,以查看 AMI 是否出现在结果中。如果有 1,则长度大于 0。您需要在过滤器中非常具体,以便在创建 ami 后只有一个结果。
这确实是 Ansible 2.5 的问题。这是关于 GitHub 的错误报告:https://github.com/ansible/ansible/issues/40303
您可以应用其他答案中发布的解决方法,或者返回 2.4 分支直到问题得到解决:
pip install ansible==2.4.5
这将删除您当前的 Ansible 版本并安装 2.4.5 版本。
请注意,在撰写本文时,2.4.5 是 2.4 分支上的最新版本。您可能想在 Ansible 2.4 Changelog 中查找最新版本并安装它。
我正在尝试使用 Ansible 的 ec2_ami 模块从 EC2 实例创建 AMI。为此,我是运行这个角色:
---
- name: Stop instance
ec2:
instance_id: "{{ instanceId }}"
region: "{{ region }}"
state: stopped
wait: yes
- name: Create AMI
ec2_ami:
region: "{{ region }}"
instance_id: "{{ instanceId }}"
name: "{{ asg_name }}-{{ ansible_date_time.iso8601 | regex_replace('[^a-zA-Z0-9]', '-') }}"
wait: yes
state: present
register: ami
我收到这个错误:
Traceback (most recent call last):
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 701, in <module>
main()
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 697, in main
create_image(module, connection)
File "/tmp/ansible_zO2i0P/ansible_module_ec2_ami.py", line 470, in create_image
waiter.wait(ImageIds=[image_id], WaiterConfig=dict(Delay=delay, MaxAttempts=max_attempts))
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 53, in wait
Waiter.wait(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 295, in wait
response = self._operation_method(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/waiter.py", line 84, in __call__
return self._client_method(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 159, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 470, in _make_api_call
api_params, operation_model, context=request_context)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 523, in _convert_to_request_dict
api_params, operation_model)
File "/usr/local/lib/python2.7/dist-packages/botocore/validate.py", line 270, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "WaiterConfig", must be one of: DryRun, ImageIds, Owners, ExecutableUsers, Filters
我在 linux Ubuntu 14.04 运行 Ansible 版本 2.5.0。这些是我安装的 boto 模块:
boto==2.45.0
boto3==1.7.0
botocore==1.4.50
我猜我遇到了版本问题,但不确定是什么问题。这个角色以前是 运行 但我从版本 2.0 升级了 Ansible。
问题是 botocore 需要升级。
sudo pip install awscli botocore boto3 -U
现在我的boto版本是
boto==2.45.0
boto3==1.7.0
botocore==1.10.0
角色运行很好。
在 Ansible 2.5 上,按照有关更新 awscli、boto3 和 botocore 的说明进行操作,问题仍然存在。
TASK [Create AMI Image from the instance just created] ***********************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Unknown parameter in input: "WaiterConfig", must be one of: DryRun, ImageIds, Owners, ExecutableUsers, Filters
fatal: [a_flap_prod_door_21841_a -> localhost]: FAILED!
pip 模块
- awscli==1.15.2
- boto==2.48.0
- boto3==1.7.2
- botocore==1.10.2
AMI 已创建,但标签 none。这在 Ansible 2.4 上不是问题。
这可以通过告诉任务不要等待来解决:
# CREATE THE AMI IMAGE
- name: Create AMI Image from the instance just created
local_action:
module: ec2_ami
instance_id: "{{ ec2_id }}"
wait: no
它 运行 通过了 - 没有错误并且标签已创建
我已经告诉任务不要等待
# CREATE THE AMI IMAGE
- name: Create AMI Image from the instance just created
local_action:
module: ec2_ami
instance_id: "{{ ec2_id }}"
wait: no
并且 "waiterconfig" 错误消息消失了。
如果你想查看AMI镜像创建的进度,因为你已经不在等待任务中了:
- name: Check the created AMI Image exists
local_action:
module: ec2_ami_facts
owners: self
region: "{{ region }}"
aws_access_key: "{{ aws_akey }}"
aws_secret_key: "{{ aws_skey }}"
filters:
"tag:Name": "NameOfAMI"
"tag:ami_completeness": "someOtherTag"
register: ami_find
until: ami_find.images|length > 0
retries: 5
delay: 10
这将每 10 秒检查一次,持续 5 秒,以查看 AMI 是否出现在结果中。如果有 1,则长度大于 0。您需要在过滤器中非常具体,以便在创建 ami 后只有一个结果。
这确实是 Ansible 2.5 的问题。这是关于 GitHub 的错误报告:https://github.com/ansible/ansible/issues/40303
您可以应用其他答案中发布的解决方法,或者返回 2.4 分支直到问题得到解决:
pip install ansible==2.4.5
这将删除您当前的 Ansible 版本并安装 2.4.5 版本。
请注意,在撰写本文时,2.4.5 是 2.4 分支上的最新版本。您可能想在 Ansible 2.4 Changelog 中查找最新版本并安装它。