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