This commit is contained in:
nora 2024-07-01 20:24:00 +02:00
parent 009f85acc2
commit de02947066
6 changed files with 32 additions and 5 deletions

View file

@ -1,4 +1,4 @@
name: Deploy an application
name: Build an application
on:
workflow_dispatch:

View file

@ -3,6 +3,10 @@
hosts: all
gather_facts: false
tasks:
- name: apt update
ansible.builtin.apt:
update_cache: true
upgrade: yes
- name: Install docker
ansible.builtin.apt:
name: "{{ item }}"

View file

@ -2,5 +2,5 @@ vps:
hosts:
vps1:
ansible_host: vps1.nilstrieb.dev
#vps2:
# ansible_host: vps2.nilstrieb.dev
vps2:
ansible_host: vps2.nilstrieb.dev

View file

@ -19,6 +19,6 @@
src: "../secrets/vps1.env"
mode: "u=r,g=r,o=r"
- name: Docker compose up! 🚀
community.docker.docker_compose:
community.docker.docker_compose_v2:
project_src: /apps
restarted: true

View file

@ -189,7 +189,7 @@
src: "../secrets/vps2.env"
mode: "u=r,g=r,o=r"
- name: Docker compose up! 🚀
community.docker.docker_compose:
community.docker.docker_compose_v2:
project_src: /apps
restarted: true
#####

23
scripts/copy-deploy-key.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copies a base64 encoded deploy key to the servers.
set -eu
printf "Enter private key (base64 encoded): "
read -r key64
private=$(echo "$key64" | base64 -d)
public=$(ssh-keygen -f <(echo "$private") -y)
tmp=$(mktemp -d)
echo "$private" > "$tmp/id"
echo "$public" > "$tmp/id.pub"
delete() {
rm -r "$tmp"
}
trap delete EXIT
ssh-copy-id -i "$tmp/id" root@vps1.nilstrieb.dev
ssh-copy-id -i "$tmp/id" root@vps2.nilstrieb.dev