Why parameterized attribute lookup on ansible variables fail?

16 views
Skip to first unread message

moe_22

unread,
Jul 10, 2017, 11:46:52 AM7/10/17
to Ansible Project
This is best explained by this example:

---
- name: getattr
hosts: 127.0.0.1
connection: local
vars:
  - foo:
       bar: "bar"
       baz: "baz"
  - bee: "bar"
tasks:
  - name: get foo.bar
    debug:
      msg: "{{ foo|attr(bee) }}"

...

This fails, whay?

Brian Coca

unread,
Jul 11, 2017, 1:34:25 PM7/11/17
to Ansible Project
its a dictionary, not an object, the following will get you the result you want:

msg: "{{foo[bee]}}"

----------
Brian Coca

moe_22

unread,
Jul 11, 2017, 7:35:29 PM7/11/17
to Ansible Project

Thanx.
Reply all
Reply to author
Forward
0 new messages