roles/gitea: support giteaUninstall variable

This commit is contained in:
CPunch 2023-01-21 18:25:02 -06:00
parent e8fe024b77
commit af53eb4637
10 changed files with 94 additions and 45 deletions

View File

@ -18,6 +18,10 @@
- zsh # :D
- python3-certbot-nginx
- name: Grab package facts
package_facts:
manager: auto
- name: Setup zsh
user:
name: "{{ ansible_user }}"

View File

@ -24,7 +24,7 @@
mode: u=rw,g=,o=
# this keypair is trusted under my github account, so it allows my vps to make pushes
# to the main branch of my openpunk repository. (see roles/deadswitchfiles/imdead.sh)
# to the main branch of my openpunk repository. (see roles/deadswitch/files/imdead.sh)
- name: Install ssh priv key
copy:

View File

@ -0,0 +1,3 @@
---
giteaPort: 3000
giteaUninstall: false

View File

@ -1,16 +1,13 @@
---
- name: Check if Gitea is installed
shell: gitea --version
register: validate_gitea
changed_when: no
- name: Add Gitea key && repository
block:
- name: Check for Gitea gpg key
- name: Check for Gitea gpg key
stat:
path: /etc/apt/trusted.gpg.d/morph027-gitea.gpg
register: gitea_key
- name: Install Gitea
block:
- name: Add Gitea key, repository && install
block:
- 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
when: gitea_key.stat.exists == false or gitea_key.stat.mode != "0644"
@ -19,22 +16,48 @@
apt_repository:
filename: morph027-gitea
repo: deb https://packaging.gitlab.io/gitea gitea main
when: '"not found" in validate_gitea.stdout'
- name: Install Gitea
- name: Add Gitea package
package:
name:
- gitea
name: gitea
when: "'gitea' not in ansible_facts.packages"
- name: Configure Gitea
- name: Configure Gitea
template:
src: templates/app.ini
dest: /etc/gitea/app.ini
owner: gitea
force: no # we don't want to kill our existing config D:
- name: Reload Gitea
- name: Reload Gitea
systemd:
name: gitea
enabled: yes
state: started
when: giteaUninstall == false
- name: Uninstall Gitea
block:
- name: Stop Gitea
systemd:
name: gitea
enabled: no
state: stopped
- name: Remove Gitea package
package:
name: gitea
state: absent
- name: Remove Gitea repository
apt_repository:
filename: morph027-gitea
repo: deb https://packaging.gitlab.io/gitea gitea main
state: absent
- name: Remove Gitea key
file:
path: /etc/apt/trusted.gpg.d/morph027-gitea.gpg
state: absent
when: gitea_key.stat.exists == false or gitea_key.stat.mode != "0644"
when: giteaUninstall == true and ('gitea' in ansible_facts.packages)

View File

@ -18,7 +18,7 @@ ROOT = /var/lib/gitea/gitea-repositories
[server]
SSH_DOMAIN = git.{{ domain }}
DOMAIN = git.{{ domain }}
HTTP_PORT = 3000
HTTP_PORT = {{ giteaPort }}
ROOT_URL = https://git.{{ domain }}/
DISABLE_SSH = false
SSH_PORT = 22

View File

@ -0,0 +1,3 @@
---
giteaPort: 3000
giteaUninstall: false

View File

@ -22,6 +22,14 @@
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
force: no
notify: setup nginx
when: giteaPort is defined and giteaUninstall == false
- name: Uninstall nginx config for git.{{ domain }}
file:
path: /etc/nginx/conf.d/git.{{ domain }}.conf
state: absent
notify: setup nginx
when: giteaPort is not defined or (giteaUninstall is defined and giteaUninstall)
- name: Install nginx config for our Hidden Service
template:

View File

@ -1,6 +1,10 @@
---
- name: Setup certbot
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }} -d git.{{ domain }}"
- name: Setup certbot for {{ domain }}
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }}"
- name: Setup certbot for git.{{ domain }}
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d git.{{ domain }}"
when: giteaPort is defined and giteaUninstall == false
- name: Reload Nginx
systemd:

View File

@ -4,7 +4,7 @@ server {
location / {
add_header Permissions-Policy interest-cohort=();
proxy_pass http://localhost:3000;
proxy_pass http://localhost:{{ giteaPort }};
}
client_max_body_size 100M;

22
run.yml
View File

@ -1,6 +1,10 @@
---
- hosts: all
become: yes
vars:
- giteaPort: 3000
- giteaUninstall: false
vars_files:
- group_vars/all.yml
@ -10,12 +14,12 @@
private: no
roles:
- essential
- git
- deadswitch
- firewall
- blog
- gitea
- nginx
- goaccess
- tor
- role: essential
- role: firewall
- role: git
- role: deadswitch
- role: blog
- role: gitea
- role: nginx
- role: goaccess
- role: tor