mirror of
https://github.com/Noratrieb/vps.git
synced 2026-01-14 16:55:00 +01:00
86 lines
2.6 KiB
YAML
86 lines
2.6 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 useful tools
|
|
ansible.builtin.apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
with_items:
|
|
- htop
|
|
- 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 -f /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: "../{{ inventory_hostname }}/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: "../{{ inventory_hostname }}/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
|