Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove instance-state-name inverse filters in favor of standard value… #237

Merged
merged 3 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/237_replace_inverse_ec2_aws_filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- aws_ec2 module - Replace inverse aws instance-state-name filters !terminated, !shutting-down in favor of postive filters pending, running, stopping, stopped. Issue 235. (https://github.com/ansible-collections/amazon.aws/pull/237)
2 changes: 1 addition & 1 deletion plugins/modules/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ def startstop_instances(module, ec2, instance_ids, state, instance_tags):
for key, value in instance_tags.items():
filters["tag:" + key] = value

filters['instance-state-name'] = ["!terminated", "!shutting-down"]
filters['instance-state-name'] = ["pending", "running", "stopping", "stopped"]

if module.params.get('id'):
filters['client-token'] = module.params['id']
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/targets/ec2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@
- (result.instances|length) == 1
- "result.instances[0].state.name == 'running'"

- name: test second instance is stopped
ec2:
instance_ids: "{{ test_instance_2.instance_ids }}"
state: stopped
wait: yes
register: result

- name: assert second instance is stopped
assert:
that:
- "result.instances[0].state == 'stopped'"

# ========================================================

always:
Expand Down