A playbook to setup a server that serves as host for multiple static sites
Go to file
2023-11-10 15:00:51 +01:00
roles/static-server fix: use site user as ssh config owner 2023-11-10 15:00:51 +01:00
.gitignore chore: Add gitignore 2023-11-10 14:25:00 +01:00
justfile Initial commit 2023-11-10 14:21:47 +01:00
LICENSE Initial commit 2023-11-10 14:21:47 +01:00
README.md Add docker-compose installation 2023-11-10 14:47:57 +01:00
setup.yml Initial commit 2023-11-10 14:21:47 +01:00

Static Site Host - Ansible playbook

This is an Ansible playbook which allows you to set up a server to serve static sites via Static Web Server. Everything will be ready for your site to be deployed using your CI.

Getting started

Create an file listing the repository host in inventory/hosts. You shouldn't put every domain that you intend to use as static site in there, only one domain per server.

[static_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.