我只想从yaml执行powershell命令,而无需通过脚本
$("#inq_str_dt").hide();
这项重要的工作
答案 0 :(得分:0)
win_shell模块通过外壳程序运行命令(默认为PowerShell),您应该更加了解yaml文件结构,因为它会导致很多执行问题。有关新项目模块的更多信息,您可以找到here。
---
- hosts: windows
gather_facts: no
tasks:
- name: repo
win_shell: |
New-Item -Path "c:\" -Name "Temp" -ItemType "directory" | New-Item -Path "c:\Temp\" -ItemType "directory" -Name "Script"
args:
executable: cmd
第二个选项(我将命令分为两个任务):
---
- hosts: windows
gather_facts: no
tasks:
- name: Create Temp directory
win_shell: New-Item -Path c:\ -Name Temp -ItemType directory
args:
executable: cmd
- name: Create Temp/Script directory
win_shell: New-Item -Path c:\Temp\ -Name Script -ItemType directory
args:
executable: cmd