寻找如何以提升的权限执行 powershell win_command 的指导。
我的剧本示例:
---
- name: Run powershell script
hosts: win
gather_facts: false
tasks:
- name: windows test command
win_command: powershell.exe -
args:
stdin: ipconfig >> c:\ipconfig.txt
Run Code Online (Sandbox Code Playgroud)
这工作正常,因为它不需要提升权限,但如果我尝试需要 runas 管理员的东西,我似乎无法弄清楚,尝试添加 'become_method: runas' 不走运?
它应该这样工作:
- name: Run powershell script
hosts: win
gather_facts: false
become_method: runas
vars:
ansible_become_password: "{{ password }}"
tasks:
- win_command: powershell.exe -
args:
stdin: ipconfig >> c:\ipconfig.txt
become: yes
become_user: Administrator
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20395 次 |
| 最近记录: |