Add an ~./abbey facts~ command to update (clobber!) a =facts= file.
authorMatt Birkholz <matt@birchwood-abbey.net>
Sun, 23 Nov 2025 19:37:10 +0000 (12:37 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Sun, 23 Nov 2025 19:49:04 +0000 (12:49 -0700)
.gitignore
README.org
abbey

index 440aba166193c1331a5a46707c3cedd77d5f615f..035704d40f6ad29ca70abfef4f97fcdd336d101b 100644 (file)
@@ -3,3 +3,4 @@
 /roles/
 /Secret*
 /mythtv-ansible/
+/facts
index 2e426b6edb9936ad8dc0e624ce9ebd6582638a82..4d25e170fab5710ced849620c77d00858b95ef5c 100644 (file)
@@ -2721,6 +2721,7 @@ Liturgical sub-commands:
 - reboots :: Look for =/run/reboot*= on all hosts.
 - versions :: Report ~ansible_distribution~, ~_distribution_version~,
   and ~_architecture~ for all hosts.
+- facts :: Update (clobber!) [[file:facts][=facts=]].
 
 ** Abbey Command Script
 
@@ -2869,6 +2870,23 @@ if ($ARGV[0] eq "versions") {
         {{ ansible_architecture }}
 #+END_SRC
 
+** The Facts Command
+
+The script implements a ~facts~ sub-command to collect the Ansible
+"facts" from ~all~ and output them to the JSON format =facts= file.
+
+#+CAPTION: [[file:abbey][=abbey=]]
+#+BEGIN_SRC perl :tangle abbey
+if ($ARGV[0] eq "facts") {
+  my $line = ("ansible all -m gather_facts -e \@Secret/become.yml"
+             . " >facts");
+  print "$line\n";
+  my $status = system $line;
+  die "status: $status\nCould not run $line: $!\n" if $status != 0;
+  exit;
+}
+#+END_SRC
+
 ** The TZ Command
 
 The abbey changes location almost weekly, so its timezone changes
@@ -2945,7 +2963,8 @@ if ($ARGV[0] eq "tz") {
 
 #+CAPTION: [[file:abbey][=abbey=]]
 #+BEGIN_SRC perl :tangle abbey
-my $ops = "config,new,old,pass,client,upgrade,reboots,versions,tz";
+my $ops = ("config,new,old,pass,client,"
+           ."upgrade,reboots,versions,facts,tz");
 die "usage: $0 [$ops]\n";
 #+END_SRC
 
diff --git a/abbey b/abbey
index 95fd999ba0e90497fdd1a18b764c7556beed5736..e44a032d2fed0fb176c82335799b697e01785387 100755 (executable)
--- a/abbey
+++ b/abbey
@@ -35,10 +35,20 @@ if ($ARGV[0] eq "versions") {
        "playbooks/versarch.yml");
 }
 
+if ($ARGV[0] eq "facts") {
+  my $line = ("ansible all -m gather_facts -e \@Secret/become.yml"
+             . " >facts");
+  print "$line\n";
+  my $status = system $line;
+  die "status: $status\nCould not run $line: $!\n" if $status != 0;
+  exit;
+}
+
 if ($ARGV[0] eq "tz") {
   exec ("ansible-playbook", "-e", "\@Secret/become.yml",
        "playbooks/timezone.yml");
 }
 
-my $ops = "config,new,old,pass,client,upgrade,reboots,versions,tz";
+my $ops = ("config,new,old,pass,client,"
+           ."upgrade,reboots,versions,facts,tz");
 die "usage: $0 [$ops]\n";