# Ansible skipping other hosts

**URL:** <https://forum.ansible.com/t/ansible-skipping-other-hosts/36879>\
**Category:** Ansible Project\
**Created:** [July 20, 2022, 5:36pm UTC](https://forum.ansible.com/t/ansible-skipping-other-hosts/36879 "2022-07-20T17:36:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mboncalo](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@mboncalo](https://forum.ansible.com/u/mboncalo)\
**Post date:** [July 20, 2022, 5:36pm UTC](https://forum.ansible.com/t/ansible-skipping-other-hosts/36879/1 "2022-07-20T17:36:22Z")

</div>

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
