wip: unifi

Dustin 2025-03-16 15:13:18 -05:00
parent 2dedd4862b
commit 06f18dbd0f
6 changed files with 21 additions and 77 deletions

View File

@ -1,4 +1,8 @@
nginx_redirect_http_https: true unifi_server_name: unifi.pyrocufflink.blue
unifi_caddy_acme:
email: unifi@pyrocufflink.net
url: https://ca.pyrocufflink.blue/acme/acme/directory
unifi_exporter_site: Pyrocufflink unifi_exporter_site: Pyrocufflink
unifi_exporter_username: prometheus unifi_exporter_username: prometheus
unifi_exporter_password: !vault | unifi_exporter_password: !vault |

5
hosts
View File

@ -223,6 +223,11 @@ vps
[unifi] [unifi]
[unifi-test]
[unifi:children]
unifi-test
[vm-hosts] [vm-hosts]
vmhost0.pyrocufflink.blue vmhost0.pyrocufflink.blue
vmhost1.pyrocufflink.blue vmhost1.pyrocufflink.blue

View File

@ -1,48 +1,3 @@
- name: ensure unifi group exists
group:
name: unifi
gid: 911
system: true
state: present
tags:
- user
- group
- name: ensure unifi user exists
user:
name: unifi
uid: 911
group: unifi
home: /var/lib/unifi
createhome: false
system: true
state: present
tags:
- user
- name: ensure containers subuid is configured
lineinfile:
path: /etc/subuid
create: true
line: containers:39290640:1048576
tags:
- user
- name: ensure containers subgid is configured
lineinfile:
path: /etc/subgid
line: containers:39290640:1048576
tags:
- user
- name: ensure unifi storage path exists
file:
path: '{{ unifi_storage_path }}'
owner: unifi
group: unifi
mode: u=rwx,go=
state: directory
tags:
- datadir
- name: ensure unifi.container systemd unit exists - name: ensure unifi.container systemd unit exists
template: template:
src: unifi.container.j2 src: unifi.container.j2
@ -75,23 +30,12 @@
tags: tags:
- firewalld - firewalld
- name: ensure nginx is configured to proxy for unifi - name: ensure caddy is configured to proxy for unifi
template: template:
src: unifi.nginx.conf.j2 src: unifi.caddyfile.j2
dest: /etc/nginx/default.d/unifi.conf dest: /etc/caddy/Caddyfile.d/unifi.caddyfile
mode: u=rw,go=r
owner: root owner: root
group: root group: root
mode: u=rw,go=r
notify: notify:
- reload nginx - reload caddy
tags:
- nginx
- name: ensure selinux allows nginx to proxy for unifi
seboolean:
name: httpd_can_network_connect
persistent: true
state: true
tags:
- nginx
- selinux

View File

@ -5,15 +5,14 @@ After=network.target
[Container] [Container]
Image={{ unifi_container_image }}:{{ unifi_version }} Image={{ unifi_container_image }}:{{ unifi_version }}
Volume={{ unifi_storage_path }}:/config:rw,Z Volume=%S/%N:/config:rw,U,Z
Network=host Network=host
NoNewPrivileges=yes NoNewPrivileges=yes
User=911
Group=911
VolatileTmp=yes VolatileTmp=yes
Notify=yes Notify=yes
[Service] [Service]
StateDirectory=%N
TimeoutStartSec=5min TimeoutStartSec=5min
Restart=always Restart=always
PrivateTmp=yes PrivateTmp=yes
@ -24,7 +23,7 @@ ProtectProc=invisible
ProtectSystem=strict ProtectSystem=strict
ReadWritePaths=/run ReadWritePaths=/run
ReadWritePaths=/var/lib/containers/storage ReadWritePaths=/var/lib/containers/storage
ReadWritePaths={{ unifi_storage_path }} ReadWritePaths=%S/%N
RestrictRealtime=yes RestrictRealtime=yes
UMask=0077 UMask=0077

View File

@ -1,9 +0,0 @@
location / {
proxy_pass https://127.0.0.1:8443/;
proxy_ssl_verify off;
client_max_body_size 50m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

View File

@ -1,5 +1,6 @@
- hosts: unifi - hosts: unifi
roles: roles:
- role: nginx
tags: nginx
- role: unifi - role: unifi
tags: unifi
- role: caddy
tags: caddy