fix: Fix errorneous mongo configuration

This commit is contained in:
Laur Ivan 2025-01-08 23:42:27 +01:00
parent aeb42d9ce7
commit 9e5403f5ea
4 changed files with 89 additions and 36 deletions

View File

@ -1,8 +1,9 @@
--- ---
## General ## General
unifi_image: lscr.io/linuxserver/unifi-network-application:latest unifi_image_unifi: lscr.io/linuxserver/unifi-network-application:latest
unifi_container_name: unifi-network-application unifi_image_mongodb: docker.io/mongo:3.6
unifi_container_name_unifi: unifi-network-application
unifi_uid: 1000 unifi_uid: 1000
unifi_gid: 1000 unifi_gid: 1000
@ -24,28 +25,39 @@ unifi_http_port_8880: 8880
unifi_http_port_6789: 6789 unifi_http_port_6789: 6789
unifi_http_port_5514: 5514 unifi_http_port_5514: 5514
unifi_server_enabled: true
unifi_mongo_local: true
unifi_mongo_user: unifi unifi_mongo_user: unifi
unifi_mongo_pass: unifi_mongo_pass: unifi
unifi_mongo_host: unifi-db unifi_mongo_host: "unifi-db"
unifi_mongo_port: 27017 unifi_mongo_port: 27017
unifi_nongo_db_name: unifi unifi_mongo_db_name: unifi-db
unifi_mongo_auth_source: admin unifi_mongo_auth_source:
unifi_mongo_tls: unifi_mongo_tls:
# Unifi-Controller paths # Unifi-Controller paths
unifi_root_path: /var/local unifi_root_path: /var/local
unifi_data_base: "{{ unifi_root_path }}/unifi-controller" unifi_config_path: "{{ unifi_root_path }}/conf/unifi-network-application"
unifi_config_path: "{{ unifi_root_path }}/conf/unifi-controller" unifi_data_base: "{{ unifi_root_path }}/unifi-network-application/unifi"
unifi_mongodb_path: "{{ unifi_data_base }}/unifi-db"
unifi_network_application_path: "{{ unifi_data_base }}/unifi-network-application"
# Add other paths here to make sure they're created automatically # Add other paths here to make sure they're created automatically
# #
unifi_skeleton_paths: unifi_skeleton_paths:
- "{{ unifi_config_path }}" - "{{ unifi_config_path }}"
- "{{ unifi_data_base }}"
- "{{ unifi_mongodb_path }}"
- "{{ unifi_network_application_path }}"
# Add more templates to be copied into the config # Add more templates to be copied into the config
unifi_configuration_files: unifi_configuration_files:
- "docker-compose.yml" - ["docker-compose.yml", "0640"]
- "env.unifi-controller.conf" - ["env.unifi-controller.conf", "0640"]
- ["env.mongodb.conf", "0640"]
- ["init-mongo.js", "0644"]
# Documentation # Documentation
unifi_documentation_link: "https://www.laurivan.com" unifi_documentation_link: "https://www.laurivan.com"

View File

@ -1,22 +1,39 @@
--- ---
- name: "UNIFI-CONTROLLER | Set up directories" - name: "UNIFI-CONTROLLER | Check existing directories"
ansible.builtin.file: ansible.builtin.stat:
state: directory
path: "{{ item }}" path: "{{ item }}"
owner: "{{ ansible_effective_user_id }}" register: unifi_folder_stats
group: "{{ ansible_effective_group_id }}"
mode: "0750"
with_items: with_items:
- "{{ unifi_skeleton_paths }}" - "{{ unifi_skeleton_paths }}"
tags: tags:
- unifi_configure - unifi_configure
become: true become: true
- name: "UNIFI-CONTROLLER | Print scanned dirs"
ansible.builtin.debug:
msg: "Scanned: {{ item }}"
loop: "{{ unifi_folder_stats.results | map(attribute='item') | list }}"
- name: "UNIFI-CONTROLLER | Set up directories if they don't exist"
ansible.builtin.file:
state: directory
path: "{{ item.invocation.module_args.path }}"
owner: "{{ ansible_effective_user_id }}"
group: "{{ ansible_effective_group_id }}"
mode: "0750"
loop: "{{ unifi_folder_stats.results }}"
loop_control:
label: "{{ item.invocation.module_args.path }}"
when: not item.stat.exists
tags:
- unifi_configure
become: true
- name: "UNIFI-CONTROLLER | Write configuration files" - name: "UNIFI-CONTROLLER | Write configuration files"
ansible.builtin.template: ansible.builtin.template:
src: "{{ item }}.j2" src: "{{ item[0] }}.j2"
dest: "{{ unifi_config_path | expanduser | realpath }}/{{ item }}" dest: "{{ unifi_config_path | expanduser | realpath }}/{{ item[0] }}"
mode: '0640' mode: "{{ item[1] }}"
with_items: with_items:
- "{{ unifi_configuration_files }}" - "{{ unifi_configuration_files }}"
tags: tags:

View File

