i have a simple ansible playbook that i am using to configure some windows machines. i am getting the following error. i have installed powershell. is it the bash shell that is complaining? winrm is configured fine and i have tested it as well. i’ll really appreciate any help with this.
$ ansible-playbook -i winhosts awsenvcfgtest.yml
PLAY [infrastructure setup] ********************************************************************************************************
Without seeing your playbook I don’t know how you are trying to do it but Ansible is trying to connect to localhost with the PowerShell plugin. Usually you need to run the provisioning tasks in 1 play and then the Windows tasks in a separate play. An example of how I did this can be seen here https://github.com/jborean93/ansible-win-demos/blob/master/ec2-win-ami/main.yml. The first play provisions the host in AWS and then adds it into the windows group. The 2nd play then runs on the Windows group which seems to be what you want.
From the error message, it seemed to me that /bin/sh is trying to execute the command ‘powershell’ which it can’t find. On investigating, I found that powershell is invoked through pwsh command.
I created a symbol link named powershell for the pwsh command, and it’s working flawlessly now.
I don’t understand why I had to do all this! Why it’s looking for powershell and not pwsh?
We don’t support PowerShell core (pwsh) and the PowerShell/WinRM is currently only designed for Windows hosts which use PowerShell.exe not pwsh.exe. As I said, the issue you have is that you are running the PowerShell module on the localhost as a local command and not on the Windows host through WinRM like it should be.
i have a simple ansible playbook that i am using to configure some windows machines. i am getting the following error. i have installed powershell. is it the bash shell that is complaining? winrm is configured fine and i have tested it as well. i’ll really appreciate any help with this.
$ ansible-playbook -i winhosts awsenvcfgtest.yml
PLAY [infrastructure setup] ********************************************************************************************************
PLAY RECAP *************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=1
Hi All,
Can anyone help to sort this.I am trying to achieve the installation of a software to a windows instance at provisiong time. Software is deploy but not installed.Below i got the error when running the playbook:-
PLAY [localhost] *******************************************************************************************************************************************************
TASK [ensure instances are running] ************************************************************************************************************************************
changed: [localhost]
TASK [ensure Automation_Anywhere_Enterprise_Client is installed via win_package] ***************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “module_stderr”: “/bin/sh: powershell: command not found\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”, “rc”: 127}
to retry, use: --limit @/root/awswinins.retry
PLAY RECAP *************************************************************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=1
hosts: localhost
gather_facts: no
vars:
target_aws_region: “us-east-1”
vars_files:
You are running the module over SSH with the wrong shell plugin. Ensure this is run with either ‘ansible_connection: winrm’ or ‘ansible_connection: psrp’ so the PowerShell modules work properly.
Change the ansible_ssh_* variables to just ansible_*, e.g. ansible_ssh_port becomes ansible_port and so on
You are defining ansible_connection=winrm on the group but then override that with ansible_connection=local on the host var meaning this will run on the Ansible controller
You have defined the Windows host as localhost, this is quite rare and I’ve only really seen it for WSL installations
Try out the following