Reputation: 2749
So I am trying to simply return '/opt/omeka/apps'/ but despite being returned by the debug statement in the prior statement returning what I am looking for I get the responce that it does not exist.
I assume there is a silly syntactical error here and just looking for correction.
var.yml
omeka_cache_base: /opt/omeka
omeka_cache:
- app: "{{ omeka_cache_base }}/apps"
- plugins: "{{ omeka_cache_base }}/plugins"
- theme: "{{ omeka_cache_base }}/themes"
role.yml
- name: debug
debug: var=omeka_cache
- name: download applications files
unarchive:
src: "http://omeka.org/files/omeka-{{ inst.value.version }}.zip"
copy: no
dest: "{{ omeka_cache.app }}"
Ansible Returns
TASK [debug] *******************************************************************
ok: [localhost] => {
"omeka_cache": [
{
"app": "/opt/omeka/apps"
},
{
"plugins": "/opt/omeka/plugins"
},
{
"theme": "/opt/omeka/themes"
}
]
}
TASK [download applications files] *********************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'list object' has no attribute 'app'"}
Upvotes: 2
Views: 64
Reputation: 3137
You have created a list, when what you want is a dict. try storing your var like this instead.
omeka_cache:
app: "{{ omeka_cache_base }}/apps"
plugins: "{{ omeka_cache_base }}/plugins"
theme: "{{ omeka_cache_base }}/themes"
then "{{ omeka_cache.app }}"
should work
Upvotes: 5
Reputation: 13709
It looks to me like there's an array there. Try omeka_cache[0].app
. I used jq to parse your debug, then played around with it to confirm:
>cat t.json
{
"omeka_cache": [
{
"app": "/opt/omeka/apps"
},
{
"plugins": "/opt/omeka/plugins"
},
{
"theme": "/opt/omeka/themes"
}
]
}
>jq < t.json '[.omeka_cache[0].app]'
[
"/opt/omeka/apps"
]
Upvotes: 1