diff --git a/README.md b/README.md index c08a1a2..503e1de 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,10 @@ -# ansible-docker-swarm +# Raspberry Pi NAS -This repository contains a complete Ansible config for setting up a Docker -Swarm on Debian 10-based nodes. I personally use it for a swarm of Raspberry -Pi's, but in theory it should work with other hosts as well. +This repository contains all configuration I use to set up a Raspberry Pi 4B as +a NAS and media storage server. This repository will most likely evolve a lot. -## Inventory file +The Pi is used to host the following: -A template for the inventory file can be found in `hosts.template.ini`. The -hosts consists of three main groups: - -* `admin`: the admin is the host that initializes the Swarm. It serves several - functions: - * It's used to initialize the Swarm. - * It serves as the entrypoint to the Swarm. - * It hosts the NFS share that's used for persistent storage. -* `managers`: these are the nodes that should be added as manager. -* `workers`: these nodes will be added as workers. - -## Roles - -The config is divided into several roles to make management easier: - -* `install-python3`: replaces Python 2 with Python 3. This role currently - crashes, because Ansible doesn't like it when you change the Python install - during a run, but a consecutive run does work. -* `install-net-security`: installs UFW & Fail2Ban & configures them -* `install-docker`: installs Docker & any Docker-related tools -* `init-docker-swarm`: initializes the Swarm on the `admin` host -* `add-docker-swarm-managers`: adds the manager nodes to the swarm -* `add-docker-swarm-workers`: adds the worker nodes to the swarm -* `deploy-portainer`: deploys Portainer - -## Use of Portainer - -Portainer is a tool created for managing Docker engines, and in particular -Docker Swarm. Because I use Portainer for setting up all other services, it's -the only Docker service that I actually set up using Ansible. +* Samba network share for access to family pictures +* [Photoview](https://photoview.github.io/) instance for accessing image over the internet +* [Jellyfin](https://jellyfin.org/) for accessing media library as well diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..dc19376 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,17 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +Vagrant.configure("2") do |config| + config.vm.box = "generic/debian11" + + # Use the standard insecure SSH key + config.ssh.insert_key = false + + # Don't mount the current directory in the VM + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.define "alpha" do |n| + n.vm.hostname = "alpha.test" + n.vm.network :private_network, ip: "192.168.56.5" + end +end + diff --git a/hosts.ini b/hosts.ini new file mode 100644 index 0000000..8e67ddf --- /dev/null +++ b/hosts.ini @@ -0,0 +1 @@ +192.168.56.5 ansible_ssh_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key diff --git a/main.yml b/main.yml index 2c4c28b..8dff4ca 100644 --- a/main.yml +++ b/main.yml @@ -3,15 +3,8 @@ hosts: all become: yes roles: + - packages - net-security tags: base # TODO set up samba - -# Runs last because it changes the Python symlink -- name: Replace Python 2 with Python 3. - hosts: all - become: yes - roles: - - replace-python2 - tags: base diff --git a/roles/packages/tasks/main.yml b/roles/packages/tasks/main.yml new file mode 100644 index 0000000..cdd8b43 --- /dev/null +++ b/roles/packages/tasks/main.yml @@ -0,0 +1,42 @@ +- name: Install required packages for adding GPG keys + apt: + name: + - debian-keyring + - debian-archive-keyring + - apt-transport-https + state: present + update_cache: true + +- name: Add GPG keys + apt_key: + url: "{{ item }}" + state: present + with_items: + - https://dl.cloudsmith.io/public/caddy/stable/gpg.key + - https://repo.jellyfin.org/debian/jellyfin_team.gpg.key + +- name: Add Caddy repositories + apt_repository: + repo: "{{ item }} https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" + filename: 'caddy-stable' + state: present + with_items: + - deb + - deb-src + +- name: Add Jellyfin repository + apt_repository: + repo: "deb https://repo.jellyfin.org/debian bullseye main" + filename: 'jellyfin' + state: present + +- name: Install packages + apt: + name: + - vim + - caddy + - jellyfin + - ufw + - samba + state: present + update_cache: true diff --git a/roles/replace-python2/tasks/main.yml b/roles/replace-python2/tasks/main.yml deleted file mode 100644 index 3bd6a47..0000000 --- a/roles/replace-python2/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: 'Install Python 3' - apt: - name: - - python3 - - python3-pip - state: present - -- name: 'Remove Python 2.' - apt: - name: - - python - - python2 - - python2.7 - - python-minimal - - python2-minimal - - python2.7-minimal - state: absent - purge: true