This commit is contained in:
nora 2023-08-27 17:07:08 +02:00
parent f53902abee
commit e714c08de3
10 changed files with 71 additions and 13 deletions

View file

@ -18,9 +18,6 @@ http:
draintimeout: 60s draintimeout: 60s
headers: headers:
X-Content-Type-Options: [nosniff] X-Content-Type-Options: [nosniff]
# tls:
# certificate: /etc/certs/vps2.nilstrieb.dev.crt
# key: /etc/certs/vps2.nilstrieb.dev.key
auth: auth:
htpasswd: htpasswd:
realm: nilstrieb-registry realm: nilstrieb-registry

View file

@ -1,6 +1,6 @@
vps: vps:
hosts: hosts:
# vps1: vps1:
# ansible_host: vps1.nilstrieb.dev ansible_host: vps1.nilstrieb.dev
vps2: vps2:
ansible_host: vps2.nilstrieb.dev ansible_host: vps2.nilstrieb.dev

7
playbooks/all.yml Normal file
View file

@ -0,0 +1,7 @@
---
- name: Generic setup
ansible.builtin.import_playbook: ./basic-setup.yml
- name: VPS 1
ansible.builtin.import_playbook: ./vps1.yml
- name: VPS 2
ansible.builtin.import_playbook: ./vps2.yml

View file

@ -35,7 +35,7 @@
ansible.builtin.shell: | ansible.builtin.shell: |
set -euo pipefail set -euo pipefail
sudo rm /usr/share/keyrings/caddy-stable-archive-keyring.gpg sudo rm -f /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
@ -56,16 +56,16 @@
ansible.builtin.file: ansible.builtin.file:
path: /var/www/html/debug path: /var/www/html/debug
state: directory state: directory
mode: u=rwx,g=rx,o=rx mode: "u=rwx,g=rx,o=rx"
- name: Create debug webserver file - name: Create debug webserver file
ansible.builtin.copy: ansible.builtin.copy:
dest: /var/www/html/debug/index.html dest: /var/www/html/debug/index.html
src: "../debug.html" src: "../debug.html"
mode: u=rw,g=r,o=r mode: "u=rw,g=r,o=r"
- name: Copy Caddyfile - name: Copy Caddyfile
ansible.builtin.copy: ansible.builtin.copy:
dest: /etc/caddy/Caddyfile dest: /etc/caddy/Caddyfile
src: "../vps2/Caddyfile" # TODO: Choose the right caddyfile depending on the server. src: "../{{ inventory_hostname }}/Caddyfile" # TODO: Choose the right caddyfile depending on the server.
mode: "u=rw,g=r,o=r" mode: "u=rw,g=r,o=r"
notify: notify:
- "Caddyfile changed" - "Caddyfile changed"
@ -77,7 +77,7 @@
- name: Copy docker-compose - name: Copy docker-compose
ansible.builtin.copy: ansible.builtin.copy:
dest: /apps/docker-compose.yml dest: /apps/docker-compose.yml
src: "../vps2/docker-compose.yml" # TODO: choose the right directory src: "../{{ inventory_hostname }}/docker-compose.yml" # TODO: choose the right directory
mode: "u=r,g=r,o=r" mode: "u=r,g=r,o=r"
handlers: handlers:
- name: "Caddyfile changed" - name: "Caddyfile changed"

14
playbooks/vps1.yml Normal file
View file

@ -0,0 +1,14 @@
---
- name: VPS 1 setup
hosts: vps1
gather_facts: false
tasks:
#####
# END: docker compose up!
#####
# We want this to be last so that all app-specific config has been done.
- name: Docker compose up! 🚀
community.docker.docker_compose:
project_src: /apps
state: present
restarted: true

View file

@ -1,6 +1,4 @@
--- ---
- name: Generic setup
ansible.builtin.import_playbook: ./basic-setup.yml
- name: VPS 2 setup - name: VPS 2 setup
hosts: vps2 hosts: vps2
gather_facts: false gather_facts: false

2
run.sh
View file

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ansible-playbook -i inventory.yml playbooks/vps2.yml -u root ansible-playbook -i inventory.yml playbooks/all.yml -u root

34
vps1/Caddyfile Normal file
View file

@ -0,0 +1,34 @@
{
email nilstrieb@gmail.com
}
# https://gist.github.com/ryanburnette/d13575c9ced201e73f8169d3a793c1a3
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Credentials "false"
Access-Control-Allow-Headers "${args.1}"
Access-Control-Max-Age "86400"
defer
}
respond "" 204
}
handle @cors{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Expose-Headers *
defer
}
}
}
vps1.nilstrieb.dev {
root * /var/www/html/debug
file_server
}

1
vps1/README.md Normal file
View file

@ -0,0 +1 @@
## ports

7
vps1/docker-compose.yml Normal file
View file

@ -0,0 +1,7 @@
version: "3.8"
services:
dummy:
container_name: dummy
image: alpine:latest
networks:
internal: