Hmm, that was what I thought I wanted, but using that value for the API
call was refused as it was not valid JSON.
On Monday, January 20, 2014 8:36:43 AM UTC-6, James Cammarata wrote:
>
> Escape those braces:
>
> - set_fact: >
> sshkey_json='\{"text": "{{public_key_contents.stdout}}"\}'
>
> results in:
>
> TASK: [debug var=sshkey_json]
> *************************************************
> ok: [127.0.0.1] => {
> "sshkey_json": "\\{\"text\": \"ssh-rsa blahblah comment\"\\}"
> }
>
> Which I think is what you want.
>
>
> On Sun, Jan 19, 2014 at 8:55 PM, <[email protected] <javascript:>> wrote:
>
>> An API that I use accepts only JSON. I'm creating what I need with
>> set_fact, which I'll later use with the uri module. However, the curly
>> braces are getting interpreted as a dictionary or something.
>>
>> Here's my playbook:
>>
>>
>>
>> ---
>> - name: Create server
>> gather_facts: no
>> hosts: local
>>
>> tasks:
>> - command: cat /home/jim/.ssh/id_rsa.pub
>> register: public_key_contents
>> - set_fact: >
>> sshkey_json='{"text": "{{public_key_contents.stdout}}"}'
>> - debug: var=sshkey_json
>>
>>
>>
>>
>> The results of this are:
>>
>>
>>
>> TASK: [debug var=sshkey_json]
>> *************************************************
>> ok: [localhost] => {
>> "sshkey_json": *{*
>> "text": "ssh-rsa blahblah jim"
>> *}*
>> }
>>
>>
>> The red, bolded quotes should be part of the string but it seems like
>> they are not. How can I accomplish this?
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
>
> James Cammarata <[email protected] <javascript:>>
> Sr. Software Engineer, AnsibleWorks, Inc.
> http://www.ansibleworks.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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.