Hi Team

   I am creating the NAT instance using Ansible. Below is my code.




# This is the NAT instance for routing traffic and jumphost, etc.
---
  - name: Create the NAT Instance
    ec2:
      region: "{{ vpc_region }}"
      ec2_access_key: "{{ ec2_access_key }}"
      ec2_secret_key: "{{ ec2_secret_key }}"
      keypair: "{{ ec2_keypair }}"
      instance_type: "{{ nat_instance_type }}"
      image: "{{ nat_image }}"
      vpc_subnet_id: "{{ public_subnet }}"
      assign_public_ip: yes
      group: "{{ vpc_name }}_sg_nat"
      source_dest_check: no
      wait: true
      instance_tags:
        Name: "{{ vpc_name }}_nat"
      exact_count: 1
      count_tag:
        Name: "{{ vpc_name }}_nat"
    register: ec2

  - name: Get the routing table entry for the main table
    shell: >
      {{ ec2_bin_path }}/ec2-describe-route-tables -O {{ ec2_access_key }} 
-W {{ ec2_secret_key }} -F vpc-id={{ vpc.vpc_id }} -F 
"association.main=true" | grep ROUTETABLE | awk '{ print $2 }'
    register: main_rtb

  - name: Get the NAT Instance ID and register
    shell: >
      {{ ec2_bin_path }}/ec2-describe-instances -O {{ ec2_access_key }} -W 
{{ ec2_secret_key }} -F vpc-id={{ vpc.vpc_id }} -F 
"instance-state-name=running" | grep "{{ vpc_name }}_nat" | awk '{ print $3 
}'
    register: nat_instance

  - name: Set the gateway to nat interface.
    shell: >
      {{ ec2_bin_path }}/bin/ec2-create-route  -O {{ ec2_access_key }} -W 
{{ ec2_secret_key }} {{ main_rtb.stdout }} -r 0.0.0.0/0 -i {{ 
nat_instance.stdout }}

  - name: update subnet in the route table
    shell: >
      {{ ec2_bin_path }}/ec2-associate-route-table -O {{ ec2_access_key }} 
-W {{ ec2_secret_key }} {{ main_rtb.stdout }} -s {{ private_subnet }}
~





But when i am running this ansible script i am getting the error like.

ERROR:
==========
TASK: [Set the gateway to nat interface.] 
*************************************
<localhost> REMOTE_MODULE command 
/usr/local/ec2-api-tools/bin/ec2-create-route -O AKIAIWPKJNJDBNJ7WFGA -W 
g+64dXvkwkyo6s1cMrQEplC2sFJHT1moPniIPRrD -r 0.0.0.0/0 -i #USE_SHELL
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1460719317.22-268813804589515 && echo 
$HOME/.ansible/tmp/ansible-tmp-1460719317.22-268853804589515']
<localhost> PUT /tmp/tmpJ_xGn2 TO 
/root/.ansible/tmp/ansible-tmp-1460719317.22-268853814589515/command
<localhost> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1460719317.22-268853804589515/command; rm 
-rf /root/.ansible/tmp/ansible-tmp-1460719317.22-268853804589515/ 
>/dev/null 2>&1']
*failed: [localhost] => {"changed": true, "cmd": 
"/usr/local/ec2-api-tools/bin/ec2-create-route -O xxxxxxxxxxxxxxxx -W 
xxxxxxxxxxxxxxxxxxxxxx  -r 0.0.0.0/0 -i", "delta": "0:00:00.140411", "end": 
"2016-04-15 07:21:57.408895", "rc": 1, "start": "2016-04-15 
07:21:57.268484", "warnings": []}*
*stderr: Missing argument for option:i (use -h for usage)*

*FATAL: all hosts have already failed -- aborting*


Please help me to fix this error.




-- 
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/06076ca0-ead7-45a7-92a1-676a26e5a9b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to