vps/new/playbooks/basic-setup.yml
2023-08-26 23:43:10 +02:00

80 lines
2.4 KiB
YAML

---
- name: Basic Server setup
hosts: all
gather_facts: false
tasks:
- name: Install docker
ansible.builtin.apt:
name: "{{ item }}"
state: present
with_items:
- docker.io
- docker-compose
- name: Install fish
ansible.builtin.apt:
name: "fish"
state: present
- name: "Change root's shell to fish"
ansible.builtin.user:
name: root
shell: /usr/bin/fish
- 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=rwx,g=rx,o=rx
- 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"
- name: Create /apps
ansible.builtin.file:
path: /apps
state: directory
mode: u=rwx,g=rx,o=rx
- name: Copy docker-compose
ansible.builtin.copy:
dest: /apps/docker-compose.yml
src: "../vps2/docker-compose.yml" # TODO: choose the right directory
mode: "u=r,g=r,o=r"
handlers:
- name: "Caddyfile changed"
ansible.builtin.service:
name: caddy
state: reloaded