fix no attribute stdout

This commit is contained in:
Pim Kunis 2023-04-26 19:17:40 +02:00
parent 65ea776c21
commit 4f23d12b59

View file

@ -12,21 +12,21 @@
- name: Generate SSH user certificate - name: Generate SSH user certificate
command: 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 }}\"'" 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 delegate_to: localhost
when: item.type == "user" and not cert_stat.stat.exists when: item.type == "user" and not cert_stat.stat.exists
- name: Generate SSH host certificate - name: Generate SSH host certificate
command: 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 }}'" 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 delegate_to: localhost
when: item.type == "host" and not cert_stat.stat.exists when: item.type == "host" and not cert_stat.stat.exists
- name: Place certificate - name: Place certificate
copy: copy:
dest: "/etc/ssh/{{ item.name }}-cert.pub" dest: "/etc/ssh/{{ item.name }}-cert.pub"
content: "{{ certificate.stdout }}" content: "{{ (item.type == 'user') | ternary(user_cert.stdout, host_cert.stdout) }}"
mode: 0644 mode: 0644
when: not cert_stat.stat.exists when: not cert_stat.stat.exists