When I try that code I get something different altogether, note the
single dash for the list item:


 ~$ cat /tmp/tempfile
command:
- run: '"somecommand ''somestring'' | awk ''{print $2}''"

    '

But this seems OK as that is what ansible is instructed to do.

So, the better question is what are you trying to do?
What do you want that file to look like - exactly?

Also, you ask for yaml, and when that is emitted, ansible (or the yaml
library) emits whatever is needed to make it valid YAML.


On Mon, 20 Feb 2023 at 16:04, [email protected]
<[email protected]> wrote:
>
> Hello,
>
> having something like this in my playbook
> vars:
>   somevar:
>      command:
>             - run: |
>                     "somecommand 'somestring' | awk '{print $2}'"
>
> tasks:
>    - name: output var to file
>       copy:
>           content: "{{ somevar | to_nice_yaml(sort_keys=false,indent=2) }}"
>            dest: /tmp/tempfile
>
> when I look at /tmp/tempfile it looks like ansible doubles apostrophes:
> command:
>      -- run: '"somecommand ''somestring'' | awk ''{print $2}''"
>
> is there any way to make ansible produce file without extra apostrophes?
>
> thanks.
>
> --
> 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/75403ea8-3d4d-4293-97cf-5ba77cfb1878n%40googlegroups.com.

-- 
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/CAF8BbLYvO5iHAsKqrOaX8iaN9sF67YTLkor3sYBrU%3D%3Ds7Xo_Qg%40mail.gmail.com.

Reply via email to