vps/new/playbooks/basic-setup.yml
2023-08-26 20:40:30 +02:00

59 lines
1.8 KiB
YAML

---
- name: Basic Server setup
hosts: all
gather_facts: false
tasks:
- name: Install docker
ansible.builtin.apt:
name: docker.io
state: present
- name: Install keyring packages
ansible.builtin.apt:
name: "{{ item }}"
with_items:
- debian-keyring
- debian-archive-keyring
- apt-transport-https
- name: Add caddy keyrings
ansible.builtin.shell: |
set -euo pipefail
sudo rm /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
# todo: show ok/changed
args:
executable: /bin/bash
- name: Install caddy
ansible.builtin.apt:
name: caddy
state: present
args:
update_cache: true
- name: Ensure caddy is started
ansible.builtin.service:
name: caddy
state: started
- name: Create debug html root
ansible.builtin.file:
path: /var/www/html/debug
state: directory
mode: u=rw,g=r,o=r
- name: Create debug webserver file
ansible.builtin.copy:
dest: /var/www/html/debug/index.html
src: "../debug.html"
mode: u=rw,g=r,o=r
- name: Copy Caddyfile
ansible.builtin.copy:
dest: /etc/caddy/Caddyfile
src: "../vps2/Caddyfile" # TODO: Choose the right caddyfile depending on the server.
mode: "u=rw,g=r,o=r"
notify:
- "Caddyfile changed"
handlers:
- name: "Caddyfile changed"
ansible.builtin.service:
name: caddy
state: reloaded