Closed nethershaw closed 1 year ago
Files identified in the description:
plugins/modules/ec2_instance.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_instance.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @jillr @ryansb @s-hertel @tremble click here for bot help
@nethershaw,
Thanks for taking the time to open this issue. I personally prefer to consistently return details of the resource, even when no changes are made. I've tweaked the subject line a little, to reflect the desired change as this makes it easier for other people to find the issue.
So, is there a recommended workaround for the moment? I've just taught myself how to debug tasks because I expected this pattern to work, when it didn't.
The documentation even leads me to believe that the 'instances' key would be present if 'wait == true' -- it isn't:
So, is there a recommended workaround for the moment? I've just taught myself how to debug tasks because I expected this pattern to work, when it didn't.
ec2_instance_info: https://docs.ansible.com/ansible/devel/collections/amazon/aws/ec2_instance_info_module.html
FTR: this works, but shouldn't be necessary:
- name: Create EC2 instances
amazon.aws.ec2_instance:
instance_type: t2.nano
state: running
image:
id: ami-f2b39792
region: us-west-1
name: myinstance
exact_count: 2
- name: Gather information about EC2 instances
amazon.aws.ec2_instance_info:
region: us-west-1
filters:
"tag:Name": myinstance
instance-state-name: ["running"]
register: ec2_instances
Summary
I am duplicating issue #859 because it was incorrectly closed.
Idempotency -- the core design pattern and expectation on which Ansible is built -- requires that the module's return data be complete and consistent whether a change occurs or not. Any instances that matched
filters
passed to the module because they already exist must be included in the module'sinstances
return key.It is an anti-pattern to suggest inserting a second task to cover a fault in idempotency of the first, especially after breaking the expectation set by the original "ec2" module. In Linux design philosophy, any such breaking change is automatically a bug.
Issue Type
Bug Report
Component Name
ec2_instance
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
Gentoo Linux
Steps to Reproduce
Expected Results
Actual Results
Code of Conduct