Hello, There could be a few things not correctly configured or missed that could result into below error:
First and foremost, while installing Ansible, did you resolve dependencies for paramiko, PyYAML, Jinja2 and httplib2 packages? If not, you may execute below commands on the linux machine with Ansible installation. 1. $ sudo pip install paramiko PyYAML Jinja2 httplib2 2. $ pip install "pywinrm>=0.1.1" 3. $ pip install http://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrm Secondly, verify that the version of Microsoft.NET Framework is 4.0 or later. If not you may follow below steps to get it upgraded. 1. Click on Start -> Control Panel -> Program and Features -> Add or Remove Programs. 2. Scroll down to the M's and look for Microsoft .NET Framework. If you don't have version 4.0 or later, download and install it from here “ https://www.microsoft.com/en-us/download/details.aspx?id=30653”. Thirdly, the ansible_user used in windows.yml file should have admin privileges on remote windows machine to make connection to PowerShell. You may follow below steps to grant admin privileges to the user, if not provided already. 1. Click on Start -> Control Panel -> User Accounts -> Manage User Accounts. 2. Select your new account and click on Properties. 3. Click on the Group Membership tab and change the Group Membership from Standard User to Administrator. 4. Click OK, OK and Close. Restart computer. *Note*:- The remote computer need not be logged into this account for Ansible to make a remote connection to PowerShell, but the account must exist. Last but not the least, you need to execute a PowerShell script in order to enable WinRM/PS Remoting. Below are the steps to be followed. 1. Start PowerShell and run the command Set-ExecutionPolicy -ExecutionPolicy Unrestricted 2. Download PowerShell script (named ConfigureRemotingForAnsible.ps1) for enabling WinRM/PSRemoting. You can get the most recent version here: “ https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1”. 3. And then run the PowerShell script : • powershell.exe -File ConfigureRemotingForAnsible.ps1 Pass the -CertValidityDays option to customize the expiration date of the generated certificate: • powershell.exe -File ConfigureRemotingForAnsible.ps1 -CertValidityDays 100 Pass the -EnableCredSSP switch to enable CredSSP as an authentication option: • powershell.exe -File ConfigureRemotingForAnsible.ps1 –EnableCredSSP Pass the -ForceNewSSLCert switch to force a new SSL certificate to be attached to an already existing winrm listener. • powershell.exe -File ConfigureRemotingForAnsible.ps1 –ForceNewSSLCert Pass the -SkipNetworkProfileCheck switch to configure winrm to listen on PUBLIC zone interfaces. • powershell.exe -File ConfigureRemotingForAnsible.ps1 –SkipNetworkProfileCheck Additionally the -Verbose option can be used to get more information on screen about what it is doing • powershell.exe -File ConfigureRemotingForAnsible.ps1 –Verbose Output of this command should be like this: VERBOSE: Verifying WinRM service. VERBOSE: PS Remoting is already enabled. VERBOSE: SSL listener is already active. VERBOSE: Basic auth is already enabled. VERBOSE: Firewall rule already exists to allow WinRM HTTPS. VERBOSE: HTTP: Enabled | HTTPS: Enabled VERBOSE: PS Remoting has been successfully configured for Ansible. 4. Run the PowerShell command Set-ExecutionPolicy -ExecutionPolicy Restricted. 5. Close PowerShell. If all of the above steps are performed correctly, you should get a successful ping-pong from your remote windows node. Thanks Soniya On Tuesday, November 21, 2017 at 7:33:40 PM UTC+5:30, shilpa motghare wrote: > > Guys Need help here I am posting /etc/ansible/hosts file for windows entry > is > [windows] > Lenovo-PC > > Lenovo-PC entry is added in my /etc/hosts file > > AND > > /etc/ansible/windows.yml file is > ansible_user: Administrator > ansible_password: > ansible_port: 5985 > ansible_connection: winrm > ansible_winrm_scheme: http > ansible_winrm_server_cert_validation: ignore > > and run command > ansible windows -m win_ping > > But Still GET ERROR > > Lenovo-PC | UNREACHABLE! => { > "changed": false, > "msg": "Failed to connect to the host via ssh: ssh: connect to host > lenovo-pc port 22: Connection refused\r\n", > "unreachable": true > } > > PLEASE HELLPPP!!!!!!!! > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/29d3ae1e-4ee9-456b-9083-9564a287c7ab%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
