ansible - 如何获取包含任务 --playbook 中每个任务的状态?
问题描述
我在 with_together 循环中作为 ansible playbook 在下面执行,但需要知道定义为 switch-host-config.yaml 的每个任务的状态,但是当我打印寄存器变量“sw_output”时,它没有显示任务结果,它显示了 with_together定义列表...是否有任何方法或方式来识别定义的 switch-host-config.yaml 剧本中的任务状态。
- hosts: "{{ data_sw_ip1 }}"
connection: local
gather_facts: False
tasks:
- name: sw-host task
include_tasks: switch-host-config.yaml
vars:
- nic1_swport: "{{ item.0 }}"
- nic2_swport: "{{ item.1 }}"
- id_host: "{{ item.2}}"
register: sw_output
with_together:
- "{{ nic1_swport1 }}"
- "{{ nic2_swport }}"
- "{{ id_host }}"
ignore_errors: yes
- debug:
msg: "{{ sw_output }}"
解决方案
推荐阅读
- r - 如何将字符向量列表转换为单个向量?
- javascript - HTTP POST 到 Web API 后的 Angular 2+ 确认页面
- node.js - 如何使用 git 部署到测试服务器?
- javascript - 基于传入键的json对象更改值函数
- c# - 在 C# 中按 DateTime 值合并对象
- python - 如何向dict键添加多个值?
- amazon-web-services - 使用备用域名和自定义 SSL 在 CloudFront 后面访问被拒绝的 S3 存储桶
- c++ - 具有多个参数的 masm x64 上的 Printf
- forms - 从一个表单中插入同一个实体 3 次
- arrays - array3d 和 array2d 之间的荒谬性能差异