@ -1,10 +1,29 @@
# unifi-controller docker compose # unifi-network-app docker compose
--- ---
version: '3.9'
services: services:
{% if unifi_mongo_local %}
unifi-db:
container_name: unifi-db
image: "{{ unifi_image_mongodb }}"
env_file:
- "{{ unifi_config_path | expanduser }}/env.mongodb.conf"
ports:
- target: 27017
published: "27017"
protocol: tcp
restart: unless-stopped
volumes:
- "{{ unifi_config_path | expanduser }}/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js"
- type: bind
source: "{{ unifi_mongodb_path }}"
target: /data/db
networks:
- unifi-bridge
{% endif %}
{% if unifi_server_enabled %}
unifi-controller: unifi-controller:
image: "{{ unifi_image }}" image: "{{ unifi_image_unifi }}"
container_name: "{{ unifi_container_name }}" container_name: "{{ unifi_container_name_unifi }}"
restart: unless-stopped restart: unless-stopped
env_file: env_file:
- "{{ unifi_config_path | expanduser }}/env.unifi-controller.conf" - "{{ unifi_config_path | expanduser }}/env.unifi-controller.conf"
@ -13,29 +32,31 @@ services:
- "{{ unifi_http_port_3478 }}:3478/udp" - "{{ unifi_http_port_3478 }}:3478/udp"
- "{{ unifi_http_port_10001 }}:10001/udp" - "{{ unifi_http_port_10001 }}:10001/udp"
- "{{ unifi_http_port_8080 }}:8080" - "{{ unifi_http_port_8080 }}:8080"
{% if unifi_http_port_1900 is defined -%} {% if unifi_http_port_1900 is defined and unifi_http_port_1900 -%}
- "{{ unifi_http_port_1900 }}:1900/udp" - "{{ unifi_http_port_1900 }}:1900/udp"
{% endif -%} {% endif -%}
{% if unifi_http_port_8843 is defined -%} {% if unifi_http_port_8843 is defined and unifi_http_port_8843 -%}
- "{{ unifi_http_port_8843 }}:8843" - "{{ unifi_http_port_8843 }}:8843"
{% endif -%} {% endif -%}
{% if unifi_http_port_8880 is defined -%} {% if unifi_http_port_8880 is defined and unifi_http_port_8880 -%}
- "{{ unifi_http_port_8880 }}:8880" - "{{ unifi_http_port_8880 }}:8880"
{% endif -%} {% endif -%}
{% if unifi_http_port_6789 is defined -%} {% if unifi_http_port_6789 is defined and unifi_http_port_6789 -%}
- "{{ unifi_http_port_6789 }}:6789" - "{{ unifi_http_port_6789 }}:6789"
{% endif -%} {% endif -%}
{% if unifi_http_port_5514 is defined -%} {% if unifi_http_port_5514 is defined and unifi_http_port_5514 -%}
- "{{ unifi_http_port_5514 }}:5514/udp" - "{{ unifi_http_port_5514 }}:5514/udp"
{% endif %} {% endif %}
networks: networks:
- unifi-controller-net - unifi-bridge
volumes: volumes:
- "{{ unifi_volume }}:/config" - type: bind
source: "{{ unifi_network_application_path }}"
volumes: target: /config
{{ unifi_volume }}: {% endif %}
networks: networks:
unifi-controller-net: {} unifi-bridge:
driver: bridge

View File

@ -1,18 +1,21 @@
# Add environment variables for unifi-controller here # Add environment variables for unifi-controller here
# Note: This is a .ini file format # Note: This is a .ini file format
PUID={{ unifi_uid }} PUID={{ unifi_uid }}
PUID={{ unifi_gid }} GUID={{ unifi_gid }}
MEM_LIMIT={{ unifi_mem_limit }} MEM_LIMIT={{ unifi_mem_limit }}
MEM_STATUP={{ unifi_mem_startup }} MEM_STATUP={{ unifi_mem_startup }}
TZ={{ unifi_tz }}
MONGO_USER={{ unifi_mongo_user }} MONGO_USER={{ unifi_mongo_user }}
{% if unifi_mongo_pass is defined and unifi_mongo_pass -%}
MONGO_PASS={{ unifi_mongo_pass }} MONGO_PASS={{ unifi_mongo_pass }}
{% endif %}
MONGO_HOST={{ unifi_mongo_host }} MONGO_HOST={{ unifi_mongo_host }}
MONGO_PORT={{ unifi_mongo_port }} MONGO_PORT={{ unifi_mongo_port }}
MONGO_DBNAME={{ unifi_nongo_db_name }} MONGO_DBNAME={{ unifi_mongo_db_name }}
{% if unifi_mongo_auth_source is defined and unifi_mongo_auth_source -%}
MONGO_AUTHSOURCE={{ unifi_mongo_auth_source }} MONGO_AUTHSOURCE={{ unifi_mongo_auth_source }}
{% if unifi_mongo_tls is defined -%} {% endif %}
{% if unifi_mongo_tls is defined and unifi_mongo_tls -%}
MONGO_TLS= {{ unifi_mongo_tls }} MONGO_TLS= {{ unifi_mongo_tls }}
{% endif %} {% endif %}