# Create an ec2 instance failed with ec2: error: unrecognized arguments

**URL:** <https://forum.ansible.com/t/create-an-ec2-instance-failed-with-ec2-error-unrecognized-arguments/17583>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 20, 2015, 9:52pm UTC](https://forum.ansible.com/t/create-an-ec2-instance-failed-with-ec2-error-unrecognized-arguments/17583 "2015-02-20T21:52:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xin\_Yi](https://avatars.discourse-cdn.com/v4/letter/x/b782af/32.png) [@Xin\_Yi](https://forum.ansible.com/u/Xin_Yi)\
**Post date:** [February 20, 2015, 9:52pm UTC](https://forum.ansible.com/t/create-an-ec2-instance-failed-with-ec2-error-unrecognized-arguments/17583/1 "2015-02-20T21:52:23Z")

</div>

I am a newbie to the ansible world. I followed your blog, [https://djaodjin.com/blog/deploying-on-ec2-with-ansible.blog.html](https://djaodjin.com/blog/deploying-on-ec2-with-ansible.blog.html), to create a security group and an ec2 instance. The security group is created successfully, but creating ec2 instance is failed by ec2: error: unrecognized arguments: /home/ec2-user/.ansible/tmp/ansible-tmp-14244… I did set up aws credentials and asnsible variables properly as below

# AWS Credentials

export AWS\_ACCESS\_KEY\_ID=xxx  
export AWS\_SECRET\_ACCESS\_KEY=xxx

# EC2 Environment Variables

export ANSIBLE\_HOSTS=/etc/ansible/ec2.py  
export EC2\_INI\_PATH=/etc/ansible/ec2.ini

The files and output are showed as follow. Any ideas for this issue? Thanks for your Help!

```auto
$ cat group_vars/all

```

# Variables listed here are applicable to all host groups

key\_name: sobrr-staging.pem  
aws\_region: cn-north-1  
ami\_id: ami-9e0c9ea7  
instance\_type: m1.small

```auto
$ cat basic-create.yml

```

# Basic provisioning example

- name: Create AWS resources  
hosts: localhost  
connection: local  
gather\_facts: False  
tasks:

- name: Create security group  
ec2\_group:  
name: my-security-group  
description: “A Security group”  
region: “{{aws\_region}}”  
rules:

- proto: tcp  
type: ssh  
from\_port: 22  
to\_port: 22  
cidr\_ip: [0.0.0.0/0](http://0.0.0.0/0)  
rules\_egress:

- proto: all  
type: all  
cidr\_ip: [0.0.0.0/0](http://0.0.0.0/0)  
register: basic\_firewall

- name: debug basic\_firewall  
debug: ‘msg=“{{ basic\_firewall }}”’

- name: create an EC2 instance  
local\_action:  
module: ec2  
key\_name: “{{key\_name}}”  
region: “{{aws\_region}}”  
group\_id: “{{basic\_firewall.group\_id}}”  
instance\_type: “{{instance\_type}}”  
image: “{{ami\_id}}”  
count: 1  
wait: yes  
register: basic\_ec2

- name: debug instance start  
debug: ‘msg=“{{ basic\_ec2 }}”’

OUTPUT

ansible-playbook -i /etc/ansible/hosts -vvvv basic-create.yml  
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz\_powm\_sec. You should rebuild using libgmp \>= 5 to avoid timing attack vulnerability.  
\_warn(“Not using mpz\_powm\_sec. You should rebuild using libgmp \>= 5 to avoid timing attack vulnerability.”, PowmInsecureWarning)

PLAY [Create AWS resources] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [Create security group] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
 region=cn-north-1 description=A Security group name=my-security-group  
  
  
 u’LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.15-98406246607462/ec2\_group; rm -rf /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.15-98406246607462/ \>/dev/null 2\>&1’]  
ok: [localhost] =\> {“changed”: false, “group\_id”: “sg-63fae101”}

TASK: [debug basic\_firewall] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “{‘invocation’: {‘module\_name’: u’ec2\_group’, ‘module\_args’: ‘’}, ‘changed’: False, ‘group\_id’: ‘sg-63fae101’}”  
}

TASK: [create an EC2 instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<127.0.0.1\> instance\_type=m1.small image=ami-9e0c9ea7 group\_id=sg-63fae101 region=cn-north-1 key\_name=sobrr-staging.pem  
\<127.0.0.1\>  
\<127.0.0.1\>  
\<127.0.0.1\>  
\<127.0.0.1\> u’LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/env python /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.54-184834253412898/ec2 /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.54-184834253412898/arguments; rm -rf /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.54-184834253412898/ \>/dev/null 2\>&1’]  
failed: [localhost → 127.0.0.1] =\> {“failed”: true, “parsed”: false}  
usage: ec2 [-h] [–list] [–host HOST] [–refresh-cache]  
ec2: error: unrecognized arguments: /home/ec2-user/.ansible/tmp/ansible-tmp-1424461765.54-184834253412898/arguments

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/ec2-user/basic-create.retry

localhost : ok=2 changed=0 unreachable=0 failed=1

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [February 21, 2015, 7:21pm UTC](https://forum.ansible.com/t/create-an-ec2-instance-failed-with-ec2-error-unrecognized-arguments/17583/2 "2015-02-21T19:21:00Z")

</div>

For spinning up instances in AWS you don’t need to tell ansible to use the dynamic inventory script. That is something you might want to use later on.  
Try unsetting that environment variable.  
Also, when running the playbook, you are telling it to use the inventory file _/etc/ansible/hosts._ Mind showing us what you have in there?
