I am a newbie to the ansible world. I followed your blog, 
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!

$ 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

$ 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
      rules_egress:
        - proto: all
          type: all
          cidr_ip: 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] 
*************************************************
<localhost> region=cn-north-1 description=A Security group 
name=my-security-group
<localhost>
<localhost>
<localhost> 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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e50f59ab-19eb-4f0a-a9cc-3cdac5ea1132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to