forked from evolix/ansible-roles
kvm-host: auto deploy ssh public key for other kvm hosts
This commit is contained in:
parent
9f3e4fee60
commit
7fa9c4adf0
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
- include: ssh.yml
|
||||||
- include: packages.yml
|
- include: packages.yml
|
||||||
|
|
||||||
- name: Check if /usr is a partition
|
- name: Check if /usr is a partition
|
||||||
|
|
25
kvm-host/tasks/ssh.yml
Normal file
25
kvm-host/tasks/ssh.yml
Normal 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']}}"
|
Loading…
Reference in a new issue