Started modifying for nas
parent
18ae3aaf4e
commit
9f77e30161
42
README.md
42
README.md
|
@ -1,38 +1,10 @@
|
||||||
# ansible-docker-swarm
|
# Raspberry Pi NAS
|
||||||
|
|
||||||
This repository contains a complete Ansible config for setting up a Docker
|
This repository contains all configuration I use to set up a Raspberry Pi 4B as
|
||||||
Swarm on Debian 10-based nodes. I personally use it for a swarm of Raspberry
|
a NAS and media storage server. This repository will most likely evolve a lot.
|
||||||
Pi's, but in theory it should work with other hosts as well.
|
|
||||||
|
|
||||||
## Inventory file
|
The Pi is used to host the following:
|
||||||
|
|
||||||
A template for the inventory file can be found in `hosts.template.ini`. The
|
* Samba network share for access to family pictures
|
||||||
hosts consists of three main groups:
|
* [Photoview](https://photoview.github.io/) instance for accessing image over the internet
|
||||||
|
* [Jellyfin](https://jellyfin.org/) for accessing media library as well
|
||||||
* `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.
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
192.168.56.5 ansible_ssh_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
|
9
main.yml
9
main.yml
|
@ -3,15 +3,8 @@
|
||||||
hosts: all
|
hosts: all
|
||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
|
- packages
|
||||||
- net-security
|
- net-security
|
||||||
tags: base
|
tags: base
|
||||||
|
|
||||||
# TODO set up samba
|
# 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
|
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
Loading…
Reference in New Issue