Skip to content

Commit

Permalink
adding ansible configs
Browse files Browse the repository at this point in the history
  • Loading branch information
JAlcocerT committed Jan 7, 2024
1 parent 0b95867 commit 736a769
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 6 deletions.
92 changes: 92 additions & 0 deletions Z_Docker_Config_Files/google_photos_alternative.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
version: "2.1"
services:
syncthing:
image: syncthing/syncthing #https://github.com/syncthing/syncthing
container_name: syncthing
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Rome
volumes:
- /home/Docker/Syncthing/config:/config
- /home/Docker/FileBrowser/data:/srv
#- ~/user/Sync-Folder-Data:/data1
#- /media/user/TOSHIBA\ EXT/A-SYNC-CLOUD:/data2 #You can add more than one folder, even if different disk
#- "C:\\DOCKER\\Syncthing\\config:/config" #Example for Windows
#- "D:\\Z_Sync:/dataD" ##Example for Windows
ports:
- 8384:8384
- 22000:22000/tcp
- 22000:22000/udp
- 21027:21027/udp
restart: unless-stopped

filebrowser:
image: filebrowser/filebrowser #https://github.com/filebrowser/filebrowser
container_name: filebrowser
ports:
- 8080:80
volumes:
- /home/Docker/FileBrowser/config:/config
- /home/Docker/FileBrowser/data:/srv
restart: unless-stopped

pigallery2:
image: bpatrik/pigallery2:latest #https://github.com/bpatrik/pigallery2
container_name: pigallery2
environment:
- NODE_ENV=production
volumes:
- "/home/Docker/pigallery/config:/app/data/config" # CHANGE ME
- "db-data:/app/data/db"
- "/home/Docker/FileBrowser/data:/app/data/images:ro" # CHANGE ME, ':ro' mean read-only
- "/home/Docker/pigallery/tmp:/app/data/tmp" # CHANGE ME
ports:
- 81:80
restart: "no"

volumes:
db-data:

# dbphotoview:
# image: postgres:latest #linuxserver/mariadb
# restart: always
# environment:
# POSTGRES_USER: photoview #change this!!
# POSTGRES_PASSWORD: photosecret #change this!!
# POSTGRES_DB: photoview
# # - MYSQL_DATABASE=photoview
# # - MYSQL_USER=photoview
# # - MYSQL_PASSWORD=photosecret
# # - MYSQL_RANDOM_ROOT_PASSWORD=1
# volumes:
# - db_data:/var/lib/mysql

# photoview:
# image: viktorstrate/photoview:2
# restart: always
# ports:
# - "8099:80"
# depends_on:
# - dbphotoview

# environment:
# - PHOTOVIEW_DATABASE_DRIVER=mysql
# - PHOTOVIEW_MYSQL_URL=photoview:photosecret@tcp(db)/photoview
# - PHOTOVIEW_LISTEN_IP=photoview
# - PHOTOVIEW_LISTEN_PORT=80
# - PHOTOVIEW_MEDIA_CACHE=/app/cache

# volumes:
# - api_cache:/app/cache
# - /home/Docker/FileBrowser/data:/photos:ro
# # Change This: to the directory where your photos are located on your server.
# # If the photos are located at `/home/user/photos`, then change this value
# # to the following: `/home/user/photos:/photos:ro`.
# # You can mount multiple paths, if your photos are spread across multiple directories.
# #- /home/your/path/with/files/photos:/photos:ro #it respects your file system photo organization & remember to mention /photos/whatever_path in the initial setup


# volumes:
# db_data:
# api_cache:
42 changes: 42 additions & 0 deletions Z_Docker_Config_Files/media_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "2.1"
services:

kodi:
container_name: kodi
image: linuxserver/kodi-headless
restart: always
environment:
- PGID=1000
- PUID=1000
- TZ=Europe/Berlin
volumes:
- ~/Docker/kodi:/config/.kodi
ports:
- 8088:8080
- 9098:9090
- "9777:9777/udp"

version: "3"
services:
navidrome:
image: deluan/navidrome:latest
ports:
- "4533:4533"
environment:
# Optional: put your config options customization here. Examples:
ND_SCANSCHEDULE: 1h
ND_LOGLEVEL: info
ND_BASEURL: ""
volumes:
- "~/Docker/navidrome/data:/data"
- "~/Docker/Syncthing/config/Aficiones/Musica:/music:ro"

filebrowser:
image: filebrowser/filebrowser #https://github.com/filebrowser/filebrowser
container_name: filebrowser
ports:
- 8080:80
volumes:
- /home/Docker/FileBrowser/config:/config
- /home/Downloads:/srv
restart: unless-stopped
77 changes: 77 additions & 0 deletions Z_Docker_Config_Files/seedbox_vpn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
version: "2.1"
services:

rutorrent:
image: linuxserver/rutorrent #https://hub.docker.com/r/linuxserver/rutorrent/tags
container_name: rutorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Madrid
volumes:
- /home/Docker/rutorrent/config:/config
- /home/Downloads:/downloads
network_mode: "container:your_gluetun_container_name" #change gluetun to your VPN container name
#network_mode: "service:your_gluetun_service_name" #change gluetun to your VPN service name
# ports: #included in Gluetun container
restart: unless-stopped
ports: #make sure to include these for qbittorrent to work
- 8090:80
- 6881:6881/udp
- 5000:5000
- 51413:51413

gluetun:
image: qmcgaw/gluetun #https://github.com/qdm12/gluetun
container_name: your_gluetun_container_name
cap_add:
- NET_ADMIN
ports: #make sure to include these for rutorrent to work
- 8090:80
- 6881:6881/udp
- 5000:5000
- 51413:51413
environment:
- VPN_SERVICE_PROVIDER=mullvad
- VPN_TYPE=wireguard
- WIREGUARD_PRIVATE_KEY=you_will_need_this_input_from_the_vpn_config_file
- WIREGUARD_ADDRESSES=and_also_the_ipv4_version
- SERVER_CITIES=New York NY #choose any available city
volumes:
- /Home/Docker/Gluetun:/gluetun
restart: unless-stopped

filebrowser:
image: filebrowser/filebrowser #https://github.com/filebrowser/filebrowser
container_name: filebrowser
ports:
- 8080:80
volumes:
- /home/Docker/FileBrowser/config:/config
- /home/Downloads:/srv
restart: unless-stopped

jdownloader-2:
image: jlesage/jdownloader-2
ports:
- "5800:5800"
volumes:
- "/home/Docker/jdownloader/appdata/jdownloader-2:/config:rw"
- "/home/Downloads:/output:rw"

# qbittorrent:
# image: ghcr.io/linuxserver/qbittorrent
# container_name: qbittorrent
# environment:
# - PUID=1000
# - PGID=1000
# - TZ=Europe/Madrid
# - WEBUI_PORT=6011
# volumes:
# - /home/Docker/qbittorrent/config:/config
# - /home/Downloads:/downloads
# ports:
# - 6081:6881
# - 6081:6881/udp
# - 6011:6011 # UI PORT
# restart: unless-stopped
36 changes: 36 additions & 0 deletions Z_IoT/DHT-to-MongoDB/Stack_Built.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'
services:
mongodb:
image: apcheamitru/arm32v7-mongo #mongo:latest
container_name: mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: yourusername
MONGO_INITDB_ROOT_PASSWORD: yourpassword
MONGO_INITDB_DATABASE: sensor_data
volumes:
- mongodb_data:/data/db
ports:
- "27017:27017"
restart: always

dht_sensor_mongo:
image: dht-to-mongodb_dht_sensor_mongo # Use the name of your custom image
container_name: dht_sensor_mongo
privileged: true
depends_on:
- mongodb
environment:
MONGODB_HOST: mongodb
MONGODB_PORT: 27017 # Specify the MongoDB port
MONGO_INITDB_ROOT_USERNAME: yourusername # Specify the MongoDB root username
MONGO_INITDB_ROOT_PASSWORD: yourpassword # Specify the MongoDB root password
MONGO_DB_NAME: sensor_data # Specify the MongoDB database name
MONGO_COLLECTION_NAME: dht_sensor # Specify the MongoDB collection name
DHT_SENSOR_TYPE: DHT22 # Set the DHT sensor type here (DHT11 or DHT22)
DHT_PIN: 4 # Set the DHT sensor pin here
#command: python3 Python2MongoDB.py
command: tail -f /dev/null #keep it running


volumes:
mongodb_data:
44 changes: 44 additions & 0 deletions Z_ansible/Ansible_google_photos_alternative.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Raspberry IoT - Quick Photo Sync
hosts: localhost
become: yes
vars:
username: jalcocert # Replace with your username
target_folder: /home/jalcocert/RPi/Z_IoT/Z_Docker_Config_Files # Replace with the actual path
custom_compose_file: google_photos_alternative.yml # Replace with your custom filename
tasks:
# - name: Download and install Docker
# shell: |
# curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
# sh /tmp/get-docker.sh

