Unable to look up dict by key if the dict key contains a variable

15 views
Skip to first unread message

Aneesh Joseph

unread,
Jul 6, 2016, 5:38:29 PM7/6/16
to Ansible Project
vars.yml
---
volumes:
 "vol-1-{{env}}":
   size: 500
   fs: "ext3"

play.yml
- hosts: localhost
  connection
: local
  gather_facts
: no
  vars_files
:
   
- vars.yml
  tasks
:
 
- set_fact:
     volume_name
: "vol-1-{{env}}"
 
- debug: msg='{{ volumes[volume_name].size }}'

ansible-playbook test.yml -e "env=dev1"

 I would expect the above play to output 500, but it fails instead with the below error. Is this the expected behaviour for a dict with variables in the key field? 

 The error was: 'dict object' has no attribute u'vol-1-fut1'


Reply all
Reply to author
Forward
0 new messages