Created
November 24, 2015 00:48
-
-
Save bsanders/5b147a1344cb204f900b to your computer and use it in GitHub Desktop.
psuedo-ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have all my hosts' public keys in a local directory ./keys/hosts/*pub | |
# I want to use the known_hosts module to add these to 'server' | |
# I'd prefer to just add the key to that local dir, and ansible just glob it up automatically | |
- hosts: server | |
vars: | |
# this is the part I'd like to do automatically; | |
# just loop over everything in "keys/hosts/" without explicitly repeating each file | |
ssh_pub_keys: | |
- name: host1 | |
key: "{{ lookup('file', 'keys/hosts/host1.pub') }}" | |
- name: host2 | |
key: "{{ lookup('file', 'keys/hosts/host2.pub') }}" | |
#- name: et cetera... | |
# .... | |
tasks: | |
- name: Add host pub key to server | |
known_hosts: | |
name: "{{ item.name }}" | |
key: "{{ item.key }}" | |
with_items: ssh_pub_keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment