Ansible win_file模块注册结果
问题描述:
我正在使用win_file Ansible模块在Windows 2012 R2服务器上创建目录和文件。我想注册win_file任务的结果,但是我无法使其工作。Ansible win_file模块注册结果
例如这个剧本......
---
- hosts: windows_server
gather_facts: no
- name: create directory on remote windows server
win_file:
path: 'c:\temp}'
state: directory
register: task_results
debug: var=task_results
...不打印任务的结果。
任何帮助将不胜感激。
答
你的剧本语法是有缺陷的...试试这个:
---
- hosts: windows_server
gather_facts: no
tasks:
- name: create directory on remote windows server
win_file:
path: 'c:\temp'
state: directory
register: task_results
- debug: var=task_results
register
是任务不模块的参数的一部分,所以应该具有相同的缩进。 debug
是一个新的任务,所以它应该是一个列表中的另一个项目。
您的示例中也没有tasks
关键字。