简体   繁体   中英

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. 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.

I tried disabling become=True in ansible.cfg but same issue occurred.

Is it compulsory to use ansible_winrm_transport=ntlm for the win_ping to work. 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

[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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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