fixup! Per Device SSH-Keys
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tobias Manske 2023-09-14 14:54:09 +02:00
parent e6255c76e3
commit 6976503097
Signed by: tobias
GPG Key ID: 9164B527694A0709
2 changed files with 5 additions and 7 deletions

View File

@ -18,18 +18,15 @@
become: false
changed_when: false
register: pubkey
community.crypto.openssl_publickey:
format: OpenSSH
path: "/tmp/{{ inventory_hostname }}.pub"
privatekey_path: "{{ ansible_ssh_private_key_file }}"
return_content: true
ansible.builtin.command:
cmd: "ssh-keygen -y -f {{ ansible_ssh_private_key_file }}"
- name: Deploy Machine SSH-Key
ansible.posix.authorized_key:
user: "{{ ansible_user }}"
state: present
manage_dir: false
path: "/etc/ssh/authorized_keys/{{ ansible_user }}"
key: "{{ pubkey.publickey }} drone-machine-deploy"
key: "{{ pubkey.stdout }}"
- name: Deploy Common SSH-Keys
ansible.posix.authorized_key:
user: "{{ ansible_user }}"

View File

@ -2,6 +2,7 @@
---
- name: Generate SSH Keys
hosts: all
serial: 1
tasks:
- name: Check for ssh key present
shell: "passage machine/{{ inventory_hostname }}/ssh_key"
@ -10,7 +11,7 @@
failed_when: false
changed_when: false
- name: Generate ssh_key
shell: "openssl genpkey -algorithm ed25519 | passage insert --multiline machine/{{ inventory_hostname }}/ssh_key"
shell: "( exec 3>&1 ; ssh-keygen -qt ed25519 -f /proc/self/fd/3 <<<y >/dev/null 2>&1 ) | passage insert --multiline machine/{{ inventory_hostname }}/ssh_key"
delegate_to: localhost
when: ssh_key.rc != 0
register: new_ssh_key