Get ssh fingerprints and add condition for uploading the SSH key
This commit is contained in:
parent
6587f1621a
commit
665ef414a0
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue