Answers: <p>You should try adding an entry to your priviledge escalation section.</p>
  
  <p>Set <code>become_method</code> to <code>runas</code>. So in my opinion just change the <code>become_method</code> to <code>runas</code> and it should work just fine.</p>
  
  <p>Do make sure the ports 5985/5986 are opened in the security group from the AWS console and try again. Do post the logs if you can.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-11-13T13:50:40.653Z
Answers: 2019-11-13T13:50:40.653Z
Answers: Vedant Kashyap
Answers: <p>According to <a href="https://docs.ansible.com/ansible/latest/user_guide/become.html#become-and-windows" rel="nofollow noreferrer">the documentation</a>:</p>
  
  <blockquote>
    <p>Prior to Ansible 2.4, become would only work when ansible_winrm_transport was set to either basic or credssp, but since Ansible 2.4 become now works on all transport types.</p>
  </blockquote>
  
  <p>You're using Ansible 2.2. Might that be it? The error message might be a bit misleading.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-02-14T04:05:08.717Z
Answers: if I set `ansible_winrm_transport=basic` then win_ping doesn't work
Answers: user3847894
Answers: CC BY-SA 4.0
Answers: 2019-02-13T08:40:21.073Z
Answers: 2019-02-13T08:40:21.073Z
Answers: bgdnlp
Body: <p>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.</p>
  
  <p>I tried disabling become=True in ansible.cfg but same issue occurred.</p>
  
  <p>Is it compulsory to use ansible_winrm_transport=ntlm for the win_ping to work. I feel that is causing this issue.</p>
  
  <p>Any help would be appreciated.</p>
  
  <pre><code>fatal: [10.0.150.18]: FAILED! =&gt; {"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
  </code></pre>
  
Tags: <ansible><amazon-ec2>
Title: ansible aws windows ec2 - Internal Error: this connection module does not support running commands via sudo
UserDisplayName: user3847894
ThreadText: # ansible aws windows ec2 - Internal Error: this connection module does not support running commands via sudo
  
  (Asked by: username_0 on 2019-02-13)
  
  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
  
  ```
  
  **Tags:** ansible, amazon-ec2
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-11-13. Score: 1
  
  You should try adding an entry to your priviledge escalation section.
  
  Set `become_method` to `runas`. So in my opinion just change the `become_method` to `runas` and it should work just fine.
  
  Do make sure the ports 5985/5986 are opened in the security group from the AWS console and try again. Do post the logs if you can.
  
  
  ---
  
  ### Answer by username_2 on 2019-02-13. Score: 1
  
  According to [the documentation](https://docs.ansible.com/ansible/latest/user_guide/become.html#become-and-windows):
  
  > Prior to Ansible 2.4, become would only work when ansible\_winrm\_transport was set to either basic or credssp, but since Ansible 2.4 become now works on all transport types.
  
  You're using Ansible 2.2. Might that be it? The error message might be a bit misleading.
  
  > **Comments:**
  > **username_0**: if I set `ansible_winrm_transport=basic` then win_ping doesn't work  
  
  ---
  
  