Error while using variables

73 views
Skip to first unread message

Erick Vitor de Barros

unread,
Nov 5, 2014, 4:06:56 PM11/5/14
to ansible...@googlegroups.com
Hi !

Sorry for this newbie question...but...what is wrong with this?

---
- name: Example of provisioning servers
  hosts: 127.0.0.1
  connection: local
  tasks:
    - name: "Deploying new instances"
      local_action:
        module: ec2
        aws_access_key: THIS IS A SECRET
        aws_secret_key: THIS IS A SECRET
        assign_public_ip: yes
        exact_count: {{ item.count }}
        key_name: search-dev-sa-east-1a
        group_id: sg-00b87865
        region: {{ item.region }}
        zone: {{ item.tag }}
        instance_type: {{ item.type }}
        image: ami-69d26774
        wait: true
        vpc_subnet_id: {{ item.subnet }}
        user_data: "{{ lookup('file', 'userdata_api.txt') }}"
        count_tag:
           search: {{ item.tag }}

        instance_tags:
           Name: search-api-{{ item.tag }}-{{ 200 |random(step=5) }}
           team: search
           env: dev
           search: {{ item.tag }}
           chaordic:role: search
           chaordic:product: search

        volumes:
             - device_name: /dev/sdb
               device_type: io1
               iops: 500
               volume_size: 50
               delete_on_termination: true

      with_items:
        - { region: 'sa-east-1', count: '2', tag: 'search-sa-east-1a', zone: 'a' , type: 't2.micro', subnet: 'subnet-9706efe0' }
        - { region: 'sa-east-1', count: '2', tag: 'search-sa-east-1b', zone: 'b' , type: 't2.micro', subnet: 'subnet-66f22703' }

Thanks in advance.

Matt Martz

unread,
Nov 5, 2014, 4:11:44 PM11/5/14
to ansible...@googlegroups.com
You didn't actually tell us what error you are getting, however I will assume it is that you need to wrap your {{ }} tempting code in quotes.

So instead of:

exact_count: {{ item.count }}

You need:

exact_count: "{{ item.count }}"

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAKz6g-1%2BJhDuBSzq47BLXEr_gPDTOrcT5PFJ6TwXOFUboapxeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Erick Vitor de Barros

unread,
Nov 5, 2014, 9:00:08 PM11/5/14
to ansible...@googlegroups.com
Hey Matt,

you're perfectly right on both affirmations:

1) I've not informed the error
2) The proposed solution worked fine

Thanks so much

Reply all
Reply to author
Forward
0 new messages