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 instance stopping doesn't work where termination works #272

Closed
p-goetz opened this issue Mar 1, 2021 · 3 comments
Closed

EC2 instance stopping doesn't work where termination works #272

p-goetz opened this issue Mar 1, 2021 · 3 comments
Labels
bug This issue/PR relates to a bug python3

Comments

@p-goetz
Copy link

p-goetz commented Mar 1, 2021

SUMMARY

Simply stopping an instance doesn't work, but termination does.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

amazon.aws.ec2

ANSIBLE VERSION
2.10.6
CONFIGURATION
HOST_KEY_CHECKING(/var/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/var/ansible/ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT

Ubuntu Linux 20.04.2 LTS

STEPS TO REPRODUCE

Start EC2 instance to be stopped.

- hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: Find EC2 instance ID
      ec2_instance_info: 
        region: "{{ region }}"
        filters:
          "tag:Name": "{{ instance_name }}"
      register: ec2
    - name: Terminate EC2 instance
      ec2:
        region: "{{ region }}"
        instance_id: "{{ item.instance_id }}"
        state: stopped
        wait: yes
      loop: "{{ ec2.instances }}"
EXPECTED RESULTS

The instance will be stopped.

ACTUAL RESULTS

Wait times out after 5(?) minutes, should be the default timeout.

PLAY [localhost] **************************************************************************************************************************************************************************************************

TASK [Find EC2 instance ID] ***************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Stop EC2 instance] ******************************************************************************************************************************************************************************************
failed: [localhost] (item={'ami_launch_index': 0, 'image_id': 'ami-0bdf93799014acdc4', 'instance_id': 'i-0acb87f429d5c2bd3', 'instance_type': 't3.xlarge', 'key_name': 'ansible-key', 'launch_time': '2021-03-01T15:41:24+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'eu-central-1c', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': '', 'product_codes': [], 'public_dns_name': '', 'state': {'code': 48, 'name': 'terminated'}, 'state_transition_reason': 'User initiated (2021-03-01 16:01:12 GMT)', 'architecture': 'x86_64', 'block_device_mappings': [], 'client_token': '', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [], 'root_device_name': '/dev/sda1', 'root_device_type': 'ebs', 'security_groups': [], 'state_reason': {'code': 'Client.UserInitiatedShutdown', 'message': 'Client.UserInitiatedShutdown: User initiated shutdown'}, 'tags': {'class': 'proscrumdev', 'Name': 'psd-docker-host'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 2, 'threads_per_core': 2}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'pending', 'http_tokens': 'optional', 'http_put_response_hop_limit': 1, 'http_endpoint': 'enabled'}, 'enclave_options': {'enabled': False}}) => {"ansible_loop_var": "item", "changed": false, "item": {"ami_launch_index": 0, "architecture": "x86_64", "block_device_mappings": [], "capacity_reservation_specification": {"capacity_reservation_preference": "open"}, "client_token": "", "cpu_options": {"core_count": 2, "threads_per_core": 2}, "ebs_optimized": false, "ena_support": true, "enclave_options": {"enabled": false}, "hibernation_options": {"configured": false}, "hypervisor": "xen", "image_id": "ami-0bdf93799014acdc4", "instance_id": "i-0acb87f429d5c2bd3", "instance_type": "t3.xlarge", "key_name": "ansible-key", "launch_time": "2021-03-01T15:41:24+00:00", "metadata_options": {"http_endpoint": "enabled", "http_put_response_hop_limit": 1, "http_tokens": "optional", "state": "pending"}, "monitoring": {"state": "disabled"}, "network_interfaces": [], "placement": {"availability_zone": "eu-central-1c", "group_name": "", "tenancy": "default"}, "private_dns_name": "", "product_codes": [], "public_dns_name": "", "root_device_name": "/dev/sda1", "root_device_type": "ebs", "security_groups": [], "state": {"code": 48, "name": "terminated"}, "state_reason": {"code": "Client.UserInitiatedShutdown", "message": "Client.UserInitiatedShutdown: User initiated shutdown"}, "state_transition_reason": "User initiated (2021-03-01 16:01:12 GMT)", "tags": {"Name": "psd-docker-host", "class": "proscrumdev"}, "virtualization_type": "hvm"}, "msg": "wait for instances running timeout on Mon Mar  1 17:04:10 2021"}
@ansibullbot
Copy link

Files identified in the description:
None

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 ansibullbot added bug This issue/PR relates to a bug needs_triage python3 labels Mar 1, 2021
@abikouo
Copy link
Contributor

abikouo commented Mar 3, 2021

Hi @p-goetz
Thanks you for rising it, It has probably fixed on a PR #237, it was released on collection 1.4.0, so please updated to this version and try again.

@p-goetz
Copy link
Author

p-goetz commented Mar 6, 2021

Thank you very much for this hint. I didn't realize that I could update individual parts of Ansible. I did that and it works.

@p-goetz p-goetz closed this as completed Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug python3
Projects
None yet
Development

No branches or pull requests

4 participants