roles/static-server | ||
.gitignore | ||
justfile | ||
LICENSE | ||
README.md | ||
setup.yml |
Static Site Host - Ansible playbook
This is an Ansible playbook which allows you to set up a server to serve static sites that will be deployed via CI.
Getting started
Create an file listing the repository host in inventory/hosts
. You snouldn't put every domain that you intend to use as static site in there, only one domain per server.
[stitic_site_servers]
static.example.org
Create the directory ìnventory/<hostname>/
and then create ìnventory/<hostname>/vars.yml
. In there you will configure your static sites, specifically which user will be created, which domain will be used (can be changed) and the public part of the SSH key your CI will later use. Create them with ssh-keygen
and without a password.
static_sites:
- user: host_1
domain: host_1.example.org
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOREPUBLICKEYINFO host_1"
- user: host_2
domain: host_2.example.org
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOREPUBLICKEYINFO host_2"
Now deploy by running
just install-all
In the end you need to setup your CI pipline to deploy to your server. Here is how this would look like for Woodpecker.
---
pipeline:
build:
image: klakegg/hugo:ext
commands:
- hugo
deploy:
image: appleboy/drone-scp
settings:
host:
from_secret: host
username:
from_secret: ssh_user
target:
from_secret: path
source: public/
key:
from_secret: ssh_key
The secrets should be
Key | Example | Description |
---|---|---|
host |
static.example.org |
Hostename of the server where you want to deploy |
ssh_user |
username |
User on the server |
ssh_key |
-----BEGIN OPENSSH PRIVATE KEY----- |
The private SSH key of the user |
path |
/static_sites/USER/public |
Path where to deploy the static files. Deploying means it'll create public in the given path. |