ansible 2.3.0: variables in with_items (and ec2_tag module) selectively get not interpreted but taken literally

50 views
Skip to first unread message

hket...@gmail.com

unread,
Oct 19, 2016, 11:07:24 AM10/19/16
to Ansible Project
Hello Everybody,

to explain the odd behaviour, i post a snippet of what i launch via ansible-playbook:

---
  - name: test
    hosts: localhost
    gather_facts: false

    vars:
      tags:
       OS: Debian
       Codename: Jessie
       Name: Test1234

    tasks:
    - name: tag vm
      ec2_tag:
        region: eu-central-1
        resource: i-12345678
        state: present
        tags:
          "{{ item }}" : "{{ tags[item] }}"
      with_items: "{{ tags }}"

# Testing text output debug
    - debug:
        msg: "{{ tags[item] }}"
      with_items: "{{ tags }}"

-cut-

What happens is: Looking into the AWS web console afterwards, shows me:
-Tags-
Key {{ item }}   Value Test1234


So it iterates through the key-value-pairs of tags setting them, but takes the one I marked in bold literally :-)
Am I doing something wrong?
(When doing the same thing with debug-msg, it shows the right thing.)

Many thanks in advance,
Sebastian.

Reply all
Reply to author
Forward
0 new messages