Ansible ssh key distribution
---
- hosts: testfileservers
remote_user: devopuser
tasks:
- name: Read variables
include_vars: '{{ item }}'
with_first_found:
- files:
- "{{ inventory_hostname }}.yml"
- "default.yml"
paths: "./vars/"
- name: Deploy SSH-Keys to remote host
authorized_key:
user: functionaccount
key: "{{ keystodeploy|map(attribute='sshkey')|join('\n') }}"
exclusive: true