ansible - 如何在ansible中显示两个不同任务寄存器变量的值
问题描述
下面是我的剧本,
---
- hosts: all
tasks:
- name: asyn task 1 use time command to see diff use when hostname to get faster output
command: sleep 15
async: 2
poll: 0
register: result1
- name: asyn task
command: sleep 2
register: result2
- name: showing result1
debug:
var: result1
var1: result2
- name: debugging output
debug: msg=this is the {{ result1 }} and {{ result2 }}
# with_items:
# - {{ result1 }}
# - {{ result2 }}
低于错误,
changed: [vishwa]
TASK [showing result1] **************************************************************************************************
fatal: [rudra]: FAILED! => {"changed": false, "msg": "'var1' is not a valid option in debug"}
fatal: [arya]: FAILED! => {"changed": false, "msg": "'var1' is not a valid option in debug"}
fatal: [vishwa]: FAILED! => {"changed": false, "msg": "'var1' is not a valid option in debug"}
to retry, use: --limit @/home/admin/ansibledemo/asynch.retry
解决方案
- debug 没有参数 var1 或 var。您不能只为模块创建参数。错误信息很清楚。
- 如果您想存储 result1 或 result2 则使用 set_fact 模块。
- 您正在执行在后台运行的异步任务。异步任务发生火灾后忘记执行。该任务将被触发并处于运行状态,而另一个正在被触发。使用 2 https://docs.ansible.com/ansible/latest/modules/async_status_module.html 获取异步任务的结果。
参考:https ://docs.ansible.com/ansible/2.7/user_guide/playbooks_async.html
推荐阅读
- essbase - Essbase 和数据仓库(一般问题)
- javascript - 检测 iframe src 更改 - 外部网站
- reactjs - 虚拟 DOM 和真实 DOM 批量操作间隔
- javascript - Array Slice() 修改原始数组
- javascript - 如何在列表项单击时获取文本?
- sql - 为什么我必须在 2 列上使用 group by?为什么按 1 列分组给我错误?
- python - 如何在窗口的右下角放置一个框架?
- cocoa - 菜单项中的圆形复选标记(可可)
- angular - Angular FormGroup - valuesChanges没有收到下一个值
- c# - 从 Android 库中获取图像到 C#