kvm-host: auto deploy ssh public key for other kvm hosts

This commit is contained in:
Victor LABORIE 2017-04-24 16:21:08 +02:00
parent 9f3e4fee60
commit 7fa9c4adf0
2 changed files with 26 additions and 0 deletions

View file

@ -1,4 +1,5 @@
---
- include: ssh.yml
- include: packages.yml
- name: Check if /usr is a partition

25
kvm-host/tasks/ssh.yml Normal file
View file

@ -0,0 +1,25 @@
---
- name: Generate root ssh_key
user:
name: root
generate_ssh_key: yes
ssh_key_bits: 2048
- name: Fetch ssh public keys
shell: cat /root/.ssh/id_rsa.pub
register: ssh_keys
always_run: yes
- name: Print ssh public keys
debug:
msg: "{{ ssh_keys.stdout }}"
- name: Autorize other kvm ssh key
authorized_key:
user: root
state: present
key: "{{ item[0] }}"
delegate_to: "{{ item[1] }}"
with_nested:
- "{{ ssh_keys.stdout }}"
- "{{groups['hypervisors']}}"