diff --git a/.ci/Dockerfile b/.ci/Dockerfile new file mode 100644 index 0000000..708bc07 --- /dev/null +++ b/.ci/Dockerfile @@ -0,0 +1,7 @@ +FROM nginx:latest + +COPY nginx.conf /etc/nginx/nginx.conf + +COPY ./static /var/www/static + +RUN nginx -t diff --git a/.ci/nginx.conf b/.ci/nginx.conf new file mode 100644 index 0000000..e795fd5 --- /dev/null +++ b/.ci/nginx.conf @@ -0,0 +1,25 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + server { + listen 80; + #server_name localhost; + root /var/www/static; + + index index.html; + + location / { + try_files $uri $uri/ =404; + } + + } + +} diff --git a/.ci/static/.gitkeep b/.ci/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore index 31d87eb..ab69987 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ *~ private.pem venv/ + +./.ci/static/ +!./.ci/static/.gitkeep diff --git a/ansible/playbooks/bootstrap-docker.yaml b/ansible/playbooks/bootstrap-docker.yaml new file mode 100644 index 0000000..ea3cb10 --- /dev/null +++ b/ansible/playbooks/bootstrap-docker.yaml @@ -0,0 +1,64 @@ +- name: Bootstrap docker + hosts: k3s_masters + become: yes + vars_files: + # Secrets + - ../secrets/gluttonycluster-credentials.yaml + + tasks: + - name: Update the apt package index + apt: + update_cache: yes + tags: docker + + - name: Install packages to allow apt to use a repository over HTTPS + apt: + name: + - ca-certificates + - curl + - gnupg + - lsb-release + state: present + tags: docker + + - name: Download Docker's GPG key + ansible.builtin.get_url: + url: https://download.docker.com/linux/ubuntu/gpg + dest: /usr/share/keyrings/docker-archive-keyring.gpg + mode: '0644' + tags: docker + + - name: Set up the stable Docker repository + ansible.builtin.lineinfile: + path: /etc/apt/sources.list.d/docker.list + line: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" + create: yes + tags: docker + + - name: Update the apt package index after adding Docker repository + apt: + update_cache: yes + tags: docker + + - name: Install Docker Engine + apt: + name: + - docker-ce + - docker-ce-cli + - containerd.io + state: latest + tags: docker + + - name: Ensure Docker is started and enabled + service: + name: docker + state: started + enabled: yes + tags: docker + + - name: Add user to docker group (optional) + ansible.builtin.user: + name: "{{ ansible_user }}" + groups: docker + append: yes + tags: docker diff --git a/ansible/run-playbook.sh b/ansible/run-playbook.sh new file mode 100755 index 0000000..22a4d9e --- /dev/null +++ b/ansible/run-playbook.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +PLAYBOOK_DIR="./playbooks" + +# Ensure gum is installed +if ! command -v gum &> /dev/null; then + echo "gum could not be found. Please install gum first." + exit 1 +fi + +# Ensure pass is installed +if ! command -v pass &> /dev/null; then + echo "pass could not be found. Please install pass first." + exit 1 +fi + + +echo "Fetching ansible-vault password" +VAULT_PASS=$(pass show gluttony-cluster/ansible-vault) +if [[ -z "$VAULT_PASS" ]]; then + echo "Failed to retrieve Ansible Vault password from pass." + exit 1 +fi + +# Create a list of playbooks in the specified directory +PLAYBOOKS=$(ls -1 "$PLAYBOOK_DIR"/*.yaml 2> /dev/null) +if [[ -z "$PLAYBOOKS" ]]; then + echo "No playbooks found in $PLAYBOOK_DIR." + exit 1 +fi + +# Use gum to select a playbook +SELECTED_PLAYBOOK=$(echo "$PLAYBOOKS" | gum choose) +if [[ -z "$SELECTED_PLAYBOOK" ]]; then + echo "No playbook selected. Exiting." + exit 1 +fi + +# Confirmation step with gum +echo "You selected: $SELECTED_PLAYBOOK" +if ! gum confirm "Are you sure you want to run this playbook? ($SELECTED_PLAYBOOK)"; then + echo "Operation cancelled. Exiting." + exit 1 +fi + +# Run the selected playbook with the Ansible Vault password +echo "Running playbook: $SELECTED_PLAYBOOK" +ANSIBLE_VAULT_PASSWORD_FILE=$(mktemp) +echo "$VAULT_PASS" > "$ANSIBLE_VAULT_PASSWORD_FILE" + +ansible-playbook -i inventory.yaml "$SELECTED_PLAYBOOK" --vault-password-file "$ANSIBLE_VAULT_PASSWORD_FILE" + +# Clean up the temporary password file +rm -f "$ANSIBLE_VAULT_PASSWORD_FILE" diff --git a/docs/index.md b/docs/index.md index 306bd28..ed58168 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,8 +2,6 @@ Welcome to the documentation for my k3s cluster, aka my datacenter at home. -If you are looking for user documentation, navigate to [the user docs](./user/index.md) - ## About this project This project is a small datacenter that I run in my house. diff --git a/docs/technical/conventions.md b/docs/technical/conventions.md index e1a55d0..e88812e 100644 --- a/docs/technical/conventions.md +++ b/docs/technical/conventions.md @@ -2,5 +2,7 @@ Try and stick to these, so our life is a bit easier. -- Place all components in their own namespace - Place all system components into a `*-system` namespace +- Place all "User apps (aka tier 2)" into the default namespace +- Folder per service +- Minimal to no cluster modification (keep everything in version control) diff --git a/docs/setup.md b/docs/technical/setup.md similarity index 100% rename from docs/setup.md rename to docs/technical/setup.md diff --git a/docs/user/calendar.md b/docs/user/calendar.md new file mode 100644 index 0000000..fbd257b --- /dev/null +++ b/docs/user/calendar.md @@ -0,0 +1,4 @@ +# Calendar + +> [!NOTE] +> diff --git a/docs/user/contacts.md b/docs/user/contacts.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/user/davx5.md b/docs/user/davx5.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/user/index.md b/docs/user/index.md deleted file mode 100644 index 2b97925..0000000 --- a/docs/user/index.md +++ /dev/null @@ -1,19 +0,0 @@ -# User Documentation - -Welcome to the user facing documentation! This documentation is intended for those -utilizing one of my services I host for friends and family. - -## FAQ - -### How do I register an account? - -See [Registering an account](./account.md) - -### How do I request media? - -See [Requesting Media](./request.md) - -### How do I download media? - -See [Downloading Media](./download.md) - diff --git a/docs/user/radicale.md b/docs/user/radicale.md new file mode 100644 index 0000000..8d43e6a --- /dev/null +++ b/docs/user/radicale.md @@ -0,0 +1,19 @@ +# Radicale + +[Radicale](https://radicale.org/v3.html) is a calendar, contact, and TODO list server. +It provides a centeralized place +to store all these things so that they can be backed up and sync across devices. + +To get started with radicale, request an account, then login in at [cal.clortox.com](cal.clortox.com). + +You can bookmark this page, as anytime you may want to create new calendars, address books, todo lists, +or more, this is where you will have to go. + +## Usage + +- [Davx5 (Required for use on android devices)](davx5.md) +- [Calendar Setup](calendar.md) +- [Contacts Setup](contacts.md) +- [TODO Setup](todo.md) + + diff --git a/docs/user/todo.md b/docs/user/todo.md new file mode 100644 index 0000000..e69de29 diff --git a/mkdocs.yaml b/mkdocs.yaml index f96b725..ae7b4e6 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -7,20 +7,24 @@ repo_url: https://git.clortox.com/Infrastructure/Gluttony-Cluster edit_uri: src/branch/main/docs nav: - - Introduction: - - Overview: index.md - - Cluster Architecture: architecture.md - - Setup Cluster: setup.md - User Documentation: - - Overview: user/index.md + - Overview: index.md - Accounts: - Registering a mail account: user/mailcow.md - - Registering an account: user/account.md + - Registering an SSO account: user/account.md + - Registering a radicale account: user/radicale.md - Media: - Requesting Media: user/request.md - Downloading Media: user/download.md + - Radicale (Calendars, contacts, etc): + - Android Phone Sync (DAVX5): user/davx5.md + - Making a Calendar: user/calendar.md + - Making a Contact Book: user/contacts.md + - Making a TODO List: user/todo.md - Technical: - Overview: technical/index.md + - Cluster Architecture: architecture.md + - Setup Cluster: technical/setup.md - Conventions: technical/conventions.md - Tier 0 (Infrastructure): - MetalLB: technical/metallb.md