Mustaches never nest.

key: "{{ lookup('file', '/home/' ~ username ~ '/.ssh/id_rsa.pub') }}"

On Wednesday, July 20, 2022 at 5:37:15 PM UTC-4 [email protected] wrote:

> tried this way and got same error
>
> - name: Setup authkeys for user rke
>   authorized_key:
>     user: '{{ username }}'
>     state: present
>     key: "{{ lookup(‘file’, '/home/{{ username }}/.ssh/id_rsa.pub') }}"
>
>
>
> On Wed, Jul 20, 2022 at 2:12 PM Tony Wong <[email protected]> wrote:
>
>> can i use jinja like this?
>>
>> - name: Setup authkeys for user rke
>>   authorized_key:
>>     user: rke
>>     state: present
>>     key: “{{ lookup(‘file’, ‘{{ authorized_key }}’) }}”
>>
>>
>>
>> keep getting error 
>>
>>
>> Setup authkeys for user rke] *******************************************
>> fatal: [k8master]: FAILED! => {"msg": "template error while templating 
>> string: unexpected char '‘' at 11. String: “{{ lookup(‘file’, ‘{{ 
>> authorized_key }}’) }}”"}
>> fatal: [k8node02]: FAILED! => {"msg": "template error while templating 
>> string: unexpected char '‘' at 11. String: “{{ lookup(‘file’, ‘{{ 
>> authorized_key }}’) }}”"}
>> fatal: [k8node01]: FAILED! => {"msg": "template error while templating 
>> string: unexpected char '‘' at 11. String: “{{ lookup(‘file’, ‘{{ 
>> authorized_key }}’) }}”"}
>>
>>
>>
>> On Wed, Jul 20, 2022 at 10:31 AM boncalo mihai <[email protected]> wrote:
>>
>>> Just did that, you use authorized_key module 
>>>
>>> On Wed, Jul 20, 2022 at 4:24 PM Tony Wong <[email protected]> wrote:
>>>
>>>> how do I lookup id_rsa.pub on a host and then run ansible playbook to 
>>>> copy it to their authorized_key file?
>>>>
>>>>
>>>> -- 
>>>> 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/2994746b-812f-4038-ad58-27d5b0c47been%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ansible-project/2994746b-812f-4038-ad58-27d5b0c47been%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Ansible Project" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/ansible-project/gkaigHAiAC0/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to 
>>> [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/CAOK917Sv42GhE_GR3yo5vxSrYjB9bs-8bHsn9%2BA-4O5tcLNaDA%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/CAOK917Sv42GhE_GR3yo5vxSrYjB9bs-8bHsn9%2BA-4O5tcLNaDA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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/ae4c2b44-f45e-4be7-b196-1c6b17903aaen%40googlegroups.com.

Reply via email to