简体   繁体   中英

How do I use Ansible to manage Windows Servers?

I'm trying to run an Ansible playbook against a Windows machine and I keep getting the error "UNREACHABLE! => {"changed": false, "msg": "basic: the specified credentials were rejected by the server", "unreachable": true}"

I'm running the command from the Ansible server as: ansible-playbook updates2.yml -i 40.117.253.59,

My playbook looks like this:

---
 - hosts: 40.117.253.59
   vars:
     ansible_user: user
     ansible_password: password
     ansible_connection: winrm
     ansible_winrm_transport: basic
     ansible_port: 5985
     ansible_winrm_server_cert_validation: ignore
   tasks:
   - name: Install all security updates with automatic reboots
     win_updates:
       category_names:
       - SecurityUpdates
       reboot: yes

I have verified that the username/password are correct, winrm is enabled on the target Windows machine and I've disabled the Windows firewall. Any help would be greatly appreciated.

Thanks in advance

Everything seems to be correct only. Try logging in to the server using RDP and see if you are able to login. That will prove if your credentials are correct. Next is to check if you have the port enabled. Also if your system is higher that windows 2007 then use the port 5986

在 PowerShell 中,运行以下命令:

winrm set winrm/config/service '@{AllowUnencrypted="true"}'

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