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

How to use the ec2 module to start/stop exisiting EC2 instance #222

Closed
it-praktyk opened this issue Dec 31, 2020 · 2 comments
Closed

How to use the ec2 module to start/stop exisiting EC2 instance #222

it-praktyk opened this issue Dec 31, 2020 · 2 comments

Comments

@it-praktyk
Copy link

it-praktyk commented Dec 31, 2020

SUMMARY

I'm not sure is it a request to explain/update documentation or the bug report.

I try to start/stop the existing EC2 instance using the amazon.aws.ec2 module using the playbook like below.

---
- hosts: localhost
  gather_facts: false

  tasks:
    - local_action:
        module: amazon.aws.ec2
        instance_ids: ['i-07axxxxxxxxxxxxx7c']
        state: stopped
        region: eu-west-1
        wait: true

Because the ansible-playbook is run from the virtualenv I pass to it the value `-e 'ansible_python_interpreter=/home/<user_name>/Python-virtualenv/ansible-2.10.x/bin/python'

When I run it I receive only

TASK [amazon.aws.ec2] **********************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "wait for instances running timeout on Thu Dec 31 10:32:53 2020"}

The ansible-inventory -i inventory_config_aws_ec2.yml --list, run from the same virtualenv, returns the host that I try to stop.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

amazon.aws.ec2

ANSIBLE VERSION
ansible 2.10.4
  config file = /home/<folder_name>/ansible.cfg
  configured module search path = ['/home/<user_name>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/<user_name>/Python-virtualenv/ansible-2.10.x/lib/python3.6/site-packages/ansible
  executable location = /home/<user_name>/Python-virtualenv/ansible-2.10.x/bin/ansible
  python version = 3.6.9 (default, Oct  8 2020, 12:12:24) [GCC 8.4.0]
> ansible-galaxy collection list

# /home/<user_name>/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
amazon.aws        1.3.0  
ansible.netcommon 1.4.1  
@gravesm
Copy link
Member

gravesm commented Jan 8, 2021

@it-praktyk Thank you for posting. We would suggest perhaps trying to specify a longer wait time with wait_timeout. Also, you may find it more helpful to ask this question on the ansible-project mailing list.

@boutetnico
Copy link
Contributor

boutetnico commented Feb 9, 2021

I have the same issue when starting or stopping an instance using ec2 module. The task hangs until timeout. The instance state does not change in AWS web console.
It seems to be a regression in Ansible 2.10 because it was working fine on all previous Ansible versions.

I'm using the same region as @it-praktyk eu-west-1.

Edit: a workaround is to use ec2_instance module instead of ec2.

Edit 2: possibly related to #235.

abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…ollections#237)

Files transferred to instances via the SSM connection plugin should use
folders within the bucket that are namespaced per-host, to prevent collisions.
Files should also be deleted from buckets when they are no longer required.

Fixes: ansible-collections#221
Fixes: ansible-collections#222

Based on work by abeluck

changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants