Skip to content

Instantly share code, notes, and snippets.

@zamoose
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zamoose/2d69bc7b31a5458e46d4 to your computer and use it in GitHub Desktop.
Save zamoose/2d69bc7b31a5458e46d4 to your computer and use it in GitHub Desktop.
- name: Register host keys
shell: "ssh-keyscan {{ hostvars[item]['ansible_ssh_host'] }}"
with_flattened:
- "{{ groups['elasticpress'] }}"
- "{{ groups['logstash'] }}"
- "{{ groups['webserver'] }}"
- "{{ groups['mariadb'] }}"
- "{{ groups['nfs-server'] }}"
register: inventory_host_keys
tags: [ 'monitmonit' ]
- name: Add to known_hosts
known_hosts:
host: "{{ hostvars[item.item]['ansible_ssh_host'] }}"
key: "{{ item.stdout }}"
with_items: inventory_host_keys.results
when: "{{ item.stdout }} is defined"
tags: [ 'monitmonit' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment