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

EC2 module errors out since it incorrectly includes terminated instances #146

Closed
trondhindenes opened this issue Aug 20, 2020 · 4 comments · Fixed by #197
Closed

EC2 module errors out since it incorrectly includes terminated instances #146

trondhindenes opened this issue Aug 20, 2020 · 4 comments · Fixed by #197
Labels
affects_2.10 bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3

Comments

@trondhindenes
Copy link

trondhindenes commented Aug 20, 2020

SUMMARY

Given this task:

    - name: stop ec2 instances
      ec2:
        region: eu-west-1
        state: stopped
        wait: yes
        instance_tags:
          strange-dog-match-tag: "what"

If there are existing (recently) terminated ec2 instances matching that tag, Ansible will error out with this message:
"Unable to change state for instance i-03bb1408d136a9a4b, error: EC2ResponseError: 400 Bad Request\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response><Errors><Error><Code>IncorrectInstanceState</Code><Message>This instance 'i-03bb1408d136a9a4b' is not in a state from which it can be stopped.</Message></Error></Errors><RequestID>d35eac01-6fa2-4c62-9763-3a5a08651a5c</RequestID></Response>"}

This seems to happen because Ansible considers all instances matching the instance_tags, including terminated instances. The correct behaviour would be to only consider non-terminated instances for all evaluations

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ec2

ANSIBLE VERSION
ansible 2.9.12
  config file = None
  configured module search path = ['/home/trond/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]

CONFIGURATION
N/A
OS / ENVIRONMENT

Ubuntu 20.04

STEPS TO REPRODUCE

See description above

EXPECTED RESULTS

Ansible should disregard terminated instances and not error out

ACTUAL RESULTS

See description

@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 labels Aug 27, 2020
@nikhilpatne
Copy link

Hi @trondhindenes I am working on this issue

@tremble
Copy link
Contributor

tremble commented Nov 17, 2020

@nikhilpatne in case you didn't see: @gravesm submitted #197 which should address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants