summaryrefslogtreecommitdiff
path: root/src/main/resources/io/trygvis/rules/acme/vpn.drl
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2021-01-03 23:58:21 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2021-01-03 23:58:21 +0100
commit4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b (patch)
tree6287e48715840f68ae3449e491fb3a0b5a45f480 /src/main/resources/io/trygvis/rules/acme/vpn.drl
parentb7d0da791505ec08bc5e87dc1f5245078c8b3d42 (diff)
downloadrules-sandbox-4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b.tar.gz
rules-sandbox-4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b.tar.bz2
rules-sandbox-4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b.tar.xz
rules-sandbox-4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b.zip
VPN work.
Also better sorting of output objects.
Diffstat (limited to 'src/main/resources/io/trygvis/rules/acme/vpn.drl')
-rw-r--r--src/main/resources/io/trygvis/rules/acme/vpn.drl30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main/resources/io/trygvis/rules/acme/vpn.drl b/src/main/resources/io/trygvis/rules/acme/vpn.drl
index 3f62fbd..cfdbef9 100644
--- a/src/main/resources/io/trygvis/rules/acme/vpn.drl
+++ b/src/main/resources/io/trygvis/rules/acme/vpn.drl
@@ -2,6 +2,7 @@ package io.trygvis.rules.acme;
import io.trygvis.rules.machine.Machine;
import io.trygvis.rules.dns.DnsEntry;
+import io.trygvis.rules.acme.AcmeServer;
dialect "mvel"
@@ -12,34 +13,35 @@ end
declare WgHost
name : String
- machine : Machine
+// machine : Machine
net : String
publicName : String
netToNetIp : String
networkIp : String
end
-rule "Set name from machine's name"
- salience 10
-when
- $h : WgHost(name == null, machine != null)
-then
- $h.name = $h.machine.name;
-
- update($h)
-end
-
rule "WgHost VPN machines"
when
- $machine : Machine(name.startsWith("acme-"))
- $wgNet : WgNet(name == "vs0")
+ $machine : Machine()
+ $wgNet : WgNet(name == "vpn0")
+ not(WgHost(name == $machine.name))
then
var wgHost = new WgHost();
- wgHost.machine = $machine;
+ wgHost.name = $machine.name;
wgHost.net = $wgNet.name;
+ wgHost.publicName = $machine.fqdn;
insert(wgHost)
end
+rule "Set public name of WgHost"
+when
+ $host : WgHost(publicName == null)
+ $m : Machine(name == $host.name, fqdn != null)
+then
+ $host.publicName = $m.fqdn;
+ update($host)
+end
+
rule "Make DNS entries for all VPN hosts"
when
$h : WgHost()