How to run puppet bolt command remotely on Azure Virtual Machine through powershell

284 Views Asked by At

I'm trying to run below puppet bolt command for remote Azure VM through powershell.

bolt command run ipconfig --targets winrm://158.28.0.546 --no-ssl -user testuser123 -password test@84p

getting below error for above command in powershell

Failed on 192.168.0.140:

Timeout after 10 seconds connecting to 192.168.0.140

Failed on 1 target: 192.168.0.140

How to resolve above issue

Update 1:

WinRM enabled on remote Azure Virtual Machine. Even Firewall is disabled on Azure VM for public networks.

enter image description here

After adding DNS name in Azure Portal, I'm getting error as below

Failed to connect to https://testazurevm.westus.cloudapp.azure.com:5986/wsman:

No connection could be made because target machine actively refused it

2

There are 2 best solutions below

0
On BEST ANSWER

For this issue, the error shows a timeout after trying to connect. Generally, it is because the port does not allow you to connect. And there should be two reasons as I know. One is that the firewall does not allow access from the port. Another is that the port does not be listened to.

For you, you can check if the firewall allows the WinRM port and if the WinRM is enabled in the VM.

0
On

Issue fixed after following below steps as given in below article.

https://learn.microsoft.com/en-us/azure/marketplace/cloud-partner-portal/virtual-machine/cpp-configure-winrm-after-vm-creation

  1. Navigate to the blade Virtual machines > > Settings/Networking.
  2. Click on the NSG name to display its properties: Under Settings, select Inbound security rules to display this blade.
  3. Click +Add to create a new rule called WinRM_HTTPS for TCP port 5986.
  4. Click OK when you are finished supplying values.

Configure VM to enable WinRM:

Download and copy below to remote machine. (Get these files from link provided.)

  • ConfigureWinRM.ps1
  • makecert.exe
  • winrmconf.cmd

Run below command in remote vm.

ConfigureWinRM.ps1 <vm-domain-name>