Ok, i may have my answer . https://github.com/ansible/ansible/issues/51604
====
o, the WinRM connection protocol is set to use PowerShell modules, so 
Python modules will not work. A way to bypass this issue to use delegate_to:
 localhost to run a Python module on the Ansible controller. This is useful 
if during a playbook, an external service needs to be contacted and there 
is no equivalent Windows module available.
=======



On Friday, March 8, 2019 at 12:08:05 PM UTC-5, Mehedi Hashir wrote:
>
> The playbook is below. It connects to a windows host and run the installs 
> using Chocolatey successfully.
> Installing npm packages fail in this playbook. The playbook & error is 
> shown at the end of the post .
> Any suggestions.
> Thanks
>
> Mehedi
> ---Playbook---
> - hosts: webservers
>    tasks:
>     - name: openssl  install via Chocolatey
>       win_chocolatey:
>         name: openssl.light
>         status: present
>     - name: nodejs install via Chocolatey
>       win_chocolatey:
>         name: nodejs
>         status: present
>         version: 8.14.1
>     - name: Install edgemicro node.js package globally
>       npm:
>         name: edgemicro
>         global: yes
>         version: 2.5.7
>         state: present
> ---Playbook---
> Here is the error on using the npm module to install packages globally. 
> fatal: [localhost]: FAILED! => 
> {"changed": false, "module_stderr": "Exception calling "Create" with "1" 
> argument(s): "At line:4 char:21 def _ansiballz_main():
>  An expression was expected after '('At line:12 char:27     except 
> (AttributeError, OSError):
> Missing argument in parameter listAt line:14 char:7     if scriptdir is 
> not None:  
> Missing '(' after 'if' in if statementAt line:21 char:7     if 
> sys.version_info < (3,):  
> Missing '(' after 'if' in if statementAt line:21 char:30     if 
> sys.version_info < (3,):  
> Missing expression after ','At line:21 char:25     if sys.version_info < 
> (3,):            
> The '<' operator is reserved for future useAt line:23 char:32 
> MOD_DESC = ('.py', 'U', imp.PY_SOURCE)                             
> Missing expression after ','At line:23 char:33      
> MOD_DESC = ('.py', 'U', imp.PY_SOURCE)                            
> ~~~~~~~~~~~~Unexpected token 'imp.PY_SOURCE' in expression or statementAt 
> line:23 char:32   
> MOD_DESC = ('.py', 'U', imp.PY_SOURCE)                            
> Missing closing ')' in expressionAt line:23 char:46     
> MOD_DESC = ('.py', 'U', imp.PY_SOURCE)                                    
>   
> Unexpected token ')' in expression or statement
> Not all parse errors were reported.  Correct the reported errors and try 
> again."rn
> At line:6 char:1 $exec_wrapper = [ScriptBlock]::Create($split_parts[0])
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
> + CategoryInfo          : NotSpecified: (:) [], 
> MethodInvocationExceptionrn   
> + FullyQualifiedErrorId : ParseExceptionrn rn
> The expression after '&' in a pipeline element produced an object that was 
> not valid. It must result in a command rn
> name, a script block, or a CommandInfo objectAt line:7 char:2 
> &$exec_wrapper  ~~~~~~~~~~~~ 
> + CategoryInfo          : InvalidOperation: (:) [], RuntimeExceptionrn    
> + FullyQualifiedErrorId : BadExpressionrn
> ", "module_stdout": "", "msg": "MODULE FAILUREnSee stdout/stderr for the 
> exact error", "rc": 1}
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to