【发布时间】:2018-02-22 20:18:35
【问题描述】:
我有一个剧本,它在 Windows 框上执行一个脚本,该脚本返回一个值,我必须稍后在切换到本地主机后在我的剧本中重复使用。 切换回 localhost 后如何访问此值。 这是一个例子:
hosts: localhost
connection: local
gather_facts: no
tasks:
.
.
.
hosts: windows
gather_facts: no
tasks:
- name: Call PowerShell script
win_command: "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe c:\\psl_scripts\\getData.ps1"
register: value_to_reuse
hosts: localhost
gather_facts: no
connection: local
tasks:
- name: debug store_name from windows host
debug:
var: "{{ hostvars[windows][value_to_reuse][stdout_lines] }}"
从其他主机访问变量的正确语法是什么? 我收到错误消息:“msg”:“任务包含一个带有未定义变量的选项。错误是:'windows' 未定义
【问题讨论】:
标签: ansible