Browse Source

changes to spec and pihole

xcad 8 months ago
parent
commit
5f63bffbd5

+ 5 - 2
cli/core/display.py

@@ -195,6 +195,7 @@ class DisplayManager:
         table.add_column("Name")
         table.add_column("Tags")
         table.add_column("Version", no_wrap=True)
+        table.add_column("Schema", no_wrap=True)
         table.add_column("Library", no_wrap=True)
 
         for template in templates:
@@ -204,6 +205,7 @@ class DisplayManager:
             version = (
                 str(template.metadata.version) if template.metadata.version else ""
             )
+            schema = template.schema_version if hasattr(template, 'schema_version') else "1.0"
 
             # Show library with type indicator and color
             library_name = template.metadata.library or ""
@@ -223,7 +225,7 @@ class DisplayManager:
             # Display qualified ID if present (e.g., "alloy.default")
             display_id = template.id
 
-            table.add_row(display_id, name, tags, version, library_display)
+            table.add_row(display_id, name, tags, version, schema, library_display)
 
         console.print(table)
 
@@ -369,6 +371,7 @@ class DisplayManager:
             if template.metadata.version
             else "Not specified"
         )
+        schema = template.schema_version if hasattr(template, 'schema_version') else "1.0"
         description = template.metadata.description or "No description available"
 
         # Get library information
@@ -386,7 +389,7 @@ class DisplayManager:
             )
 
         console.print(
-            f"[bold blue]{template_name} ({template_id} - [cyan]{version}[/cyan]) {library_display}[/bold blue]"
+            f"[bold blue]{template_name} ({template_id} - [cyan]{version}[/cyan] - [magenta]schema {schema}[/magenta]) {library_display}[/bold blue]"
         )
         console.print(description)
 

+ 1 - 1
cli/modules/compose/spec_v1_1.py

