Generate SSH keys for git and use gitea's API to push the public key

This commit is contained in:
flyingscorpio@clevo 2022-10-01 01:40:20 +02:00
parent bf5d668fae
commit 6587f1621a

View file

@ -207,3 +207,26 @@
src: gitea-backup.cron
dest: /etc/cron.d/gitea-backup
mode: 0644
- name: Generate SSH keys for git
become: true
become_user: git
openssh_keypair:
path: ~/.ssh/id_rsa
type: rsa
comment: "git@{{ ansible_fqdn }}"
register: ssh_key
- name: Add SSH key using Gitea's API
uri:
url: https://git.tunuifranken.info/api/v1/user/keys
method: POST
user: "{{ gitea_user }}"
password: "{{ gitea_pass }}"
force_basic_auth: true
status_code: 201
body_format: json
body:
key: "{{ ssh_key.public_key | trim }}"
read_only: false
title: "{{ ssh_key.comment | trim }}"