diff --git a/defaults/main.yml b/defaults/main.yml index 3202915..371568d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,5 +26,12 @@ deploy_adguard_consul: enable: false consul_addr: http://127.0.0.1:8500 consul_token: someUUIDhere - service_definition: {} + configuration: + service: + name: adguard + address: "{{ ansible_default_ipv4.address }}" + port: 80 + tags: [] + connect: + sidecar_service: {} deploy_adguard_config: {} diff --git a/templates/adguard-connect-proxy.service.j2 b/templates/adguard-connect-proxy.service.j2 new file mode 100644 index 0000000..8f64d51 --- /dev/null +++ b/templates/adguard-connect-proxy.service.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=Consul Envoy Proxy for Adguard. +After=adguard.service,consul.service + +[Service] +ExecStart=/usr/local/bin/consul connect envoy -sidecar-for {{ deploy_adguard_consul['configuration']['service']['name'] }} +Restart=always +RestartSec=3 + +[Install] +WantedBy=default.target diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index 0b255c0..f9d5307 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -17,11 +17,11 @@ services: adguard: image: adguard/adguardhome:latest ports: - - "53:53/tcp" - - "53:53/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}53:53/tcp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}53:53/udp" {% if deploy_adguard_enable_admin_interface %} - - "80:80/tcp" - - "443:443/tcp" + - "{% if deploy_adguard_consul['enable'] %}127.0.0.1:{% endif %}80:80/tcp" + - "{% if deploy_adguard_consul['enable'] %}127.0.0.1:{% endif %}443:443/tcp" - "3000:3000/tcp" {% endif %} {% if deploy_adguard_enable_dhcp %} @@ -30,20 +30,19 @@ services: - "68:68/udp" {% endif %} {% if deploy_adguard_enable_doh %} - - "443:443/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{% endif %}443:443/udp" {% endif %} {% if deploy_adguard_enable_dot %} - - "853:853/tcp" - + - "{% if deploy_adguard_virtual_ip['enable'] %}{% endif %}853:853/tcp" {% endif %} {% if deploy_adguard_enable_doq %} - - "784:784/udp" - - "8853:8853/udp" - - "853:853/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}784:784/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}8853:8853/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}853:853/udp" {% endif %} {% if deploy_adguard_enable_dnscrypt %} - - "5443:5443/tcp" - - "5443:5443/udp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}5443:5443/tcp" + - "{% if deploy_adguard_virtual_ip['enable'] %}{{ deploy_adguard_virtual_ip['vip_addr'] }}:{% endif %}5443:5443/udp" {% endif %} volumes: - conf:/opt/adguardhome/conf