From b48b35c93413f2ab28c7174224acf6cb94f27481 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sun, 23 Nov 2025 12:37:10 -0700 Subject: [PATCH] Add an ~./abbey facts~ command to update (clobber!) a =facts= file. --- .gitignore | 1 + README.org | 21 ++++++++++++++++++++- abbey | 12 +++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 440aba1..035704d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /roles/ /Secret* /mythtv-ansible/ +/facts diff --git a/README.org b/README.org index 2e426b6..4d25e17 100644 --- a/README.org +++ b/README.org @@ -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 95fd999..e44a032 100755 --- 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"; -- 2.25.1