# name 'module' is not defined with s3 module

**URL:** <https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985>\
**Category:** Ansible Project\
**Created:** [August 19, 2014, 9:47pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985 "2014-08-19T21:47:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 19, 2014, 9:47pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/1 "2014-08-19T21:47:04Z")

</div>

When trying to run:

`ansible --inventory /opt/wp/app/hegemon/ansible/hosts.prod --user mozart --private-key /root/.ssh/keys/prod p-backup01 -m s3`

I get the error:

`p-backup01 | FAILED >> { "failed": true, "msg": "Traceback (most recent call last):\n File \"<stdin>\", line 132, in <module>\nNameError: name 'module' is not defined\n", "parsed": false }`

I’ve tested with other modules and it works just fine. I’m running Ansible 1.6.6.

Thanks.

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 19, 2014, 9:53pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/2 "2014-08-19T21:53:13Z")

</div>

I have the same error after upgrading to 1.7.1

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 20, 2014, 1:05pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/3 "2014-08-20T13:05:12Z")

</div>

Please make sure there is a bug filed in GitHub for this, include your ansible version information, and also the line in your playbook that triggered this.

Running the s3 module with no arguments should _not_ be a thing, but we would also not want to present a traceback, and we like to correct tracebacks to human readable errors whenever possible.

You definitely do need to send it some arguments 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 20, 2014, 1:41pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/4 "2014-08-20T13:41:32Z")

</div>

Just to follow up here was my full command.

`/opt/wp/virtualenv/hegemon/bin/ansible --inventory /opt/wp/app/hegemon/ansible/hosts.prod --user mozart --private-key /root/.ssh/keys/prod p-backup01 -m s3 -a "aws_access_key= ******aws_secret_key=****** bucket=wp_confluence_backup src=/backup/confluence mode=put"`

So the bug is that the s3 module doesn’t throw an error of missing args like the file module does:

`-m file p-backup01 | FAILED >> { "failed": true, "msg": "missing required arguments: path" }`

Where as the s3 module does not.

Unfortunately even with the arguments that I pasted above I get the same error as I would get without arguments.

`p-backup01 | FAILED >> { "failed": true, "msg": "Traceback (most recent call last):\n File \"<stdin>\", line 132, in <module>\nNameError: name 'module' is not defined\n", "parsed": false }`

Is this a problem on my end or should I include this in my bug report? (I’m assuming that the s3 module is working for others 😉

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 20, 2014, 3:37pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/5 "2014-08-20T15:37:28Z")

</div>

I’ve opened a Github issue here: [https://github.com/ansible/ansible/issues/8698](https://github.com/ansible/ansible/issues/8698)

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 22, 2014, 5:25pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/6 "2014-08-22T17:25:26Z")

</div>

James Cammarata was kind enough to update the S3 module in the devel branch to handle errors better. Now when I run a command with the S3 module the error returned is:

`p-backup01 | FAILED >> { "failed": true, "msg": "boto required for this module" }`

It seems similar to [this issue](https://groups.google.com/forum/#!msg/ansible-project/ftlmfIC1DHk/ZAQ9Nj4xPLsJ). I exported ANSIBLE\_PYTHON\_INTERPRETER as an environment variable and still received the same error.

`export ANSIBLE_PYTHON_INTERPRETER=/opt/wp/virtualenv/hegemon/bin/python`

I’m using a dynamic inventory so I’m unable to add it there and I would prefer to keep it out of group\_vars. Does any one have any other suggestions?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 22, 2014, 6:32pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/7 "2014-08-22T18:32:10Z")

</div>

This seems like you are possibly having boto installed in a virtualenv and need to set ansible\_python\_interpreter to the python that can find boto.

(Actually you just said this).

A “vars\_file” include of “settings.yml” or a “vars” entry would be reasonable.

If using something like Tower, you can also add variables to the inventory that gets synced from your cloud provider.

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 22, 2014, 7:43pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/8 "2014-08-22T19:43:31Z")

</div>

Unfortunately this is an ad hoc command so there are no vars and I’m not using Tower. What is another way to insert this var into my command?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 22, 2014, 7:50pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/9 "2014-08-22T19:50:44Z")

</div>

-e “ansible\_python\_interpreter=x” on the command line works, though you can actually still use group\_vars/all

Just put this in a directory alongside your inventory script or playbook and it will load as expected.

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 22, 2014, 8:04pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/10 "2014-08-22T20:04:19Z")

</div>

Running an ad hoc command with ansible v1.7.1 returns

`ansible: error: no such option: -e`

ansible-playbook supports -e

Since this is an ad hoc command there are also no playbooks

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 22, 2014, 8:11pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/11 "2014-08-22T20:11:39Z")

</div>

I also tried updating the .ansible.cfg

`  
[defaults]  
host\_key\_checking = false  
legacy\_playbook\_variables = false  
nocows = true  
roles\_path = /opt/wp/app/hegemon/ansible/roles  
transport = ssh  
ansible\_python\_interpreter = /opt/wp/virtualenv/hegemon/bin/python

`

Unfortunately that didn’t help either.

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [August 22, 2014, 8:40pm UTC](https://forum.ansible.com/t/name-module-is-not-defined-with-s3-module/15985/12 "2014-08-22T20:40:15Z")

</div>

I was install boto on the host I was running the command from not the server I was running the command against. After installing boto on the remote server things are working better now. Thank you.
