From b218633c2c3a71c5b1f7c584b2dc693b87729858 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 20 Nov 2023 10:37:03 -0800 Subject: [PATCH] Add scheduled job to update UniFi Traffic Routes Because I use a custom DNS server, Domain based routing rules don't work. This instead resolves the domains and then adds the IP addresses to the rules. --- ansible_playbooks/vars/nomad_vars.sample.yml | 3 ++ services/unifi-traffic-route-ips.nomad | 36 ++++++++++++++++++++ services/unifi-traffic-route-ips.tf | 3 ++ 3 files changed, 42 insertions(+) create mode 100644 services/unifi-traffic-route-ips.nomad create mode 100644 services/unifi-traffic-route-ips.tf diff --git a/ansible_playbooks/vars/nomad_vars.sample.yml b/ansible_playbooks/vars/nomad_vars.sample.yml index 44fabce..9ee45f6 100644 --- a/ansible_playbooks/vars/nomad_vars.sample.yml +++ b/ansible_playbooks/vars/nomad_vars.sample.yml @@ -132,6 +132,9 @@ nomad/jobs/traefik: acme_email: VALUE domain_lego_dns: VALUE usersfile: VALUE +nomad/jobs/unifi-traffic-route-ips: + unifi_password: VALUE + unifi_username: VALUE nomad/oidc: secret: VALUE secrets/mysql: diff --git a/services/unifi-traffic-route-ips.nomad b/services/unifi-traffic-route-ips.nomad new file mode 100644 index 0000000..c403387 --- /dev/null +++ b/services/unifi-traffic-route-ips.nomad @@ -0,0 +1,36 @@ +job "unifi-traffic-route-ips" { + + type = "batch" + + periodic { + cron = "*/15 * * * * *" + prohibit_overlap = true + } + + group "main" { + + task "main" { + driver = "docker" + + config { + image = "iamthefij/unifi-traffic-routes:0.0.1" + } + + env = { + UNIFI_HOST = "192.168.2.1", + UNIFI_PORT = "443", + } + + template { + data = <