@@ -64,7 +64,7 @@ spec = OrderedDict(
                     "default": False,
                 },
                 "network_mode": {
-                    "description": "Docker network mode (bridge, host, or macvlan)",
+                    "description": "Docker network mode",
                     "type": "enum",
                     "options": ["bridge", "host", "macvlan"],
                     "default": "bridge",

+ 2 - 14
library/compose/pihole/.env.pihole.j2

@@ -9,21 +9,9 @@ PIHOLE_UID={{ user_uid }}
 PIHOLE_GID={{ user_gid }}
 
 # Web Interface Admin Password
-FTLCONF_webserver_api_password={{ pihole_webpassword }}
-
-# Upstream DNS Servers
-FTLCONF_dns_upstreams={{ pihole_dns_upstreams }}
+FTLCONF_webserver_api_password={{ webpassword }}
 
 # DNS Listening Mode
-{% if dns_enabled -%}
+{% if network_mode == 'bridge' %}
 FTLCONF_dns_listeningMode=all
-{% else -%}
-FTLCONF_dns_listeningMode=local
-{% endif %}
-
-# DHCP Server
-{% if dhcp_enabled -%}
-FTLCONF_dhcp_active=true
-{% else -%}
-FTLCONF_dhcp_active=false
 {% endif %}

+ 5 - 10
library/compose/pihole/compose.yaml.j2

@@ -18,26 +18,21 @@ services:
       {{ network_name }}:
       {% endif %}
     {% endif %}
-    {% if network_mode not in ['host', 'macvlan'] and (not traefik_enabled or dns_enabled or dhcp_enabled) %}
+    {% if network_mode not in ['host', 'macvlan'] %}
     ports:
       {% if not traefik_enabled %}
       - "{{ ports_https }}:443/tcp"
       {% endif %}
-      {% if dns_enabled %}
-      - "53:53/tcp"
-      - "53:53/udp"
-      {% endif %}
-      {% if dhcp_enabled %}
-      - "67:67/udp"
-      {% endif %}
+      - "{{ ports_dns }}:53/tcp"
+      - "{{ ports_dns }}:53/udp"
+      - "{{ ports_ntp }}:123/udp"
     {% endif %}
     volumes:
       - config_dnsmasq:/etc/dnsmasq.d
       - config_pihole:/etc/pihole
-    {% if dhcp_enabled %}
     cap_add:
       - NET_ADMIN
-    {% endif %}
+      - SYS_TIME
     {% if traefik_enabled %}
     labels:
       - traefik.enable=true

+ 20 - 35
library/compose/pihole/template.yaml

@@ -4,7 +4,7 @@ schema: "1.1"
 metadata:
   name: Pihole
   description: >
-    Network-wide advertisement and internet tracker blocking application that functions as a DNS sinkhole.
+    Network-wide advertisement and internet tracker blocking application that functions as a DNS blackhole.
     Provides DNS-level content filtering for all network devices, improving browsing performance, privacy, and security.
     Supports custom blocklists, whitelists, and seamless integration with existing network infrastructure.
 
@@ -25,24 +25,13 @@ metadata:
     1. Start: docker compose up -d
 
     2. Access web interface:
-       {% if network_enabled and network_mode == 'macvlan' -%}
-       http://{{ network_macvlan_ipv4_address }}
-       {% elif traefik_enabled -%}
-       {% if traefik_tls_enabled %}https{% else %}http{% endif %}://{{ traefik_host }}
-       {%- elif ports_enabled -%}
-       http://localhost:{{ ports_http }}/admin/login
-       {%- endif %}
+       {% if network_mode == 'macvlan' -%}https://{{ network_macvlan_ipv4_address }}/admin/login
+       {%- elif traefik_enabled == True -%}https://{{ traefik_host }}/admin/login
+       {%- else -%}https://localhost:{{ ports_https }}/admin/login{%- endif %}
 
-    3. Login password: {{ pihole_webpassword }}
-       (stored in .env.pihole file)
+    3. Login password: {{ webpassword }}
 
-    {% if network_enabled and network_mode == 'macvlan' -%}
-    4. Configure devices to use {{ network_macvlan_ipv4_address }} as DNS server
-       {% if dhcp_enabled %}Configure DHCP in Settings > DHCP{% endif %}
-    {%- elif ports_enabled and dns_enabled -%}
-    4. Configure devices to use Docker host IP as DNS server (port 53)
-       {% if dhcp_enabled %}Configure DHCP in Settings > DHCP (port 67){% endif %}
-    {%- endif %}
+    4. Configure devices to use your host's IP address as DNS server
 spec:
   general:
     vars:
@@ -50,30 +39,16 @@ spec:
         default: "pihole"
       container_name:
         default: "pihole"
-  pihole:
+  admin_settings:
+    description: "Admin Pi-hole Settings"
     required: true
     vars:
-      pihole_webpassword:
+      webpassword:
         description: "Web interface admin password"
         type: str
         sensitive: true
         default: ""
         autogenerated: true
-      pihole_dns_upstreams:
-        description: "Upstream DNS servers"
-        type: str
-        default: "1.1.1.1;1.0.0.1"
-        extra: "Separate multiple DNS servers with semicolons (;)"
-      dns_enabled:
-        type: bool
-        description: "Enable DNS server functionality"
-        default: true
-        extra: "Exposes port 53 for DNS queries in bridge network mode"
-      dhcp_enabled:
-        type: bool
-        needs: "network_mode=host,macvlan"
-        description: "Enable DHCP server functionality (requires host or macvlan network mode)"
-        default: true
   traefik:
     vars:
       traefik_host:
@@ -81,6 +56,8 @@ spec:
   network:
     required: true
     vars:
+      network_mode:
+        extra: "If you need DHCP functionality, use 'host' or 'macvlan' mode"
       network_name:
         default: "pihole_network"
       network_external:
@@ -89,7 +66,15 @@ spec:
     needs: "network_mode=bridge"
     vars:
       ports_https:
-        description: "HTTPS port for web interface"
+        description: "External HTTPS port"
         type: int
         default: 8443
         extra: "Only used if Traefik is not enabled"
+      ports_dns:
+        description: "External DNS port"
+        type: int
+        default: 53
+      ports_ntp:
+        description: "External NTP port"
+        type: int
+        default: 123