在离线环境中运行 Ansible 2.4.2,使用 kerberos 进行身份验证,
通过 ansible playbook,在提升模式下使用特定(域)用户 DOMAIN\someuser 运行 powershell 脚本的正确语法是什么?
我所说的提升模式是指在 Windows 界面中,我将通过以 DOMAIN\someuser 身份登录来运行脚本,然后右键单击 cmd 或 powershell 提示快捷方式,选择“以管理员身份运行”。
这当然并不意味着我可以使用本地用户“管理员”运行脚本。
我想要运行的是:
powershell.exe -executionpolicy bypass -noninteractive -nologo -file "myscript.ps1"
我在成为.yml 中尝试过:
- name: sigh
win_command: powershell.exe -executionpolicy bypass -noninteractive -nologo -file "myscript.ps1"
become: yes
become_user: DOMAIN\someuser
become_password: someuserpassword
become_method: runas
该脚本运行,但出现与其未在高程中运行相关的错误。
对 win_shell 和 raw 进行了相同的尝试。尝试不使用“become_user”和“become_password”(yml 运行时使用[电子邮件受保护] /cdn-cgi/l/email-protection用户和密码,所以我真的不知道是否需要它)。
我正在拖延这个过程,但没有发现通过变成解决方案的参考:http://docs.ansible.com/ansible/latest/become.html http://docs.ansible.com/ansible/latest/become.html
有任何想法吗?
我执行了以下操作以使其在我的剧本中正常运行:
- name: Run ps1 script in privileged mode
hosts: "{{ my_hosts }}"
become_method: runas
vars:
ansible_become_password: mysupersecretpasswrod
tasks:
- win_shell: '.\myscript.ps1'
become: yes
become_user: Administrator
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)