Hello,
I’ve search here for “programmatic” and had a look at http://docs.ansible.com/faq.html#how-do-i-access-a-variable-name-programatically but remain stumped.
I’ve got these group_vars/all.yml:
applist: [ boldface, taximeter ]
appconf:
boldface:
repo: https://github.com/opyate/twitter-word-source
install_dir: “/opt/apps/boldface”
description: “Twitter Word Source API”
http_port: 3000
https_port: 4440
taximeter:
repo: https://github.com/opyate/taximeter
install_dir: “/opt/apps/taximeter”
description: “Taxi cab fare API as per TFL guidelines”
http_port: 3001
https_port: 4441
I’ve got this task (and many others for these similar apps):
- name: API | Create app dir
file: dest={{appconf[$item][‘install_dir’]}} owner=$ansible_ssh_user group=admin mode=755 state=directory
sudo: yes
tags: api
with_items: “{{applist}}”
I expect it to create /opt/apps/boldface and /opt/apps/taximeter
However, I end up with stuff like this (after trying varying combinations of the ‘dest’ parameter in the task):
r00t@vagrant-ubuntu-saucy-64:~$ ls /home/r00t/*
/home/r00t/{{appconf[+boldface][install_dir]}}:/home/r00t/{{appconf[boldface][‘install_dir’]}}:
/home/r00t/{{appconf[boldface][install_dir]}}:
/home/r00t/{{appconf[+taximeter][install_dir]}}:
/home/r00t/{{appconf[taximeter][‘install_dir’]}}:
/home/r00t/{{appconf[taximeter][install_dir]}}:
/home/r00t/[{‘key’: ‘boldface’}, {‘key’: ‘taximeter’}]:
boldface taximeter
Please let me know what I’m doing wrong.
Thanks,
Juan