简体   繁体   English

Ansible AWS Windows EC2-内部错误:此连接模块不支持通过sudo运行命令

[英]ansible aws windows ec2 - Internal Error: this connection module does not support running commands via sudo

I am getting below error when I am trying to run one playbook which connects to Windows machine hosted on AWS EC2. 当我尝试运行一个连接到AWS EC2上托管的Windows计算机的剧本时,出现以下错误。 I enabled winrm and win_ping worked fine but when I am invoking ansible-playbook I am not sure why it is using sudo as if the target machine is Linux host. 我启用了winrm并且win_ping正常工作,但是当我调用ansible-playbook时,我不确定为什么它使用sudo就像目标计算机是Linux主机一样。

I tried disabling become=True in ansible.cfg but same issue occurred. 我尝试在ansible.cfg中禁用become=True ,但是发生了相同的问题。

Is it compulsory to use ansible_winrm_transport=ntlm for the win_ping to work. 必须使用ansible_winrm_transport=ntlm来使win_ping正常工作。 I feel that is causing this issue. 我认为这是造成此问题的原因。

Any help would be appreciated. 任何帮助,将不胜感激。

fatal: [10.0.150.18]: FAILED! => {"failed": true, "msg": "Internal Error: this connection module does not support running commands via sudo"}

[root@localhost ]# cat ansible.cfg
[defaults]
log_path=/var/log/ansible.log
ansible_winrm_operation_timeout_sec = 200
ansible_winrm_read_timeout_sec = 500

[privilege_escalation]
become=True

[root@localhost ]# ansible --version
ansible 2.2.0.0

[root@localhost ]# cat hosts
[localhost]
localhost ansible_connection=local

[marcel]
10.0.150.18  ansible_user=Administrator ansible_password=xxxxxxxxxx ansible_port=5985 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore ansible_winrm_transport=ntlm

Please add a winhosts file like in below example 请像下面的示例一样添加一个winhosts文件

[winserver]
#192.168.0.69
192.168.0.88
#Mars

[winserver:vars]
ansible_user=Administrator
ansible_password=password
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore

Guess this should work 猜猜这应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM