summaryrefslogtreecommitdiff
path: root/7/firewall.pl
diff options
context:
space:
mode:
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.