diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-07 23:38:01 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-07 23:38:01 +0100 |
commit | 3d25f7059f518dd8c857dd5e45552ba3ab733aa6 (patch) | |
tree | e7bbd7f2c6c7cfe41398335da0ab51807b54931c /module/ri-engine | |
parent | 70d0ad3c9f37e44a9504a0d7f66e412a3f3bba6f (diff) | |
download | rules-sandbox-3d25f7059f518dd8c857dd5e45552ba3ab733aa6.tar.gz rules-sandbox-3d25f7059f518dd8c857dd5e45552ba3ab733aa6.tar.bz2 rules-sandbox-3d25f7059f518dd8c857dd5e45552ba3ab733aa6.tar.xz rules-sandbox-3d25f7059f518dd8c857dd5e45552ba3ab733aa6.zip |
Working terraform setup.
Diffstat (limited to 'module/ri-engine')
-rw-r--r-- | module/ri-engine/src/main/resources/io/trygvis/rules/terraform/terraform.drl | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/terraform/terraform.drl b/module/ri-engine/src/main/resources/io/trygvis/rules/terraform/terraform.drl index b3d176b..c1293fe 100644 --- a/module/ri-engine/src/main/resources/io/trygvis/rules/terraform/terraform.drl +++ b/module/ri-engine/src/main/resources/io/trygvis/rules/terraform/terraform.drl @@ -5,6 +5,7 @@ import io.trygvis.rules.dba.Container import io.trygvis.rules.machine.Machine import io.trygvis.rules.dns.DnsEntry import io.trygvis.rules.dns.DnsEntryTerraformExpression +import java.util.ArrayList; import java.util.Map; global io.trygvis.rules.engine.TemplateEngine te; @@ -14,12 +15,15 @@ declare ScalewayMachine key : String end +declare GoogleManagedZoneTerraformExpression + name : String +end + rule "Terraform for Machine" when $machine: Machine() then - ScalewayMachine scw = new ScalewayMachine(); - + var scw = new ScalewayMachine(); scw.setKey($machine.name); scw.setMachine($machine); @@ -38,13 +42,24 @@ then insert(new DnsEntryTerraformExpression(a, $machine.name, ipv4)); end +rule "main-scaleway-machine.tf" + agenda-group "generate" +when + $managedZones : ArrayList() from collect(GoogleManagedZoneTerraformExpression()) +then + var path = "terraform/main-scaleway-machine.tf"; + te.template("terraform-main-scaleway-machine", path, Map.of( + "managedZones", $managedZones + )); +end + rule "TF for TerraformMachine" agenda-group "generate" when $m: Machine() $scw: ScalewayMachine(machine == $m) then - var path = "platform/terraform/%s.tf".formatted($scw.getKey()); + var path = "terraform/scaleway-machine-%s.tf".formatted($scw.getKey()); te.template("terraform-machine", path, Map.of("m", $m, "scw", $scw)); end @@ -53,10 +68,12 @@ rule "Terraform for DNS" when $entry: DnsEntry() $tf : DnsEntryTerraformExpression(entry == $entry) + $managedZone : GoogleManagedZoneTerraformExpression() then - var path = "dns/%s.tf".formatted($tf.key); + var path = "terraform/dns-%s.tf".formatted($tf.key); te.template("terraform-record-set", path, Map.of( "entry", $entry, + "managedZone", $managedZone, "tf", $tf) ); end |