"/bin/sh: 1: powershell: not found\n"

瀏覽次數:5,234 次
跳到第一則未讀訊息

ali.k...@aurea.com

未讀,
2018年4月25日 清晨7:01:052018/4/25
收件者:Ansible Project
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] ********************************************************************************************************

TASK [ec2] *************************************************************************************************************************
ok: [localhost]

TASK [add hosts to group] **********************************************************************************************************
changed: [localhost]

TASK [win_domain] ******************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/bin/sh: 1: powershell: not found\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 127}

PLAY RECAP *************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=1


Virasat Khan

未讀,
2018年4月25日 下午4:31:442018/4/25
收件者:ansible...@googlegroups.com
Which version of powershell you have on remotes? Ensure it’s 3.0 and above.

You said you are using winrm, which protocol service you are using, credssp or kerberos?

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5b01e4f8-c9ba-45ce-b015-eca43ff18e71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan Borean

未讀,
2018年4月25日 下午5:18:512018/4/25
收件者:Ansible Project
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.

Thanks

Jordan

ali.khawaja

未讀,
2018年4月25日 下午6:01:312018/4/25
收件者:ansible...@googlegroups.com
This is exactly what I'm doing.  

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?  

Thanks
Ali 

Sent from my Verizon, Samsung Galaxy smartphone
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Jordan Borean

未讀,
2018年4月25日 晚上7:39:072018/4/25
收件者:Ansible Project
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.

Thanks

Jordan

Ali Khawaja

未讀,
2018年4月26日 清晨5:13:032018/4/26
收件者:ansible...@googlegroups.com

Thanks for the pointer.  I’ll take a look at your suggested playbook and reply back.  Thanks Again!

 

Sent from Mail for Windows 10

 

From: Jordan Borean
Sent: Thursday, April 26, 2018 2:39 AM
To: Ansible Project
Subject: Re: [ansible-project] "/bin/sh: 1: powershell: not found\n"

 

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.

Thanks

Jordan

--

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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Ali Khawaja

未讀,
2018年4月29日 凌晨4:27:332018/4/29
收件者:ansible...@googlegroups.com

Thanks. I had connection=local which I removed and its working fine now.

 

Sent from Mail for Windows 10

 

From: Jordan Borean
Sent: Thursday, April 26, 2018 12:19 AM
To: Ansible Project

--

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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Akshay Kaushik

未讀,
2018年10月27日 凌晨1:04:532018/10/27
收件者:Ansible Project
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:
     - secret.yml

  tasks:
  - name: ensure instances are running
    ec2:
      aws_access_key: " "
      aws_secret_key: " "
      key_name: " "
      region: " "
      image: "ami-050202fb72f001b47"
      instance_type: t2.micro
      group_id: "sg-00cfe7b7ee9a5aea8"
      wait: yes
      wait_timeout: 500
      exact_count: 1
      vpc_subnet_id: " "
      instance_profile_name: " "
      count_tag:
        Name: win-ami
      instance_tags:
        Name: win-ami
      user_data: "{{ lookup('template', 'userdata.txt.j2') }}"
    register: ec2_result

  - name: ensure Automation_Anywhere_Enterprise_Client is installed via win_package
    win_package:
      path: C:\Windows\Temp\Automation_Anywhere_Enterprise_Client_10.7.0.exe
      product_id: Autmation_Anywhere_Enterprise_Client
      state: present


Thanks and Regards,
Akshay Kaushik

Jordan Borean

未讀,
2018年10月27日 上午8:44:042018/10/27
收件者:Ansible Project
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.

Akshay Kaushik

未讀,
2018年11月10日 上午8:12:122018/11/10
收件者:Ansible Project


On Saturday, October 27, 2018 at 6:14:04 PM UTC+5:30, Jordan Borean wrote:
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.

Hi,

Sorry for late response. Below is my host file:-

[win]

localhost ansible_connection=local

[win:vars]
ansible_connection=winrm
ansible_ssh_port=5986
ansible_ssh_user=Administrator
ansible_ssh_pass={{  }}
ansible_winrm_server_cert_validation=ignore


Please see and tell what i am doing wrong.

訊息已遭刪除

Jordan Borean

未讀,
2018年11月11日 下午3:29:272018/11/11
收件者:Ansible Project
There are a few things wrong with that inventory

  • 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

[win]
windows
-hostname

[win:vars]
ansible_user
=Administrator
ansible_password
=...
ansible_port
=5986
ansible_connection
=winrm
ansible_winrm_server_cert_validation
=ignore

This will connect to the host 'windows-hostname' but you can change that to an IP address if you wish.

Thanks

Jordan
回覆所有人
回覆作者
轉寄
0 則新訊息