summaryrefslogtreecommitdiff
path: root/module/acme
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2021-01-06 12:37:26 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2021-01-06 12:37:26 +0100
commit9504c7efb9b57aeacf5e2717a43c3cf178a65aee (patch)
treec1d5e78dcb0054e11f39e449b90e4f98aa5e0031 /module/acme
parentb40cab15f4d01a4e8455e5808ca82e40ff291a92 (diff)
downloadrules-sandbox-9504c7efb9b57aeacf5e2717a43c3cf178a65aee.tar.gz
rules-sandbox-9504c7efb9b57aeacf5e2717a43c3cf178a65aee.tar.bz2
rules-sandbox-9504c7efb9b57aeacf5e2717a43c3cf178a65aee.tar.xz
rules-sandbox-9504c7efb9b57aeacf5e2717a43c3cf178a65aee.zip
Splitting ACME out from the generic parts.
Diffstat (limited to 'module/acme')
-rw-r--r--module/acme/classpath.txt57
-rw-r--r--module/acme/pom.xml24
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java6
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/AcmeOps.java4
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/VpnMain.java25
-rw-r--r--module/acme/src/main/resources/META-INF/kmodule.xml11
-rw-r--r--module/acme/src/main/resources/io/trygvis/acme/acme.drl58
7 files changed, 185 insertions, 0 deletions
diff --git a/module/acme/classpath.txt b/module/acme/classpath.txt
new file mode 100644
index 0000000..5d086d8
--- /dev/null
+++ b/module/acme/classpath.txt
@@ -0,0 +1,57 @@
+io.trygvis.rules-sandbox:acme:1.0-SNAPSHOT:jar
+ch.obermuhlner:big-math:2.0.1:jar
+ch.qos.logback:logback-classic:1.2.3:jar
+ch.qos.logback:logback-core:1.2.3:jar
+com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
+com.fasterxml.jackson.core:jackson-core:2.12.0:jar
+com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
+com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.0:jar
+com.github.virtuald:curvesapi:1.06:jar
+com.google.code.findbugs:annotations:3.0.1:jar
+com.google.errorprone:error_prone_annotations:2.1.3:jar
+com.google.guava:guava:25.0-jre:jar
+com.google.j2objc:j2objc-annotations:1.1:jar
+com.google.re2j:re2j:1.2:jar
+com.googlecode.java-ipv6:java-ipv6:0.17:jar
+com.hubspot.jinjava:jinjava:2.5.6:jar
+com.thoughtworks.xstream:xstream:1.4.14:jar
+com.zaxxer:SparseBitSet:1.2:jar
+commons-codec:commons-codec:1.11:jar
+commons-io:commons-io:2.6:jar
+commons-net:commons-net:2.2:jar
+io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar
+io.trygvis.rules-sandbox:ri-wireguard:1.0-SNAPSHOT:jar
+org.antlr:antlr-runtime:3.5.2:jar
+org.apache.commons:commons-collections4:4.4:jar
+org.apache.commons:commons-compress:1.19:jar
+org.apache.commons:commons-lang3:3.9:jar
+org.apache.commons:commons-math3:3.4.1:jar
+org.apache.poi:poi:4.1.2:jar
+org.apache.poi:poi-ooxml:4.1.2:jar
+org.apache.poi:poi-ooxml-schemas:4.1.2:jar
+org.apache.xmlbeans:xmlbeans:3.1.0:jar
+org.checkerframework:checker-compat-qual:2.0.0:jar
+org.codehaus.mojo:animal-sniffer-annotations:1.14:jar
+org.drools:drools-compiler:7.47.0.Final:jar
+org.drools:drools-core:7.47.0.Final:jar
+org.drools:drools-core-dynamic:7.47.0.Final:jar
+org.drools:drools-core-reflective:7.47.0.Final:jar
+org.drools:drools-decisiontables:7.47.0.Final:jar
+org.drools:drools-ecj:7.47.0.Final:jar
+org.drools:drools-mvel:7.47.0.Final:jar
+org.drools:drools-templates:7.47.0.Final:jar
+org.javassist:javassist:3.26.0-GA:jar
+org.jsoup:jsoup:1.8.3:jar
+org.kie:kie-api:7.47.0.Final:jar
+org.kie:kie-internal:7.47.0.Final:jar
+org.kie:kie-memory-compiler:7.47.0.Final:jar
+org.kie.soup:kie-soup-commons:7.47.0.Final:jar
+org.kie.soup:kie-soup-maven-support:7.47.0.Final:jar
+org.kie.soup:kie-soup-project-datamodel-api:7.47.0.Final:jar
+org.kie.soup:kie-soup-project-datamodel-commons:7.47.0.Final:jar
+org.kie.soup:kie-soup-xstream:7.47.0.Final:jar
+org.mvel:mvel2:2.4.10.Final:jar
+org.slf4j:slf4j-api:1.7.26:jar
+org.yaml:snakeyaml:1.26:jar
+xmlpull:xmlpull:1.2.0:jar
+xpp3:xpp3_min:1.2.0:jar
diff --git a/module/acme/pom.xml b/module/acme/pom.xml
new file mode 100644
index 0000000..b3fc43c
--- /dev/null
+++ b/module/acme/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>io.trygvis.rules-sandbox</groupId>
+ <artifactId>rules-sandbox</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>acme</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ri-engine</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java b/module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java
new file mode 100644
index 0000000..dfe374b
--- /dev/null
+++ b/module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java
@@ -0,0 +1,6 @@
+package io.trygvis.acme;
+
+public class AcmeMyApp {
+ public String environment;
+ public String dockerTag;
+}
diff --git a/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java b/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java
new file mode 100644
index 0000000..844c7f0
--- /dev/null
+++ b/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java
@@ -0,0 +1,4 @@
+package io.trygvis.acme;
+
+public class AcmeOps {
+}
diff --git a/module/acme/src/main/java/io/trygvis/acme/VpnMain.java b/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
new file mode 100644
index 0000000..d5f986d
--- /dev/null
+++ b/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
@@ -0,0 +1,25 @@
+package io.trygvis.acme;
+
+import io.trygvis.rules.dns.DnsEntry;
+import io.trygvis.rules.engine.Engine;
+import io.trygvis.rules.machine.Machine;
+import io.trygvis.rules.network.Ipv4Address;
+import io.trygvis.rules.network.Ipv4Cidr;
+
+import java.io.IOException;
+
+public class VpnMain {
+ public static void main(String[] args) throws IOException {
+ try (var engine = new Engine("acme.yaml")) {
+ engine.io.dump("phase-1", engine.session.getFactHandles());
+
+ engine.io.dump("vpn0", engine.session.getFactHandles(), (Object o) ->
+ o.getClass().getName().contains("Wg")
+ || o instanceof Machine
+ || o instanceof DnsEntry
+ || o instanceof Ipv4Cidr
+ || o instanceof Ipv4Address
+ );
+ }
+ }
+}
diff --git a/module/acme/src/main/resources/META-INF/kmodule.xml b/module/acme/src/main/resources/META-INF/kmodule.xml
new file mode 100644
index 0000000..351a25e
--- /dev/null
+++ b/module/acme/src/main/resources/META-INF/kmodule.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.drools.org/xsd/kmodule"
+ xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd">
+
+ <kbase packages="io.trygvis.acme" default="true"
+ includes="engine,wireguard">
+ <ksession name="Default" default="true">
+ </ksession>
+ </kbase>
+</kmodule>
diff --git a/module/acme/src/main/resources/io/trygvis/acme/acme.drl b/module/acme/src/main/resources/io/trygvis/acme/acme.drl
new file mode 100644
index 0000000..d978579
--- /dev/null
+++ b/module/acme/src/main/resources/io/trygvis/acme/acme.drl
@@ -0,0 +1,58 @@
+package io.trygvis.acme;
+
+import io.trygvis.rules.machine.Machine;
+import io.trygvis.rules.dba.Cluster;
+import io.trygvis.rules.dba.Container;
+
+dialect "mvel"
+
+declare AcmeServer
+ name : String
+ machine : Machine
+end
+
+rule "Ops"
+when
+ $ops: AcmeOps()
+then
+ var cluster = new Cluster("acme-ops");
+ insert(cluster);
+ insert(new Container(cluster, "app", "pdb", "postgresql", "11"));
+ insert(new Container(cluster, "app", "n8n", "n8n", "0.84.1"));
+end
+
+rule "MyApp"
+when
+ $app: AcmeMyApp()
+then
+ var cluster = new Cluster("acme-" + $app.environment);
+ insert(cluster);
+
+ var tag = $app.dockerTag;
+ insert(new Container(cluster, "app", "statera", "statera", tag));
+ insert(new Container(cluster, "app", "statera-console", "statera-console", tag));
+ insert(new Container(cluster, "app", "4tune-web", "4tune-web", tag));
+ insert(new Container(cluster, "app", "4tune-api", "4tune-api", tag));
+ insert(new Container(cluster, "db", "pdb", "postgresql", "13"));
+ insert(new Container(cluster, "db", "mdb", "mongodb", "3.2"));
+end
+
+rule "Create Acme servers"
+when
+ $m : Machine(name.startsWith("acme-"))
+ not(AcmeServer(name == $m.name))
+then
+ var s = new AcmeServer();
+ s.name = $m.name;
+ s.machine = $m;
+ insert(s);
+end
+
+rule "Set public domain for ACME servers"
+when
+ $m : Machine(fqdn == null)
+ $s : AcmeServer(machine == $m)
+then
+ $s.machine.fqdn = "%s.machine.acme.com".formatted($s.machine.name);
+ update($s.machine)
+end