mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-26 08:50:06 +00:00
Compare commits
No commits in common. "5e2c4850e148f1446330dc6ba843416bcf0c1c83" and "d435ab80ac1539df7daae4953eebf0feb825a4ed" have entirely different histories.
5e2c4850e1
...
d435ab80ac
50
.github/workflows/deploy.yaml
vendored
50
.github/workflows/deploy.yaml
vendored
@ -1,27 +1,27 @@
|
|||||||
# name: Run Playbook
|
name: Run Playbook
|
||||||
|
|
||||||
# on:
|
on:
|
||||||
# push:
|
push:
|
||||||
# tags:
|
tags:
|
||||||
# - "v*.*.*"
|
- "v*.*.*"
|
||||||
|
|
||||||
# jobs:
|
jobs:
|
||||||
# deploy:
|
deploy:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - name: Set up Git repository
|
- name: Set up Git repository
|
||||||
# uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
# with:
|
with:
|
||||||
# ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
# submodules: recursive
|
submodules: recursive
|
||||||
# - name: Run Ansible-Playbook
|
- name: Run Ansible-Playbook
|
||||||
# uses: dawidd6/action-ansible-playbook@v2
|
uses: dawidd6/action-ansible-playbook@v2
|
||||||
# with:
|
with:
|
||||||
# playbook: run.yml
|
playbook: run.yml
|
||||||
# key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
# inventory: |
|
inventory: |
|
||||||
# [hosts]
|
[hosts]
|
||||||
# openpunk-vps ansible_host=96.30.199.68 ansible_user=root ansible_connection=ssh
|
openpunk-vps ansible_host=96.30.199.68 ansible_user=root ansible_connection=ssh
|
||||||
# vault_password: ${{ secrets.VAULT_PASSWORD }}
|
vault_password: ${{ secrets.VAULT_PASSWORD }}
|
||||||
# options: |
|
options: |
|
||||||
# --extra-vars domain=openpunk.com
|
--extra-vars domain=openpunk.com
|
||||||
|
11
README.md
11
README.md
@ -1,11 +1,12 @@
|
|||||||
# OpenPunk's Ansible playbook
|
# OpenPunk's Ansible playbook
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/CPunch/openpunk-ansible/actions/workflows/deploy.yaml"><img src="https://github.com/CPunch/openpunk-ansible/actions/workflows/deploy.yaml/badge.svg?branch=main" alt="Workflow"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
||||||
|
|
||||||
- gitea
|
- gitea
|
||||||
- sadly, no db migration is supported right now. maybe a future todo?
|
|
||||||
- blog
|
- blog
|
||||||
- cron job for grabbing the `HEAD` of https://github.com/CPunch/openpunk && building the hugo site
|
|
||||||
- tor mirror
|
- tor mirror
|
||||||
- nginx (for the above mentioned)
|
- nginx (for the above mentioned)
|
||||||
- my shell theme (zsh + powerlevel10k)
|
- my shell theme (zsh + powerlevel10k)
|
||||||
@ -13,12 +14,12 @@ This is my failsafe (and also my helpful migration tool) for restoring the OpenP
|
|||||||
|
|
||||||
This playbook assumes the target VPS is running the latest debian stable release.
|
This playbook assumes the target VPS is running the latest debian stable release.
|
||||||
|
|
||||||
|
## Automatic deployment
|
||||||
|
On new release tags the playbook is automatically ran on the production openpunk vps. For more info checkout the `.github/workflows/deploy.yaml` workflow
|
||||||
|
|
||||||
## Notes to my future self
|
## Notes to my future self
|
||||||
The deadswitch has the deadtrigger setup every run, so you have a 14-day timer to add a one-liner to your crontab to keep that deadtrigger set.
|
The deadswitch has the deadtrigger setup every run, so you have a 14-day timer to add a one-liner to your crontab to keep that deadtrigger set.
|
||||||
|
|
||||||
Some DNS records also need to be set:
|
|
||||||
- an A record with a `git.*` subdomain
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```sh
|
```sh
|
||||||
ansible-playbook -i hosts --ask-vault-pass run.yml
|
ansible-playbook -i hosts --ask-vault-pass run.yml
|
||||||
|
20
run.yml
20
run.yml
@ -9,13 +9,13 @@
|
|||||||
prompt: domain pointing to the vps
|
prompt: domain pointing to the vps
|
||||||
private: no
|
private: no
|
||||||
|
|
||||||
roles:
|
tasks:
|
||||||
- essential
|
- import_tasks: tasks/essential.yml
|
||||||
- git
|
- import_tasks: tasks/firewall.yml
|
||||||
- deadswitch
|
- import_tasks: tasks/blog.yml
|
||||||
- firewall
|
- import_tasks: tasks/gitea.yml
|
||||||
- blog
|
- import_tasks: tasks/tor.yml
|
||||||
- gitea
|
- import_tasks: tasks/nginx.yml
|
||||||
- nginx
|
- import_tasks: tasks/git.yml
|
||||||
- goaccess
|
- import_tasks: tasks/goaccess.yml
|
||||||
- tor
|
- import_tasks: tasks/deadswitch.yml
|
2
secrets
2
secrets
@ -1 +1 @@
|
|||||||
Subproject commit e643deb62e0e0e2f05a9c4023468332002668c21
|
Subproject commit 585d0fd7dda8b515fc7c78cd1491c0ec7d79b05c
|
@ -4,7 +4,6 @@
|
|||||||
repo: "https://github.com/CPunch/openpunk.git"
|
repo: "https://github.com/CPunch/openpunk.git"
|
||||||
dest: "/var/www/{{ domain }}"
|
dest: "/var/www/{{ domain }}"
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Build blog
|
- name: Build blog
|
||||||
command:
|
command:
|
||||||
cmd: hugo
|
cmd: hugo
|
||||||
@ -12,7 +11,7 @@
|
|||||||
|
|
||||||
- name: Install updateBlog script
|
- name: Install updateBlog script
|
||||||
template:
|
template:
|
||||||
src: templates/updateBlog
|
src: templates/blog/updateBlog
|
||||||
dest: /usr/local/bin/updateBlog
|
dest: /usr/local/bin/updateBlog
|
||||||
mode: u+rx
|
mode: u+rx
|
||||||
|
|
@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
- name: Install deadswitch script
|
- name: Install deadswitch script
|
||||||
copy:
|
copy:
|
||||||
src: deadswitch
|
src: static/blog/deadswitch
|
||||||
dest: /usr/local/bin/deadswitch
|
dest: /usr/local/bin/deadswitch
|
||||||
mode: u+rx
|
mode: u+rx
|
||||||
|
|
||||||
- name: Install imdead.sh
|
- name: Install imdead.sh
|
||||||
copy:
|
copy:
|
||||||
src: imdead.sh
|
src: static/blog/imdead.sh
|
||||||
dest: /root/deadman/imdead.sh
|
dest: /root/deadman/imdead.sh
|
||||||
mode: u+rx
|
mode: u+rx
|
||||||
|
|
||||||
@ -22,7 +22,6 @@
|
|||||||
dest: /root/deadman/dead.patch
|
dest: /root/deadman/dead.patch
|
||||||
mode: u+rw
|
mode: u+rw
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Install deadtrigger
|
- name: Install deadtrigger
|
||||||
file:
|
file:
|
||||||
name: /root/.deadtrigger
|
name: /root/.deadtrigger
|
@ -1,9 +1,7 @@
|
|||||||
---
|
---
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Add Gitea repo key
|
- name: Add Gitea repo 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
|
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
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Set key perms
|
- name: Set key perms
|
||||||
shell: sudo chmod 644 /etc/apt/trusted.gpg.d/morph027-gitea.gpg
|
shell: sudo chmod 644 /etc/apt/trusted.gpg.d/morph027-gitea.gpg
|
||||||
|
|
||||||
@ -32,7 +30,6 @@
|
|||||||
- zsh # :D
|
- zsh # :D
|
||||||
- python3-certbot-nginx
|
- python3-certbot-nginx
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Setup default shell (zsh)
|
- name: Setup default shell (zsh)
|
||||||
shell: chsh -s /usr/bin/zsh
|
shell: chsh -s /usr/bin/zsh
|
||||||
|
|
||||||
@ -44,6 +41,6 @@
|
|||||||
|
|
||||||
- name: Install .zshrc
|
- name: Install .zshrc
|
||||||
copy:
|
copy:
|
||||||
src: .zshrc
|
src: static/.zshrc
|
||||||
dest: /root/.zshrc
|
dest: /root/.zshrc
|
||||||
force: no
|
force: no
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
- name: Copy fail2ban jail config
|
- name: Copy fail2ban jail config
|
||||||
copy:
|
copy:
|
||||||
src: jails.local
|
src: static/fail2ban/jails.local
|
||||||
dest: /etc/fail2ban/jail.d/jails.local
|
dest: /etc/fail2ban/jail.d/jails.local
|
||||||
|
|
||||||
- name: Enable fail2ban service
|
- name: Enable fail2ban service
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Setup git config
|
- name: Setup git config
|
||||||
copy:
|
copy:
|
||||||
src: .gitconfig
|
src: static/.gitconfig
|
||||||
dest: /root/.gitconfig
|
dest: /root/.gitconfig
|
||||||
owner: root
|
owner: root
|
||||||
mode: u=rw,g=,o=
|
mode: u=rw,g=,o=
|
||||||
@ -9,7 +9,6 @@
|
|||||||
# make sure our vps trusts the github.com key signature. we pipe the output
|
# make sure our vps trusts the github.com key signature. we pipe the output
|
||||||
# of ssh-keyscan into .ssh/known_hosts
|
# of ssh-keyscan into .ssh/known_hosts
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Scan for SSH host keys
|
- name: Scan for SSH host keys
|
||||||
command: ssh-keyscan github.com 2>/dev/null
|
command: ssh-keyscan github.com 2>/dev/null
|
||||||
register: ssh_scan
|
register: ssh_scan
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Configure Gitea
|
- name: Configure Gitea
|
||||||
template:
|
template:
|
||||||
src: app.ini
|
src: templates/gitea/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:
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Copy goaccess config
|
- name: Copy goaccess config
|
||||||
copy:
|
copy:
|
||||||
src: goaccess.conf
|
src: static/goaccess/goaccess.conf
|
||||||
dest: /etc/goaccess/goaccess.conf
|
dest: /etc/goaccess/goaccess.conf
|
@ -1,12 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Remove default nginx config
|
- name: Remove default nginx config
|
||||||
file:
|
file:
|
||||||
name: /etc/nginx/sites-enabled
|
name: /etc/nginx/sites-enabled
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
# TODO: make idempotent
|
|
||||||
- name: Restore sites-enabled
|
- name: Restore sites-enabled
|
||||||
file:
|
file:
|
||||||
name: /etc/nginx/sites-enabled
|
name: /etc/nginx/sites-enabled
|
||||||
@ -14,7 +11,7 @@
|
|||||||
|
|
||||||
- name: Install system nginx config
|
- name: Install system nginx config
|
||||||
copy:
|
copy:
|
||||||
src: nginx.conf
|
src: static/nginx/nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# setup our configs for each host (we don't want to
|
# setup our configs for each host (we don't want to
|
||||||
@ -23,19 +20,19 @@
|
|||||||
|
|
||||||
- name: Install nginx config for {{ domain }}
|
- name: Install nginx config for {{ domain }}
|
||||||
template:
|
template:
|
||||||
src: templates/site.conf
|
src: templates/nginx/site.conf
|
||||||
dest: /etc/nginx/conf.d/{{ domain }}.conf
|
dest: /etc/nginx/conf.d/{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
|
||||||
- name: Install nginx config for git.{{ domain }}
|
- name: Install nginx config for git.{{ domain }}
|
||||||
template:
|
template:
|
||||||
src: templates/gitea.conf
|
src: templates/nginx/gitea.conf
|
||||||
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
dest: /etc/nginx/conf.d/git.{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
|
||||||
- name: Install nginx config for our Hidden Service
|
- name: Install nginx config for our Hidden Service
|
||||||
template:
|
template:
|
||||||
src: templates/tor.conf
|
src: templates/nginx/tor.conf
|
||||||
dest: /etc/nginx/conf.d/tor-{{ domain }}.conf
|
dest: /etc/nginx/conf.d/tor-{{ domain }}.conf
|
||||||
force: no
|
force: no
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Install torrc
|
- name: Install torrc
|
||||||
template:
|
template:
|
||||||
src: torrc
|
src: templates/tor/torrc
|
||||||
dest: /etc/tor/torrc
|
dest: /etc/tor/torrc
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
@ -23,7 +23,7 @@
|
|||||||
group: debian-tor
|
group: debian-tor
|
||||||
mode: u=rw,g=,o=
|
mode: u=rw,g=,o=
|
||||||
|
|
||||||
- name: Enable Tor Service
|
- name: Reload Tor
|
||||||
systemd:
|
systemd:
|
||||||
name: tor
|
name: tor
|
||||||
enabled: yes
|
enabled: yes
|
Loading…
Reference in New Issue
Block a user