Skip to content

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

Closed
@p-goetz

Description

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"}

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugpython3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions