Ansible error "PORT STATE SERVICE 5986/tcp closed wsmans"

Bit-10101

Member
Joined
Nov 30, 2021
Messages
52
Reaction score
8
Credits
442
It´s about Ansible setup and connection to target
I´ve configure this om my client and used Ansible for window10 with wsl:
Less:
[web] server01 [web:vars]
ansible_user="[email protected]"
ansible_password=somepassword
ansible_connection=winrm
ansible_winrm_transport=credssp
ansible_winrm_cert_validation=ignore

And enable CredSSP on target server01
ansible_credssp_listener.JPG


I´ve added svc-ansible account to local administrator group on server01
But when Im trying ansible web -m win_ping from client i receive this ERROR: ansible web -m win_ping
I get this error:
ansible_win_ping_error.JPG




PS. I´ve als done this on my windows 10 client:
Code:
Ansible [core 2.12.0]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
jinja version = 2.10.1
libyaml = True

I´ve scanned with nmap and getting this result:
"PORT STATE SERVICE 5986/tcp closed wsmans"

I hope this is right forum? and really appreciate your answer

:)
 


The part that doesn't make sense here. I've seen this on older distrro's that still use Python 2x.
But the out put of the ansible version shows this to be a fairly recent version with python3.

... unless the client is still on python2 ?
 
python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
jinja version = 2.10.1
libyaml = True
I reinstall python, to see if it works then
 
I´ve reinstall and setup everything by the book

I´m using Ansible for Windows10 with wsl
Now I got two target servers, server-01 and server-02 in my test environment, both windows servers.

When all the setup is finished I´m gonna try to connect to these servers from my client
by this command:
ansible servers -m win_ping:

The host-file on Ansible controller (windows10 - client)
Hosts file:
[servers] server-01 server-02 122.106.11.15 122.106.11.16 [servers:vars] ansible_user="[email protected]" ansible_password=somepassword ansible_connection=winrm ansible_winrm_transport=credssp

Result from ansible servers -m win_ping:

root@client01:/etc/ansible# ansible servers -m win_ping 122.106.11.15 | UNREACHABLE! => { "changed": false, "msg": "credssp: Server did not response with a CredSSP token after step Step 1. TLS Handshake - actual 'Negotiate, Kerberos, CredSSP'", "unreachable": true } server-01 | UNREACHABLE! => { "changed": false, "msg": "credssp: HTTPSConnectionPool(host='server-01', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f779c7416d0>: Failed to establish a new connection: [Errno -5] No address associated with hostname'))", "unreachable": true } 122.106.11.16 | SUCCESS => { "changed": false, "ping": "pong" } server-04 | UNREACHABLE! => { "changed": false, "msg": "credssp: HTTPSConnectionPool(host='server-04', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f779c741850>: Failed to establish a new connection: [Errno -5] No address associated with hostname'))", "unreachable": true }

Kommentar:
As you can see only one server-04 is answering, but only by ip-address and not by DNS.
122.106.11.16 | SUCCESS => { "changed": false, "ping": "pong"

I´ve checked with nmap and ports on both servers are open 5986
PORT STATE SERVICE
5986/tcp open wsmans

Ps.
DNS is working when I´m trying nslookup

-What could possible cause these problems?
 
msg": "credssp: Server did not response with a CredSSP token after step Step 1. TLS Handshake - actual 'Negotiate,
You have this error - Try this - you may have to install pip first

Code:
sudo apt remove -y python3-cryptography
Code:
sudo pip3 install cryptography
 
Ok, but this was the first step I did on my windows client:
sudo apt-get update sudo apt-get python3-pip -y
-Or was it the wrong way to install python?
-I´m just curious, so I know how to do things the right way.
 
Last edited:
Ok, but this was the first step I did on my windows client:
sudo apt-get update sudo apt-get python3-pip -y
-Or was it the wrong way to install python?
-I´m just curious, so I know how to do things the right way.
PIP is tested to work on the latest patch version of the Python interpreter, older versions of Python, and these users should request for support from the relevant provider (eg: Linux distro community, cloud provider support channels, etc). So PIP grabs the latest and greatest
 
I´ve executed:
sudo apt remove -y python3-cryptography
and then:
sudo pip3 install cryptography

I´m totally useless on Linux
Now i got the error message "requires pyOpenSSL" that´s somethings that´s missing.
requires pyOpenSSL.JPG


Really appreciate your answer
:)
 
I´ve executed:
sudo apt remove -y python3-cryptography
and then:
sudo pip3 install cryptography

I´m totally useless on Linux
Now i got the error message "requires pyOpenSSL" that´s somethings that´s missing.
View attachment 11083

Really appreciate your answer
:)
Code:
pip install pyOpenSSL==21.0.0
which is the latest version right now
 
Ok, after that I run from windows client
ansible servers –m win_ping
and this was dispalyed:
Please see the long screenshot below:
(It seems like a lot of hassle before getting started with Ansible.
But I really appreciate your answer.)
:)
message1.JPG

message2.JPG
 
Try running

Code:
ansible winserver -m win_ping

instead of ansible servers -m win_ping - assuming windows is the server
 
Is your Windows build earlier then 16188? if so - in wsl have you already ran the following? If your Windows build is later then you do not need to run the prerequisites below - only if it is earlier
Code:
sudo apt-get update
Code:
sudo apt-get install python-pip git libffi-dev libssl-dev -y
Code:
pip install ansible pywinrm
If you done all that then is is a matter of setting up a playbook - https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html
 
Last edited by a moderator:
But should´nt
ansible winserver -m win_ping
Answer with this:
122.106.11.16 | SUCCESS => { "changed": false, "ping": "pong"
 
I'm not seeing any evidence of there being any Linux in this mix.

What does this have to do with Linux specifically?
 
I'm not seeing any evidence of there being any Linux in this mix.

What does this have to do with Linux specifically?
If you have a look att the first line in this topic:
" It´s about Ansible setup and connection to target
I´ve configure this om my client and used Ansible for window10 with wsl"

WSL is Linux on Windows machine, you can enable this feature Linux Subsystem for Windows.
In other words you can run Linux terminal on Windows Machine.

Or what do you mean by "..What does this have to do with Linux specifically?"
-Can you explain in more detail what you mean?
:)
 
-Can you explain in more detail what you mean?

I was asking for clarification because I received a report concerning this thread. I can't possibly know all things Linux, so asked for clarification.

(Look under my username.)
 

Staff online

Members online


Top