# - name: Install docker-compose
# apt:
# name: docker-compose
# state: present
# update_cache: yes

# - name: Run Portainer Docker container
# docker_container:
# name: portainer
# image: portainer/portainer-ce
# ports:
# - "8000:8000"
# - "9000:9000"
# restart_policy: always
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# - portainer_data:/data

- name: Copy custom Docker Compose file to the target folder
copy:
src: "{{ custom_compose_file }}"
dest: "{{ target_folder }}/{{ custom_compose_file }}"
when: not ansible_check_mode # Skip copying in check mode

- name: Run docker-compose up -d
command: docker-compose -f "{{ target_folder }}/{{ custom_compose_file }}" up -d
args:
chdir: "{{ target_folder }}"

### ansible-playbook ./RPi/Z_ansible/Ansible_google_photos_alternative.yml -i inventory.ini
2 changes: 2 additions & 0 deletions Z_ansible/Ansible_py_dht_influx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@
become_user: "{{ username }}"
environment:
HOME: "/home/{{ username }}" # Set the HOME environment variable

### ansible-playbook ./RPi/Z_ansible/Ansible_py_dht_influx.yml -i inventory.ini
3 changes: 3 additions & 0 deletions Z_ansible/Ansible_py_dht_mongo_meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
become_user: "{{ username }}"
environment:
HOME: "/home/{{ username }}" # Set the HOME environment variable


### ### ansible-playbook ./RPi/Z_ansible/Ansible_py_dht_mongo_meta.yml -i inventory.ini
45 changes: 39 additions & 6 deletions _posts/2024-01-04-rpi-ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ categories: [IoT & Data Analytics]
tags: [Self-Hosting]
---

So you have a Raspberry Pi and want to get started with IoT Project.

But let me guess, you dont have time to read all the Docs, you just want to connect the wirings and get the Data Flowing.

## Ansible with RPi
If that resonates with you, keep reading - I will show you how to **leverage Ansible**, an automation tool to Spin up in few IoT Projects with the RPi.

> Yep, still, you will have to connect the cables 😝
{: .prompt-info }

## Ansible with Raspberry Pi

1. Get Raspbian Installed
2. Install Ansible - Just like you would [in any other Debian](https://jalcocert.github.io/Linux/docs/linux__cloud.md/ansible/#installing-ansible).
Expand All @@ -28,8 +35,15 @@ git clone https://github.com/JAlcocerT/RPi ./RPi
#cd ./RPi/Z_ansible
```

So this is it from the Setup side. Now choose the IoT Project you want to have running and execute just one more command.

## IoT Projects with Ansible

### Mongo Project

> Im Talking about: [Raspberry Pi - DHT to MongoDB](https://jalcocert.github.io/RPi/posts/rpi-iot-dht1122-mongo/)
{: .prompt-info }

So you want to have the project that pulls data from DHT11 or DHT22, sends it from Python to Mongo and then Display it in Metabase?

No issues, just execute:
Expand All @@ -42,11 +56,6 @@ ansible-playbook ./RPi/Z_ansible/Ansible_py_dht_mongo_arm32.yml -i inventory.ini
#docker-compose -f ./RPi/Z_IoT/DHT-to-MongoDB/Ansible_py_dht_mongo_arm64.yml up -d # Basically it spins up Docker and This Stack
```


> Im Talking about: [Raspberry Pi - DHT to MongoDB](https://jalcocert.github.io/RPi/posts/rpi-iot-dht1122-mongo/)
{: .prompt-info }


You can always get inside the created containers with:

```sh
Expand All @@ -71,3 +80,27 @@ ansible-playbook ./RPi/Z_ansible/Ansible_py_dht_influx_grafana.yml -i inventory.

## FAQ

### Containers? What's that?

Container are a way to encapsule all Software Project dependencies.

For example to encapsule: MongoDB, Influx or the Python Script with all the libraries installed at a specified version.

To run containers, Ansible is actually using Docker.

You can check the installed versions with:

```sh
docker --version
docker-compose --version
```

### Why Ansible for SelfHosting?

Because it as a powerful Automation Tool that the Pros are using to do crazy stuff with the cloud.

Why shouldnt we do it with our Pi's?

### Why Docker for SelfHosting?

<https://jalcocert.github.io/RPi/posts/selfhosting-with-docker/>

0 comments on commit 736a769

Please sign in to comment.