Get ssh fingerprints and add condition for uploading the SSH key

This commit is contained in:
flyingscorpio@clevo 2022-10-01 11:47:15 +02:00
parent 6587f1621a
commit 665ef414a0

View file

@ -217,6 +217,19 @@
comment: "git@{{ ansible_fqdn }}"
register: ssh_key
- name: Get previously added SSH keys
uri:
url: https://git.tunuifranken.info/api/v1/user/keys
method: GET
user: "{{ gitea_user }}"
password: "{{ gitea_pass }}"
force_basic_auth: true
register: present_ssh_keys
- name: List SSH fingerprints
set_fact:
present_ssh_fingerprints: "{{ present_ssh_keys.json | map(attribute='fingerprint') }}"
- name: Add SSH key using Gitea's API
uri:
url: https://git.tunuifranken.info/api/v1/user/keys
@ -230,3 +243,4 @@
key: "{{ ssh_key.public_key | trim }}"
read_only: false
title: "{{ ssh_key.comment | trim }}"
when: ssh_key.fingerprint not in present_ssh_fingerprints