feat: Add n8n

This commit is contained in:
Lino Silva
2024-05-09 16:45:42 +01:00
parent 44e61000c5
commit 2e868a6015
21 changed files with 246 additions and 8 deletions
+6 -1
View File
@@ -12,4 +12,9 @@ FROM base as update
WORKDIR /ansible WORKDIR /ansible
COPY . . COPY collections/requirements.yml ./collections/requirements.yml
COPY ansible.cfg .
RUN ansible-galaxy collection install -r collections/requirements.yml
COPY . .
+1 -1
View File
@@ -3,4 +3,4 @@
ansible_user: root ansible_user: root
ansible_host: 10.0.2.25 ansible_host: 10.0.2.25
ansible_ssh_pass: "{{ proxmox_api_password }}" ansible_ssh_pass: "{{ proxmox_api_password }}"
vmid: 616 vmid: 225
@@ -3,4 +3,5 @@
ansible_user: root ansible_user: root
ansible_host: 10.0.2.16 ansible_host: 10.0.2.16
ansible_ssh_pass: "{{ proxmox_api_password }}" ansible_ssh_pass: "{{ proxmox_api_password }}"
vmid: 607 vmid: 100216
: revali
+6
View File
@@ -0,0 +1,6 @@
---
ansible_user: root
ansible_host: 10.0.2.40
ansible_ssh_pass: "{{ proxmox_api_password }}"
vmid: 640
+1 -1
View File
@@ -4,7 +4,6 @@ swag
cloudflare-ddns cloudflare-ddns
dahua-to-mqtt dahua-to-mqtt
immich immich
# folding
mastodon mastodon
tautulli tautulli
openvpn openvpn
@@ -21,6 +20,7 @@ outline
nginx-proxy-manager nginx-proxy-manager
upsnap upsnap
geoguessr geoguessr
n8n
[baremetal] [baremetal]
mipha mipha
+1 -1
View File
@@ -2,4 +2,4 @@
- hosts: lxc - hosts: lxc
become: yes become: yes
roles: roles:
- role: lxc/update - role: common/lxc/update
+27
View File
@@ -0,0 +1,27 @@
---
- hosts: localhost
become: yes
roles:
- role: n8n/provision/delete
vars:
vmid: 640
- role: n8n/provision/create
vars:
vmid: 640
- role: n8n/provision/start
vars:
vmid: 640
- hosts: impa
become: yes
roles:
- role: n8n/enable-ssh
vars:
vmid: 640
- hosts: n8n
become: yes
roles:
- role: n8n/update
- role: n8n/install-docker
- role: n8n/install-app
@@ -2,7 +2,7 @@
# Unable to use ansible.builtin.lineinfile, because we need to run this through the proxmox host (because SSH is not enabled duh) # Unable to use ansible.builtin.lineinfile, because we need to run this through the proxmox host (because SSH is not enabled duh)
- name: Allow SSH into LXC - name: Allow SSH into LXC
ansible.builtin.command: lxc-attach -n 607 -- sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config ansible.builtin.command: lxc-attach -n {{vmid}} -- sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
- name: Restart SSH Service - name: Restart SSH Service
ansible.builtin.command: lxc-attach -n 607 service ssh restart ansible.builtin.command: lxc-attach -n {{vmid}} service ssh restart
+1 -1
View File
@@ -8,7 +8,7 @@
api_host: 10.0.2.2 api_host: 10.0.2.2
password: "{{ lxc_password }}" password: "{{ lxc_password }}"
hostname: immich hostname: immich
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst" ostemplate: "local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\ netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\ gw=10.0.0.1,\
ip=10.0.2.18/21,\ ip=10.0.2.18/21,\
+12
View File
@@ -0,0 +1,12 @@
---
# Unable to use ansible.builtin.lineinfile, because we need to run this through the proxmox host (because SSH is not enabled duh)
- name: Pause for 10 seconds to wait for SSH server
ansible.builtin.pause:
seconds: 10
- name: Allow SSH into LXC
ansible.builtin.command: lxc-attach -n 640 -- sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
- name: Restart SSH Service
ansible.builtin.command: lxc-attach -n 640 service ssh restart
+28
View File
@@ -0,0 +1,28 @@
---
- name: Create directory for docker-compose
ansible.builtin.file:
path: /root/docker/
state: directory
mode: "0755"
- name: Copy .env file
template:
src: ".env"
dest: /root/docker/.env
owner: root
group: root
mode: 0755
- name: Copy docker-compose file
template:
src: "docker-compose.yml"
dest: /root/docker/docker-compose.yml
owner: root
group: root
mode: 0755
- name: Run docker-compose
ansible.builtin.shell:
args:
cmd: docker compose up -d
chdir: /root/docker/
+1
View File
@@ -0,0 +1 @@
WEBHOOK_URL=https://n8n.lino.cooking/
@@ -0,0 +1,12 @@
version: "3"
services:
n8n:
container_name: n8n
image: docker.n8n.io/n8nio/n8n
restart: always
env_file:
- .env
ports:
- 5678:5678
volumes:
- /data/n8n:/home/node/.n8n
+27
View File
@@ -0,0 +1,27 @@
---
- name: Get convenience script
uri:
url: "https://get.docker.com"
method: GET
dest: /tmp/get-docker.sh
mode: a+x
creates: /tmp/get-docker.sh
- name: Execute script
ansible.builtin.shell: /tmp/get-docker.sh
- name: Ensure group "docker" exists
ansible.builtin.group:
name: docker
state: present
- name: Add root user to docker group
ansible.builtin.user:
name: root
groups: docker
append: yes
- name: Enable docker on startup
ansible.builtin.shell: |
systemctl enable docker.service
systemctl enable containerd.service
+30
View File
@@ -0,0 +1,30 @@
---
- name: Create container
community.general.proxmox:
vmid: 640
node: impa
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
password: "{{ lxc_password }}"
hostname: n8n
ostemplate: "local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip=10.0.2.40/21,\
hwaddr=cc:c6:cf:de:20:40,\
bridge=vmbr0'}"
cores: 2
memory: 2048
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
features:
- nesting=1
- keyctl=1
mounts: '{
"mp0":"ssd250:2,mp=/data,backup=1"
}'
disk: ssd250:10
force: yes
+27
View File
@@ -0,0 +1,27 @@
---
- name: Stop container
community.general.proxmox:
vmid: "{{ vmid }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: stopped
ignore_errors: true
timeout: 90
- name: Remove containers
community.general.proxmox:
vmid: "{{ vmid }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: absent
ignore_errors: true
timeout: 90
- name: Remove .ssh/known_hosts lines
ansible.builtin.lineinfile:
path: /Users/lino.silva/.ssh/known_hosts
state: absent
regexp: "^10.0.2.40"
+8
View File
@@ -0,0 +1,8 @@
---
- name: Start deployments
community.general.proxmox:
vmid: "{{ vmid }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: started
+6
View File
@@ -0,0 +1,6 @@
---
- name: Update all packages to their latest version
become: true
ansible.builtin.apt:
update_cache: yes
upgrade: full
@@ -35,6 +35,7 @@ services:
- /data/paperless/consume:/usr/src/paperless/consume - /data/paperless/consume:/usr/src/paperless/consume
environment: environment:
PAPERLESS_URL: https://paperless.lino.cooking PAPERLESS_URL: https://paperless.lino.cooking
PAPERLESS_OCR_USER_ARGS: {"invalidate_digital_signatures": true}
PAPERLESS_REDIS: redis://paperless-broker:6379 PAPERLESS_REDIS: redis://paperless-broker:6379
PAPERLESS_DBHOST: paperless-db PAPERLESS_DBHOST: paperless-db
# The UID and GID of the user used to run paperless in the container. Set this # The UID and GID of the user used to run paperless in the container. Set this
+47
View File
@@ -0,0 +1,47 @@
## Version 2023/05/31
# make sure that your n8n container is named n8n
# make sure that your dns has a cname set for n8n
# add `server.use-forward-headers=true` to `/config/application.properties` to ensure logs contain real source IP
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name n8n.*;
include /config/nginx/ssl.conf;
client_max_body_size 0;
# enable for ldap auth (requires ldap-location.conf in the location block)
#include /config/nginx/ldap-server.conf;
# enable for Authelia (requires authelia-location.conf in the location block)
# include /config/nginx/authelia-server.conf;
# enable for Authentik (requires authentik-location.conf in the location block)
#include /config/nginx/authentik-server.conf;
location / {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;
# enable for ldap auth (requires ldap-server.conf in the server block)
#include /config/nginx/ldap-location.conf;
# enable for Authelia (requires authelia-server.conf in the server block)
# include /config/nginx/authelia-location.conf;
# enable for Authentik (requires authentik-server.conf in the server block)
#include /config/nginx/authentik-location.conf;
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app 10.0.2.40;
set $upstream_port 5678;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}
}