在Ansible中,如何在另一个列表循环中生成列表?

时间:2018-09-10 21:42:15

标签: ansible jinja2

以下是我的脚本,用于循环定义新列表。

 - name: "Set test result into list"
  set_fact:
    testList: "{{ testList|default([]) + [{'url': 'https://artifacts.com/artifactory/{{item}}.{{build_version}}.zip','name': '{{item}}.zip'}] }}"
  with_items: 
    - "test1"
    - "test2"
    - "test3"

下面是结果

changed: [localhost] => (item={'url': u'https://artifacts.com/artifactory/test2.12.1.81.zip', 'name': u'test2.zip'})
changed: [localhost] => (item={'url': u'https://artifacts.com/artifactory/{{item}}.{{build_version}}.zip', 'name': u'{{item}}.zip'})
changed: [localhost] => (item={'url': u'https://artifacts.com/artifactory/{{item}}.{{build_version}}.zip', 'name': u'{{item}}.zip'})

0 个答案:

没有答案