# EC2 Terminate - Dynamic Inventory - boto required for this module

**URL:** <https://forum.ansible.com/t/ec2-terminate-dynamic-inventory-boto-required-for-this-module/19585>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [October 22, 2015, 12:32am UTC](https://forum.ansible.com/t/ec2-terminate-dynamic-inventory-boto-required-for-this-module/19585 "2015-10-22T00:32:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@K\_Cheng](https://forum.ansible.com/u/K_Cheng)\
**Post date:** [October 22, 2015, 12:32am UTC](https://forum.ansible.com/t/ec2-terminate-dynamic-inventory-boto-required-for-this-module/19585/1 "2015-10-22T00:32:09Z")

</div>

Hi All,

I’m trying to create a terminate AWS EC2 play using the dynamic inventory script but I keep getting fatal: [remote\_host\_ip]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “boto required for this module”}.

I created the instance using another play and that works perfectly.

My terminate play looks like this:

> * * *
> 
> - name: Find instances
> 
> hosts: tag\_Environment\_goji
> 
> gather\_facts: False
> 
> tasks:
> 
> - name: Create group
> 
> group\_by: key=mark\_terminate
> 
> - hosts: mark\_terminate
> 
> connection: local
> 
> gather\_facts: false
> 
> tasks:
> 
> - name: Terminate instance(s)
> 
> ec2:
> 
> profile: china
> 
> region: cn-north-1
> 
> instance\_ids: “{{ ec2\_id }}”
> 
> state: absent

I’m running Ansible 2.0.0-beta.  
I run the playbook using this from my local laptop:

> ansible-playbook -i china\_aws\_inventory/ec2.py roles/terminate\_environment.yml -e “env=goji” --limit tag\_Environment\_goji -vvvv
> 
> Using /Users/Etherdaemon/personal/coderepos/ansible/ansible.cfg as config file
> 
> 2 plays in roles/terminate\_environment.yml
> 
> Loaded callback default of type stdout, v2.0
> 
> PLAY [Find instances] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK [Create group] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> changed: [10.237.3.62] =\> {“add\_group”: “mark\_terminate”, “changed”: true}
> 
> PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK [Terminate instance(s)] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
> 
> 10.237.3.62 EXEC (umask 22 && mkdir -p “$HOME/.ansible/tmp/ansible-tmp-1445473215.44-14684358660357” && echo “$HOME/.ansible/tmp/ansible-tmp-1445473215.44-14684358660357”)
> 
> 10.237.3.62 PUT /var/folders/vh/rdc7pnkj2kz6vs9vhb844c480000gn/T/tmpCoE5zB TO /Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445473215.44-14684358660357/ec2
> 
> 10.237.3.62 EXEC LANG=C LC\_MESSAGES=C LC\_CTYPE=C /usr/bin/python /Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445473215.44-14684358660357/ec2; rm -rf “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445473215.44-14684358660357/” \> /dev/null 2\>&1
> 
> fatal: [10.237.3.62]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “boto required for this module”}
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> 10.237.3.62 : ok=1 changed=1 unreachable=0 failed=1

The part I’m confused about is that I thought connection: local ran the terminate command from my local laptop - not from the remote host I want to terminate? The above output look like it’s trying to run it from the remote??

If I change hosts to localhost in the playbook then I get skipping: no hosts matched when trying to find the instances.

If I run the inventory first using python china\_aws\_inventory/ec2.py --refresh-cache it finds all the instances, but running the play still says skipping due to no hosts found.

I’m running on:

- MAC OSX 10.10.5
- Ansible v2.0.0-0.3.beta1
- boto: 2.38.0

Launch scripts using the same ec2 module and boto profile works fine.

Any help greatly appreciated.

Karen

---

<div class="post-metadata">

**Author:** ![K\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@K\_Cheng](https://forum.ansible.com/u/K_Cheng)\
**Post date:** [October 22, 2015, 1:46am UTC](https://forum.ansible.com/t/ec2-terminate-dynamic-inventory-boto-required-for-this-module/19585/2 "2015-10-22T01:46:02Z")

</div>

Ok looks like a change in behaviour in Ansible v2:

Following playbook in v2 results in this which I think is failing as its trying to run on the remote host:

> TASK [debug msg={{ hostvars[inventory\_hostname][‘ec2\_id’] }}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> ok: [10.237.3.62] =\> {
> 
> “changed”: false,
> 
> “msg”: “i-f2fc90ca”
> 
> }
> 
> TASK [Terminate instances] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> fatal: [10.237.3.62]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “boto required for this module”}

Downgrade to Ansible v1.9.4 and it terminates successfully:

> TASK: [debug msg={{ hostvars[inventory\_hostname][‘ec2\_id’] }}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> ok: [10.237.3.62] =\> {
> 
> “msg”: “i-f2fc90ca”
> 
> }
> 
> msg:
> 
> i-f2fc90ca
> 
> TASK: [Terminate instances] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> changed: [10.237.3.62 → 127.0.0.1]
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> 10.237.3.62 : ok=4 changed=1 unreachable=0 failed=0

Play looks like:
