summaryrefslogtreecommitdiff
path: root/7/firewall.pl
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2023-11-23 22:57:55 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2023-11-23 22:57:55 +0100
commit8062753241f2c510c94b0fec6f2552950e0c8014 (patch)
tree6aeed21b783cf7d9f8bb377c44846d5c57dd4a26 /7/firewall.pl
parentba29b490ffddd28bb09235a1bd0e99df73bfa064 (diff)
downloadprolog-firewall-8062753241f2c510c94b0fec6f2552950e0c8014.tar.gz
prolog-firewall-8062753241f2c510c94b0fec6f2552950e0c8014.tar.bz2
prolog-firewall-8062753241f2c510c94b0fec6f2552950e0c8014.tar.xz
prolog-firewall-8062753241f2c510c94b0fec6f2552950e0c8014.zip
wip
Diffstat (limited to '7/firewall.pl')
-rw-r--r--7/firewall.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/7/firewall.pl b/7/firewall.pl
index 9bb0cc2..9e00afe 100644
--- a/7/firewall.pl
+++ b/7/firewall.pl
@@ -8,7 +8,11 @@
retract_all_from/1]).
:- use_module(library(assoc)).
+:- use_module(library(files)).
+:- use_module(library(format)).
:- use_module(library(dcgs)).
+:- use_module(library(lists)).
+:- use_module(library(serialization/json)).
:- use_module(hosts, [
router_link/3]).
@@ -35,3 +39,22 @@ retract_all_from(From) :-
retract_rules([R|Rules]) :- retract(R), retract_rules(Rules).
retract_rules([]).
+
+ansible(Basedir) :-
+ setof(Host, Attrs^fw_rule(Host, Attrs), Hosts),
+ ansible_host(Basedir, Hosts).
+
+ansible_host(Basedir, [Host|Hosts]) :-
+ atom_chars(Host, HostS),
+ append(Basedir, [HostS], DirPs),
+ path_segments(Dir, DirPs),
+ append(Basedir, [HostS, "firewall.yaml"], FilePs),
+ path_segments(File, FilePs),
+ format("mkdir ~s~n", [Dir]),
+ make_directory_path(Dir),
+ format("firewall: ~s~n", [File]),
+ ansible_firewall(File, Host),
+ ansible_host(Basedir, Hosts).
+
+ansible_firewall(File, Host) :-
+ true.