But I used become: in my main.yml Would that have root access?
On Wed, Jul 20, 2022 at 3:13 PM David Logan <[email protected]> wrote: > Usually the .ssh/authorized_key file has fairly specific permissions (rw > user only) as does the .ssh directory. It may well be the ansible user > cannot see the files in the .ssh directory as it may not have the correct > permissions. > > On Thu, 21 Jul 2022 at 07:37, Tony Wong <[email protected]> wrote: > >> now different error >> >> TASK [rancherpocreplay : Setup authkeys for user rke] >> ****************************************************** >> [WARNING]: Unable to find '/home/rke/.ssh/id_rsa.pub' in expected paths >> (use -vvvvv to see paths) >> fatal: [k8master]: FAILED! => {"msg": "An unhandled exception occurred >> while running the lookup plugin 'file'. Error was a <class >> 'ansible.errors.AnsibleError'>, original message: could not locate file in >> lookup: /home/rke/.ssh/id_rsa.pub"} >> [WARNING]: Unable to find '/home/rke/.ssh/id_rsa.pub' in expected paths >> (use -vvvvv to see paths) >> fatal: [k8node01]: FAILED! => {"msg": "An unhandled exception occurred >> while running the lookup plugin 'file'. Error was a <class >> 'ansible.errors.AnsibleError'>, original message: could not locate file in >> lookup: /home/rke/.ssh/id_rsa.pub"} >> [WARNING]: Unable to find '/home/rke/.ssh/id_rsa.pub' in expected paths >> (use -vvvvv to see paths) >> fatal: [k8node02]: FAILED! => {"msg": "An unhandled exception occurred >> while running the lookup plugin 'file'. Error was a <class >> 'ansible.errors.AnsibleError'>, original message: could not locate file in >> lookup: /home/rke/.ssh/id_rsa.pub"} >> >> but /home/rke/.ssh/id_rsa.pub is there on the ansible host >> >> On Wed, Jul 20, 2022 at 2:50 PM Todd Lewis <[email protected]> wrote: >> >>> 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 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/ae4c2b44-f45e-4be7-b196-1c6b17903aaen%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/ae4c2b44-f45e-4be7-b196-1c6b17903aaen%40googlegroups.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/CALmkhkrzxV3F7%2BRdu7Z8OTe2R6VqmNqUQyC6yUi3ULH8BDweSg%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CALmkhkrzxV3F7%2BRdu7Z8OTe2R6VqmNqUQyC6yUi3ULH8BDweSg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > if in trouble, or in doubt > run in circles, scream and shout > > -- > 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/CA%2B8iFp7EjSBF3dNEPC%2BYCx0C0o_GkyFOPxrVveZK7uezuPpMyA%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CA%2B8iFp7EjSBF3dNEPC%2BYCx0C0o_GkyFOPxrVveZK7uezuPpMyA%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/CALmkhkrbWMCpEkJChtohbr5nP4cd-s6pLQAmHYzfdKZrroc7Wg%40mail.gmail.com.
