我的Ansible语法有什么愚蠢的?当我调用list_item时,我被告知它不存在

Jos*_*ard 2 yaml ansible

所以我试图简单地返回'/ opt/omeka/apps'/但是尽管在前面的语句中返回调试语句返回我正在寻找的内容,但我得到的答案是它不存在.

我假设这里有一个愚蠢的语法错误,只是寻找纠正.

var.yml

omeka_cache_base: /opt/omeka
omeka_cache:
  - app: "{{ omeka_cache_base }}/apps"
  - plugins: "{{ omeka_cache_base }}/plugins"
  - theme: "{{ omeka_cache_base }}/themes"
Run Code Online (Sandbox Code Playgroud)

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 }}"
Run Code Online (Sandbox Code Playgroud)

Ansible返回

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'"}
Run Code Online (Sandbox Code Playgroud)

Mil*_*eek 5

你创建了一个列表,当你想要的是一个字典.尝试将这样的var存储起来.

omeka_cache:
  app: "{{ omeka_cache_base }}/apps"
  plugins: "{{ omeka_cache_base }}/plugins"
  theme: "{{ omeka_cache_base }}/themes"
Run Code Online (Sandbox Code Playgroud)

然后"{{ omeka_cache.app }}"应该工作