mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-22 07:20:05 +00:00
roles/gitea: support giteaUninstall variable
This commit is contained in:
parent
e8fe024b77
commit
af53eb4637
@ -18,6 +18,10 @@
|
|||||||
- zsh # :D
|
- zsh # :D
|
||||||
- python3-certbot-nginx
|
- python3-certbot-nginx
|
||||||
|
|
||||||
|
- name: Grab package facts
|
||||||
|
package_facts:
|
||||||
|
manager: auto
|
||||||
|
|
||||||
- name: Setup zsh
|
- name: Setup zsh
|
||||||
user:
|
user:
|
||||||
name: "{{ ansible_user }}"
|
name: "{{ ansible_user }}"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
mode: u=rw,g=,o=
|
mode: u=rw,g=,o=
|
||||||
|
|
||||||
# this keypair is trusted under my github account, so it allows my vps to make pushes
|
# 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
|
- name: Install ssh priv key
|
||||||
copy:
|
copy:
|
||||||
|
3
roles/gitea/defaults/main.yml
Normal file
3
roles/gitea/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
giteaPort: 3000
|
||||||
|
giteaUninstall: false
|
@ -1,16 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Check if Gitea is installed
|
- name: Check for Gitea gpg key
|
||||||
shell: gitea --version
|
|
||||||
register: validate_gitea
|
|
||||||
changed_when: no
|
|
||||||
|
|
||||||
- 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: Install Gitea
|
||||||
|
block:
|
||||||
|
- name: Add Gitea key, repository && install
|
||||||
|
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"
|
when: gitea_key.stat.exists == false or gitea_key.stat.mode != "0644"
|
||||||
@ -19,22 +16,48 @@
|
|||||||
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: '"not found" in validate_gitea.stdout'
|
|
||||||
|
|
||||||
- name: Install Gitea
|
- name: Add Gitea package
|
||||||
package:
|
package:
|
||||||
name:
|
name: gitea
|
||||||
- gitea
|
when: "'gitea' not in ansible_facts.packages"
|
||||||
|
|
||||||
- name: Configure Gitea
|
- name: Configure Gitea
|
||||||
template:
|
template:
|
||||||
src: templates/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:
|
||||||
|
|
||||||
- name: Reload Gitea
|
- name: Reload Gitea
|
||||||
systemd:
|
systemd:
|
||||||
name: gitea
|
name: gitea
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
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)
|
@ -18,7 +18,7 @@ ROOT = /var/lib/gitea/gitea-repositories
|
|||||||
[server]
|
[server]
|
||||||
SSH_DOMAIN = git.{{ domain }}
|
SSH_DOMAIN = git.{{ domain }}
|
||||||
DOMAIN = git.{{ domain }}
|
DOMAIN = git.{{ domain }}
|
||||||
HTTP_PORT = 3000
|
HTTP_PORT = {{ giteaPort }}
|
||||||
ROOT_URL = https://git.{{ domain }}/
|
ROOT_URL = https://git.{{ domain }}/
|
||||||
DISABLE_SSH = false
|
DISABLE_SSH = false
|
||||||
SSH_PORT = 22
|
SSH_PORT = 22
|
||||||
|
3
roles/nginx/defaults/main.yml
Normal file
3
roles/nginx/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
giteaPort: 3000
|
||||||
|
giteaUninstall: false
|
@ -22,6 +22,14 @@
|
|||||||
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
notify: setup nginx
|
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
|
- name: Install nginx config for our Hidden Service
|
||||||
template:
|
template:
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Setup certbot
|
- name: Setup certbot for {{ domain }}
|
||||||
shell: "certbot --nginx --non-interactive --agree-tos -m {{ contact_email }} -d {{ domain }} -d git.{{ 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
|
- name: Reload Nginx
|
||||||
systemd:
|
systemd:
|
||||||
|
@ -4,7 +4,7 @@ server {
|
|||||||
|
|
||||||
location / {
|
location / {
|
||||||
add_header Permissions-Policy interest-cohort=();
|
add_header Permissions-Policy interest-cohort=();
|
||||||
proxy_pass http://localhost:3000;
|
proxy_pass http://localhost:{{ giteaPort }};
|
||||||
}
|
}
|
||||||
|
|
||||||
client_max_body_size 100M;
|
client_max_body_size 100M;
|
||||||
|
22
run.yml
22
run.yml
@ -1,6 +1,10 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
become: yes
|
become: yes
|
||||||
|
vars:
|
||||||
|
- giteaPort: 3000
|
||||||
|
- giteaUninstall: false
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- group_vars/all.yml
|
- group_vars/all.yml
|
||||||
|
|
||||||
@ -10,12 +14,12 @@
|
|||||||
private: no
|
private: no
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- essential
|
- role: essential
|
||||||
- git
|
- role: firewall
|
||||||
- deadswitch
|
- role: git
|
||||||
- firewall
|
- role: deadswitch
|
||||||
- blog
|
- role: blog
|
||||||
- gitea
|
- role: gitea
|
||||||
- nginx
|
- role: nginx
|
||||||
- goaccess
|
- role: goaccess
|
||||||
- tor
|
- role: tor
|
Loading…
Reference in New Issue
Block a user