Hi, I have some tasks in a role that creates .ssh directory, generates a key on one of the servers, copy the public key on local and then run authorized_key module to copy the public key in the other nodes. The problem is that after generating the key with the condition that gets executed only on ha01 host, all other tasks get executed only on host ha01...
- name: Create directory become: yes file: path: "/root/.ssh" state: directory - name: Generate /etc/ssh/ RSA host key become: yes openssh_keypair: path: /root/.ssh/id_rsa type: rsa # command : echo -e 'y\n'|ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C "" -N "" # register: output when: ansible_hostname == 'ha01' - debug: var=output.stdout_lines - name: Copy pub key to local become: yes fetch: src: /root/.ssh/id_rsa.pub dest: /git/cephprep/files/ when: ansible_hostname == 'ha01' - name: Set authorized key took from file become: yes authorized_key: user: root state: present key: "{{ lookup('file', '/git/cephprep/files/ha01/root/.ssh/id_rsa.pub') }}" Also, next yml file gets executed only on ha01 Everything works fine but..only on ha01 -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAOK917RWafm40Xfd2QWN1PNoXOR%3DwUmG5V%2B7VPYunerfkhvKmg%40mail.gmail.com.