Hello everyone!

I have a task defined below, that only needs to run on the hosts that are 
within the bastion-hosts group. However, it is also running on hosts that 
are not in the group bastion-hosts.

- name: Fetch user's public cloud key for deploy to internal hosts later
  fetch:
    src: "{{ item.home | default(users_home ~ '/' ~ item.username) 
}}/.ssh/id_{{ item.ssh_key_type | default('rsa') }}.pub"
    dest: {{ files_bastion_cloud_keys_path }}/id_{{ item.ssh_key_type | 
default('rsa') }}-{{ item.username }}.pub
    flat: yes
  when: ("'bastion-hosts' in group_names") and (item.ssh_key_generate is 
defined) and item.ssh_key_generate
  with_items: "{{ users }}"

Could you kindly advise where I might be going wrong?

Regards
JS

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/08a8ecab-c71d-48b1-9f87-1f25a6215c7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to