diff --git a/tasks/deploy_certificate.yml b/tasks/deploy_certificate.yml index cfae61f..c2da41c 100644 --- a/tasks/deploy_certificate.yml +++ b/tasks/deploy_certificate.yml @@ -12,21 +12,21 @@ - name: Generate SSH user certificate command: cmd: "ssh -o ConnectTimeout=3 -o ConnectionAttempts=2 {{ ssh_ca_host }} '{{ ssh_ca_script }} user {{ item.signing_key }} \"{{ key_pair.public_key }}\" {{ item.host }} \"{{ item.principals }}\"'" - register: certificate + register: user_cert delegate_to: localhost when: item.type == "user" and not cert_stat.stat.exists - name: Generate SSH host certificate command: cmd: "ssh -o ConnectTimeout=3 -o ConnectionAttempts=2 {{ ssh_ca_host }} '{{ ssh_ca_script }} host {{ item.signing_key }} \"{{ key_pair.public_key }}\" {{ item.host }}'" - register: certificate + register: host_cert delegate_to: localhost when: item.type == "host" and not cert_stat.stat.exists - name: Place certificate copy: dest: "/etc/ssh/{{ item.name }}-cert.pub" - content: "{{ certificate.stdout }}" + content: "{{ (item.type == 'user') | ternary(user_cert.stdout, host_cert.stdout) }}" mode: 0644 when: not cert_stat.stat.exists