Sto cercando di rigenerare le chiavi dell'host ssh su una manciata di server remoti tramite ansible (e ssh-keygen
), ma i file non sembrano essere visualizzati. Il playbook funziona correttamente, ma i file sul telecomando non vengono modificati.
Devo ricorrere al echo -e
pirateria informatica poiché questi telecomandi eseguono Ubuntu 14.04 e non hanno la versione corretta del python-pexpect
disponibile (secondo Ansible).
Cosa mi sto perdendo? Il mio playbook e l'output sono di seguito:
playbook
---
- hosts: all
become: true
gather_facts: false
tasks:
- name: Generate /etc/ssh/ RSA host key
command : echo -e 'y\n'|ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C "" -N ""
register: output
- debug: var=output.stdout_lines
- name: Generate /etc/ssh/ DSA host key
command : echo -e 'y\n'|ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C "" -N ""
register: output
- debug: var=output.stdout_lines
- name: Generate /etc/ssh/ ECDSA host key
command : echo -e 'y\n'|ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C "" -N ""
register: output
- debug: var=output.stdout_lines
produzione
$ ansible-playbook ./playbooks/ssh-hostkeys.yml -l myhost.mydom.com,
SUDO password:
PLAY [all] **********************************************************************************************
TASK [Generate /etc/ssh/ RSA host key] ******************************************************************
changed: [myhost.mydom.com]
TASK [debug] ********************************************************************************************
ok: [myhost.mydom.com] => {
"output.stdout_lines": [
"y",
"|ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C -N "
]
}
TASK [Generate /etc/ssh/ DSA host key] ******************************************************************
changed: [myhost.mydom.com]
TASK [debug] ********************************************************************************************
ok: [myhost.mydom.com] => {
"output.stdout_lines": [
"y",
"|ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C -N "
]
}
TASK [Generate /etc/ssh/ ECDSA host key] ****************************************************************
changed: [myhost.mydom.com]
TASK [debug] ********************************************************************************************
ok: [myhost.mydom.com] => {
"output.stdout_lines": [
"y",
"|ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C -N "
]
}
PLAY RECAP **********************************************************************************************
myhost.mydom.com : ok=6 changed=3 unreachable=0 failed=0