Hi Stephen,

> > > vault_password: abc(123 
> > > tasks: 
> > >  - name: my-script 
> > >    script: My-Script.ps1 -secret {{ vault_password }} 
> > > 
> > > (Missing closing ')' in expression.:String) []   
> >
> > Use "quote" filter 
> > https://docs.ansible.com/ansible/devel/user_guide/playbooks_filters.html#id8
> >  
> >
> >     - name: my-script 
> >       script: My-Script.ps1 -secret {{ vault_password|quote }} 

On Wed, 23 Oct 2019 00:24:26 -0700 (PDT)
Stephen Feyrer <[email protected]> wrote:
> Apologies for the delayed reply.  Unfortunately, that hasn't worked.  In 
> the documentation that you linked to, that syntax is described in 
> connection with the shell operator rather than the script.
> 
> I tried this:
>  - name: my-script 
>       script: My-Script.ps1 -secret {{ vault_password | quote }}
> and
>  - name: my-script 
>       script: My-Script.ps1 -secret {{ vault_password | join("") }}
> Both produced the same result as before.

This is strange. It works for me. 

    $ cat my-script.sh 
    #!/bin/sh
    echo $1
    exit 0
    
    $ cat play.yml 
    - hosts: localhost
      vars:
        vault_password: abc(123
      tasks:
        - script: 'my-script.sh {{ vault_password|quote }}'
          register: result
        - debug:
            var: result.stdout
    
    $ ansible-playbook play.yml 
    [...]
    ok: [localhost] => {
        "result.stdout": "abc(123\n"
    }

Without quoted argument I see this error:

fatal: [localhost]: FAILED! => {"changed": true, "msg": "non-zero return
code", "rc": 2, "stderr": "/bin/sh: 1: Syntax error: \"(\" unexpected\n",
"stderr_lines": ["/bin/sh: 1: Syntax error: \"(\" unexpected"], "stdout":
"", "stdout_lines": []}

Cheers,

        -vlado

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20191023100718.0358233d%40gmail.com.

Attachment: pgpbzjcArDgbN.pgp
Description: OpenPGP digital signature

Reply via email to