Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
Yes My next take is to run rke up pointing to yaml file on my ansible host as rke user Will see how it goes On Fri, Jul 22, 2022 at 3:23 PM John Petro wrote: > glad to hear that you got it working. Now on to the next thing, right? > hehe > > --John > > On Fri, Jul 22, 2022, 6:20 PM Tony Wong

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread John Petro
glad to hear that you got it working. Now on to the next thing, right? hehe --John On Fri, Jul 22, 2022, 6:20 PM Tony Wong wrote: > ok finally got it working. Thanks all for your help > > --- > # tasks file for createuser > - include_vars: >dir: vars > >#- name: copy id_rsa.pub to tmp

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
ok finally got it working. Thanks all for your help --- # tasks file for createuser - include_vars: dir: vars #- name: copy id_rsa.pub to tmp for reading #ansible.builtin.shell: # cmd: "{{ command2 }}" #register: shell_output #become: true #delegate_to: localhost - name: rea

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
ok now getting different error ASK [rancherpocreplay : Setup authkeys for user rke] [WARNING]: The value {'content': 'c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCZ1FERjhsU

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread John Petro
The one thing I will add to this, is that if you are using ansible 2.9.x, make sure you are looking at that version of the docs. Some of the problems you might be having could be from exactly what Todd was getting at. This goes for the module that was suggested to you earlier for this task. ( the

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Todd Lewis
The error message is pretty clear: the command module doesn't have a "cmd" parameter. (Then it helpfully lists the parameters it does have.) You could say ansible.builtin.shell: "{{ command2 }}" But Brian already gave you a solution, which I'll repeat here: You either need to run ansible-playb

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
ansible 2.9.6 config file = /etc/ansible/ansible.cfg configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible executable location = /usr/bin/ansible python versi

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread John Petro
What ansible version do you have installed On Fri, Jul 22, 2022 at 2:37 PM Tony Wong wrote: > still failed > > TASK [rancherpocreplay : copy id_rsa.pub to tmp for reading] > * > fatal:

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
still failed TASK [rancherpocreplay : copy id_rsa.pub to tmp for reading] * fatal: [k8master -> localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (command) mod

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread John Petro
just for giggles, have you tried putting a sudo in front of your command? I am not saying this would work, but just curious if maybe the "become" is being honored on the remote site only, so locally it might still be running as whatever local user you are running the ansible playbook as. On Fri, J

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
trying to copy id_rsa.pub for a user (rke) on my ansible controller to authorized_keys on remote hosts I am running ansible playbook as user ansible since ansible user cannt access /home/rke/.ssh, it cannot lookup the pub key I tried elevating privileges on lookup tasks and cannot do it On Fr

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread John Petro
I am sure you have mentioned this before, so forgive me if it's a repeat. I couldn't find the email in my inbox. What is it you are trying to do again? On Fri, Jul 22, 2022 at 2:07 PM Tony Wong wrote: > > trying to do this another way > > - name: copy id_rsa.pub to tmp for reading on localhost

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-22 Thread Tony Wong
trying to do this another way - name: copy id_rsa.pub to tmp for reading on localhost ansible.builtin.shell: cmd: "{{ command2 }}" register: shell_output become: true delegate_to: localhost where command2 is 'cp /home/rke/.ssh/id_rsa.pub /tmp' I am trying to run this only on the an

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Tony Wong
do you mean something like this? --- # tasks file for createuser - include_vars: dir: vars *- name: Get id_rsa.pub from localhost set_fact:auth_key: "{{ lookup('file', '/home/rke/.ssh/id_rsa.pub')}}" delegate_to: localhost* - name: create user rke ansible.builtin.user: name: '

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Dick Visser
On Thu, 21 Jul 2022 at 16:32, Tony Wong wrote: > > yes it does, but the user (ansible) i am running the playbook with even > though it has sudo rights and in root group cant access that folder. Your authorized_keys task is run on the remote host, but using the lookup/file plugin in one of the a

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread John Petro
Sounds like you have a local permissions issue. On Thu, Jul 21, 2022 at 10:32 AM Tony Wong wrote: > yes it does, but the user (ansible) i am running the playbook with even > though it has sudo rights and in root group cant access that folder. > > i tried to copy the id_rsa.pub to /tmp and it wor

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Tony Wong
yes it does, but the user (ansible) i am running the playbook with even though it has sudo rights and in root group cant access that folder. i tried to copy the id_rsa.pub to /tmp and it works On Thu, Jul 21, 2022 at 7:10 AM John Petro wrote: > Does /home/rke/.ssh/id_pub.rsa exist on the host y

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread John Petro
Does /home/rke/.ssh/id_pub.rsa exist on the host you are running the ansible playbook from? Also, what happens if you try to do a ls on that directory as the user that is executing the ansible playbook, are you getting any errors? On Thu, Jul 21, 2022 at 9:09 AM Tony Wong wrote: > [WARNING]: Un

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Tony Wong
[WARNING]: Unable to find '/home/rke/.ssh/id_pub.rsa' in expected paths (use -v to see paths) fatal: [k8master]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'file'. Error was a , original message: could not locate file in lookup: /home/rke/.ssh/id_pub.rsa

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Tony Wong
how do i access to lookup the id_rsa.pub file? The user running ansible playbook has sudo rights on the controller On Wed, Jul 20, 2022 at 4:31 PM Todd Lewis wrote: > It would have root access — on the target machine, but not on the Ansible > controller. > > On Wednesday, July 20, 2022 at 6:24:2

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-21 Thread Tony Wong
main.yml --- - hosts: k8s become: true roles: - rancherpocreplay On Wed, Jul 20, 2022 at 4:35 PM David Logan wrote: > I didn't see the main.yml file and can't comment on your setup. Yes, root > should have access however I'm not sure become would carry over all tasks. > I thought it was task sp

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread David Logan
I didn't see the main.yml file and can't comment on your setup. Yes, root should have access however I'm not sure become would carry over all tasks. I thought it was task specific unless you set it in your group vars https://docs.ansible.com/ansible/latest/user_guide/become.html On Thu, 21 Jul 20

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Todd Lewis
It would have root access — on the target machine, but not on the Ansible controller. On Wednesday, July 20, 2022 at 6:24:24 PM UTC-4 tdub...@gmail.com wrote: > But I used become: in my main.yml > > Would that have root access? > -- You received this message because you are subscribed to the G

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Tony Wong
But I used become: in my main.yml Would that have root access? On Wed, Jul 20, 2022 at 3:13 PM David Logan 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 .ss

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread David Logan
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 wrote: > now different er

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Tony Wong
now different error TASK [rancherpocreplay : Setup authkeys for user rke] ** [WARNING]: Unable to find '/home/rke/.ssh/id_rsa.pub' in expected paths (use -v to see paths) fatal: [k8master]: FAILED! => {"msg": "An unhandled exception occurred

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Todd Lewis
Mustaches never nest. key: "{{ lookup('file', '/home/' ~ username ~ '/.ssh/id_rsa.pub') }}" On Wednesday, July 20, 2022 at 5:37:15 PM UTC-4 tdub...@gmail.com wrote: > tried this way and got same error > > - name: Setup authkeys for user rke > authorized_key: > user: '{{ username }}' >

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Tony Wong
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 wrote: > can i use jinja like this? > > - nam

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Tony Wong
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! => {

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread boncalo mihai
Just did that, you use authorized_key module On Wed, Jul 20, 2022 at 4:24 PM Tony Wong 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 > "An

Re: [ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Dick Visser
1. https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_lookup.html 2. https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html On Wed, 20 Jul 2022 at 15:24, Tony Wong wrote: > > how do I lookup id_rsa.pub on a host and then run ansible pl

[ansible-project] how do i lookup id_rsa.pub on a host and copy it to authorized keys on multiple servers

2022-07-20 Thread Tony Wong
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