Problem with resource_tags

111 views
Skip to first unread message

Rahul Mehrotra

unread,
Feb 6, 2015, 3:57:44 PM2/6/15
to ansible...@googlegroups.com
Hi Everyone,
I am trying to create a VPC using Ansible however I am having trouble in tagging resoruces

- name: Create a VPC
      register: vpc
      ec2_vpc:
        state: present
        cidr_block: 10.0.0.0/16
#        resource_tags: { Environmenti: Development }
        subnets:
        - cidr: 10.0.0.0/24
          az: us-east-1a
          resource_tags:
            Name: Development Public Subnet
        - cidr: 10.0.1.0/24
          az: us-east-1b
          resource_tags:
            Name: Development Private Subnet A
        - cidr: 10.0.2.0/24
          az: us-east-1d
          resource_tags:
            Name: Development Private Subnet B
        wait: yes
        region: us-east-1
        internet_gateway: yes



With the above code getting executed successfully, still the subnets dont have the Tag of " Name ", the Tag gets created but its value remains empty


Also If I try to tag the VPC, I get the following error with the below code

- name: Create a VPC
      register: vpc
      ec2_vpc:
        state: present
        cidr_block: 10.0.0.0/16
        resource_tags: { Environmenti: Development }
        subnets:
        - cidr: 10.0.0.0/24
          az: us-east-1a
          resource_tags:
            Name: Development Public Subnet
        - cidr: 10.0.1.0/24
          az: us-east-1b
          resource_tags:
            Name: Development Private Subnet A
        - cidr: 10.0.2.0/24
          az: us-east-1d
          resource_tags:
            Name: Development Private Subnet B
        wait: yes
        region: us-east-1
        internet_gateway: yes


PLAY [local] ****************************************************************** 

TASK: [Create a VPC] ********************************************************** 
failed: [localhost] => {"failed": true}
msg: unsupported parameter for module: resource_tags

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/root/main.retry


Can anyone point out what I am doing wrong.Thank you :)

Dan Vaida

unread,
Feb 9, 2015, 4:27:26 AM2/9/15
to ansible...@googlegroups.com
Try this:

- name: Create a VPC
  local_action:
    module: ec2_vpc
    state: present
    cidr_block: 10.0.0.0/16
    resource_tags: { "Environment": "Development" }
    subnets:
      - cidr: 10.0.0.0/24
        az: us-east-1a
        resource_tags: { "Environment":"Development", "Name" : "Public Subnet" }
      - cidr: 10.0.1.0/24
        az: us-east-1b
        resource_tags: { "Environment":"Development", "Name" : "Private Subnet A" }
      - cidr: 10.0.2.0/24
        az: us-east-1d
        resource_tags: { "Environment":"Development", "Name" : "Private Subnet B" }
    wait: yes
    region: us-east-1
    internet_gateway: yes
  register: vpc

Rahul Mehrotra

unread,
Feb 9, 2015, 1:17:52 PM2/9/15
to ansible...@googlegroups.com
Hi,
Even After trying your suggestion. I am getting the following error

failed: [localhost -> 127.0.0.1] => {"failed": true}
msg: unsupported parameter for module: resource_tags

FATAL: all hosts have already failed -- aborting

This is happening for 

tasks:
    - name: Create a VPC
      register: vpc
Reply all
Reply to author
Forward
0 new messages