server-config/roles/init/tasks/ssh-keygen.yml

23 lines
498 B
YAML
Raw Normal View History

---
- name: Verifica presenza directory .ssh
shell: test -d /root/.ssh
register: check_sshdir
ignore_errors: true
- name: Creazione directory .ssh
shell: mkdir -p /root/.ssh
when: check_sshdir|failed
- name: Verifica chiave ssh
shell: test -f /root/.ssh/id_rsa
changed_when: false
ignore_errors: true
register: check_key
- name: Gestione creazione chiave ssh
shell: ssh-keygen -t rsa -b 1024 -f /root/.ssh/id_rsa -N ''
sudo: yes
sudo_user: root
when: check_key|failed