Generate SSH keys for git and use gitea's API to push the public key
This commit is contained in:
parent
bf5d668fae
commit
6587f1621a
1 changed files with 23 additions and 0 deletions
|
@ -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 }}"
|
||||
|
|
Loading…
Reference in a new issue