roles/gitea: better gitea installation condition

This commit is contained in:
CPunch 2023-01-19 18:03:49 -06:00
parent c6ea8eaf38
commit 3d75ac18e7

View File

@ -1,19 +1,25 @@
--- ---
- name: Check for Gitea gpg key - name: Check if Gitea is installed
shell: gitea --version
register: validate_gitea
changed_when: false
- name: Add Gitea key && repository
block:
- name: Check for Gitea gpg key
stat: stat:
path: /etc/apt/trusted.gpg.d/morph027-gitea.gpg path: /etc/apt/trusted.gpg.d/morph027-gitea.gpg
register: gitea_key register: gitea_key
- name: Add Gitea key && repository
block:
- name: Import Gitea key - name: Import Gitea key
shell: curl -s https://packaging.gitlab.io/gitea/gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/morph027-gitea.gpg --import && sudo chmod 644 /etc/apt/trusted.gpg.d/morph027-gitea.gpg shell: curl -s https://packaging.gitlab.io/gitea/gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/morph027-gitea.gpg --import && sudo chmod 644 /etc/apt/trusted.gpg.d/morph027-gitea.gpg
when: gitea_key.stat.exists == false or gitea_key.stat.mode != "0644"
- name: Add Gitea repository - name: Add Gitea repository
apt_repository: apt_repository:
filename: morph027-gitea filename: morph027-gitea
repo: deb https://packaging.gitlab.io/gitea gitea main repo: deb https://packaging.gitlab.io/gitea gitea main
when: gitea_key.stat.exists == false or gitea_key.stat.mode != "0644" when: '"not found" in validate_gitea.stdout'
- name: Install Gitea - name: Install Gitea
package: package:
@ -22,7 +28,7 @@
- name: Configure Gitea - name: Configure Gitea
template: template:
src: app.ini src: templates/app.ini
dest: /etc/gitea/app.ini dest: /etc/gitea/app.ini
owner: gitea owner: gitea
force: no # we don't want to kill our existing config D: force: no # we don't want to kill our existing config D: