Problem in exuting ConfigureRemotingForAnsible.ps1 in windows 7

I want to exécute in a windows 7 machine to allow connexion with Ansible.

In some Machines I have this error when executing ConfigureRemotingForAnsible.ps1 (as admin) :

PS C:\Users\adminsifast\Documents\Ansible> .\ConfigureRemotingForAnsible.ps1

WinRM has been updated to receive requests.
The type of the WinRM service was successfully modified.

or
(WinRM is already configured to receive this request)

C:\Users\adminsifast\Documents\Ansible\ConfigureRemotingForAnsible.ps1 : Could not establish session on either HTTP or
HTTPS. Breaking
Au caractère Ligne:1 : 1

  • .\ConfigureRemotingForAnsible.ps1
  • CategoryInfo : NotSpecified: (:slight_smile: [Write-Error], WriteErrorException
  • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,ConfigureRemotingForAnsible.ps1

I searched this error but I have not find a solution to it.
for some pc when I execute ConfigureRemotingForAnsible.ps1 I have no problem but on the other the proplem persists.

if you have an idea thank you to orient me, I really need a solution to communicate with Ansible.

thank you

That error is coming from the attempt to connect back to localhost. 'd
made changes to some of the error handling recently; previously the script
would write an error message but continue to run.

Try commenting out line 135 (
https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1#L135)
to let the script continue past the error: Throw "Unable to establish an
HTTP or HTTPS remoting session."

Please let me know if that change works for you.

I found the cause of the error, trying to run this command “enable-psremoting” :

`
PS C:\Users\Administrateur> enable-psremoting

Configuration rapide du service WinRM (Gestion à distance de Windows)
La commande « Set-WSManQuickConfig » s’exécute pour activer l’administration à distance de cet ordinateur via le
service Gestion à distance de Windows.
Cela inclut :

  1. le démarrage ou redémarrage (s’il est déjà démarré) du service Gestion à distance de Windows ;
  2. l’activation du démarrage automatique du service WinRM ;
  3. la création d’un écouteur pour accepter les demandes sur n’importe quelle adresse IP ;
  4. l’activation des exceptions de règles de pare-feu Windows pour le trafic du service Gestion des services Web
    (trafic HTTP uniquement).

Voulez-vous continuer ?
[O] Oui [T] Oui pour tout [N] Non [U] Non pour tout [S] Suspendre [?] Aide (la valeur par défaut est « O ») : O
WinRM est déjà configuré pour recevoir des demandes sur cet ordinateur.
Set-WSManQuickConfig : <f:WSManFault xmlns:f=“http://schemas.microsoft.com/wbem/wsman/1/wsmanfault” Code=“2150859113”
Machine=“localhost”><f:

<f:ProviderFault provider=“Config provider”
path=“%systemroot%\system32\WsmSvc.dll”><f:WSManFault xmlns:f=“http://schemas.microsoft.com/wbem/wsman/1/wsmanfault
Code=“2150859113” Machine=“PC-slim-BH.sifast.infra”><f:Message>L’exception de pare-feu WinRM ne fonctionnera pas car
l’un des types de connexion réseau de cet ordinateur est défini à Public. Changez le type de connexion réseau en
Domaine ou Privé, puis recommencez. (translation: The exception WinRM firewall will not work because
one of the types of network connections of this computer is set to Public. Change the type of network connection
Domain or Private, and then try again) </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
Au caractère Ligne:69 : 17

  • Set-WSManQuickConfig -force
  • CategoryInfo : InvalidOperation : (:slight_smile: [Set-WSManQuickConfig], InvalidOperationException
  • FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

`

``As shown in the error The firewall exception WinRM will not work because one of the types of network connections of thoses computers is set to Public. I due Change the type of network connection Private. I followed the steps in the following link (sorry it’s in French) : http://www.silogix.fr/changer-l’emplacement-réseau-dune-carte-dans-le-centre-réseau-et-partage.aspx

But the error remains in one pc despite the change I made, but in trying to comment out line 135 (https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1#L135) as you told me Chris Church, it’s work for me :smiley:

thank youuu :slight_smile: Chris Church

Hi Chris,

I am getting similar error while running {ConfigureRemotingForAnsible.ps1} on some machines. I tried to look for L135 in the script but that is already a comment. can you please mention the exact line (code) that needs to be commented out?

{ # Create the hashtables of settings to be used.
$valueset = @{} $valueset.Add(‘Hostname’, $SubjectName) $valueset.Add(‘CertificateThumbprint’, $thumbprint)}

Regards,
Fahd

The script has changed a bit since Chris’s message (over a year ago).

Can you confirm you have upgraded to powershell 3 or 4 on the machines before running ConfigureRemotingForAnsible.ps1

It would help if you provide the exact error message.

Hope this helps,

Jon

Hi, I have this issues when I type this command in terminal; ansible -m ping all

192.168.1.2 | UNREACHABLE! => {
     "changed": false,
     "msg": "ssl: HTTPSConnectionPool(host='192.168.1.2', port=5986): Max retries exceeded with url: /wsman(Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f934053f890>, 'Connection to 192.168.1.2 timed out. (connnect timeout=30)'))",
     "unreachable": true
}
192.168.12 | UNREACHABLE! => {
     "changed": false,
     "msg": "Authentication failure.",
     "unreachable": true

I did this steps:
 sudo apt install python-pip
 sudo pip install “pywinrm>=0.1.1”
 sudo apt-get install libkrb5-dev
 sudo pip install kerberos

then edit /etc/ansible/hosts and add this:
[windows]
192.168.1.2

[web]
192.168.1.12

[windows:vars]
ansible_ssh_user="Administrator"
ansible_ssh_pass=123456
ansible_ssh_port=5986
ansible_connection="winrm"
ansible_winrm_server_cert_validation = "ignore"

Next edit /etc/nsible/ansible.cfgs
look for “ask_pass = True” and delete “#”.