Filter 尝试筛选带有\u项的项目将导致ansible

Filter 尝试筛选带有\u项的项目将导致ansible,filter,ansible,jinja2,docker-image,Filter,Ansible,Jinja2,Docker Image,伙计们。我试图找到一个有效的答案,但失败了; 我们正在将docker映像加载到虚拟机。我们希望调试出每个操作的.actions列表,而无需硬编码响应列表。 有人知道怎么做吗 以下是我们目前的代码: --- - name: 'Debbug images to pull' debug: var: required_images - name: 'Pull docker images so that we have them pre-loaded' docker_image:

伙计们。我试图找到一个有效的答案,但失败了; 我们正在将docker映像加载到虚拟机。我们希望调试出每个操作的
.actions
列表,而无需硬编码响应列表。 有人知道怎么做吗

以下是我们目前的代码:

---
- name: 'Debbug images to pull'
  debug:
    var: required_images

- name: 'Pull docker images so that we have them pre-loaded'
  docker_image:
    name: "{{ item.image_name }}:{{ item.image_version }}"
    state: 'present'
  with_items: "{{ required_images }}"
  register: docker_pull_output

- name: 'Confirm images pulled attempt a - this looks righ tbut has the array length hard coded'
  debug:
    var: item
    verbosity: 2
  with_items:
   - "{{ docker_pull_output.results[0].actions }}"
   - "{{ docker_pull_output.results[1].actions }}"
   - "{{ docker_pull_output.results[2].actions }}"
   - "{{ docker_pull_output.results[3].actions }}"
   - "{{ docker_pull_output.results[4].actions }}"

- name: 'Confirm images pulled attempt b - this spams us with the full item, not just the .action property'
  debug:
    var: item.actions
    verbosity: 2
  with_items: "{{ docker_pull_output.results }}"

要获取拉取任务中所有操作的列表,可以使用:

- debug:
    msg: "{{ docker_pull_output.results | json_query('[].actions[]') }}"