2022-05-31 04:36:55 +00:00
|
|
|
# OpenPunk's Ansible playbook
|
2022-10-04 17:51:54 +00:00
|
|
|
|
2022-05-30 15:46:36 +00:00
|
|
|
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
|
|
|
|
|
|
|
- gitea
|
2023-02-03 21:43:52 +00:00
|
|
|
- backup and restoring are also supported
|
2022-05-30 15:46:36 +00:00
|
|
|
- blog
|
2023-01-14 23:31:46 +00:00
|
|
|
- cron job for grabbing the `HEAD` of https://github.com/CPunch/openpunk && building the hugo site
|
2022-05-30 15:46:36 +00:00
|
|
|
- tor mirror
|
2022-05-31 04:36:55 +00:00
|
|
|
- nginx (for the above mentioned)
|
2023-01-18 07:10:40 +00:00
|
|
|
- certbot's Let's Encrypt
|
2022-05-31 04:36:55 +00:00
|
|
|
- my shell theme (zsh + powerlevel10k)
|
|
|
|
- deadswitch (& the ssh + git config to allow pushes)
|
|
|
|
|
2022-05-31 18:48:01 +00:00
|
|
|
This playbook assumes the target VPS is running the latest debian stable release.
|
|
|
|
|
2022-05-31 04:36:55 +00:00
|
|
|
## Notes to my future self
|
2023-01-18 07:10:40 +00:00
|
|
|
Add this to your local machine's crontab:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh openpunk 'touch /root/.deadtrigger'
|
|
|
|
```
|
2022-05-30 15:46:36 +00:00
|
|
|
|
2023-01-14 23:36:51 +00:00
|
|
|
Some DNS records also need to be set:
|
|
|
|
- an A record with a `git.*` subdomain
|
|
|
|
|
2024-11-23 02:10:41 +00:00
|
|
|
A Gitea Act Runner is also setup if the `giteaRunnerToken` variable is defined in your hosts file.
|
|
|
|
|
2022-05-30 15:46:36 +00:00
|
|
|
## Usage
|
2024-02-21 21:56:43 +00:00
|
|
|
First, make sure to install the requirements:
|
|
|
|
```sh
|
|
|
|
ansible-galaxy install -r requirements.yml
|
|
|
|
```
|
|
|
|
|
|
|
|
Then, run the playbook:
|
|
|
|
|
2022-05-30 15:46:36 +00:00
|
|
|
```sh
|
|
|
|
ansible-playbook -i hosts --ask-vault-pass run.yml
|
|
|
|
```
|
2022-05-31 04:36:55 +00:00
|
|
|
> NOTE: The 'secrets' directory has been omitted from this repo (so it's not going to run without the provided files)
|
2022-05-30 15:46:36 +00:00
|
|
|
|
2023-02-03 21:43:52 +00:00
|
|
|
## Backup and restore
|
|
|
|
|
|
|
|
Backup Gitea using the 'backup' tag
|
|
|
|
```sh
|
|
|
|
ansible-playbook -i hosts run.yml --tags backup
|
|
|
|
```
|
|
|
|
|
|
|
|
then, restore from the backup using the 'restore' tag
|
|
|
|
```sh
|
|
|
|
ansible-playbook -i hosts run.yml --tags restore
|
|
|
|
```
|
|
|
|
|
2022-05-30 15:46:36 +00:00
|
|
|
## Example hosts file
|
|
|
|
```
|
|
|
|
[hosts]
|
2024-11-23 02:10:41 +00:00
|
|
|
openpunk-vps ansible_host=104.238.138.76 ansible_user=root ansible_connection=ssh giteaRunnerToken=my-token-yayy
|
2022-05-30 15:46:36 +00:00
|
|
|
```
|