Rex::Co...::Augeas(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

Okay bestie, welcome to Rex::Co...::Augeas(3) β€” a User Contributed Perl Documentation page for Rex::Commands::Augeas, the augeas module for (R)?ex. It's lowkey iconic, highkey useful, and we're gonna read it together like a group chat 🫢.

🌸 NAME 🌸

Rex::Commands::Augeas β€” an augeas module for (R)?ex πŸ’–

πŸ’– DESCRIPTION πŸ’–

This is a simple module to manipulate configuration files with the help of augeas. Short, sweet, and to the point β€” we love a concise icon, periodt ✨.

✨ SYNOPSIS ✨

Okay so here's the demo reel, bestie. Vibe check: passed. Watch how it moves:

my $k = augeas exists => "/files/etc/hosts/*/ipaddr", "127.0.0.1";

augeas insert => "/files/etc/hosts",
          label => "01",
          after => "/7",
          ipaddr => "192.168.2.23",
          canonical => "test";

augeas dump => "/files/etc/hosts";

augeas modify =>
   "/files/etc/ssh/sshd_config/PermitRootLogin" => "without-password",
   on_change => sub {
      service ssh => "restart";
   };

πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

πŸ¦‹ augeas($action, @options) πŸ¦‹

Bestie, this is the function signature: augeas($action, @options). It returns 1 on success and 0 on failure β€” no cap.

Actions:

πŸ’… modify

This modifies the keys given in @options in $file. Slay. Like this:

augeas modify =>
          "/files/etc/hosts/7/ipaddr"    => "127.0.0.2",
          "/files/etc/hosts/7/canonical" => "test01",
          on_change                      => sub { say "I changed!" };

🧹 remove

Remove an entry. Bye-bye, little config node πŸ‘‹

augeas remove    => "/files/etc/hosts/2",
       on_change => sub { say "I changed!" };

🌱 insert

Insert an item into the file. Here, the order of the options is important. If the order is wrong it won't save your changes.

⚠️ Bestie, listen: the order of the options is important here. If the order is wrong it won't save your changes. Not me being dramatic, that's just the truth fr fr 😭.
augeas insert => "/files/etc/hosts",
          label     => "01",
          after     => "/7",
          ipaddr    => "192.168.2.23",
          alias     => "test02",
          on_change => sub { say "I changed!" };

πŸ“œ dump

Dump the contents of a file to STDOUT. It's giving show-and-tell for config files:

augeas dump => "/files/etc/hosts";

πŸ” exists

Check if an item exists. Here's the little check:

my $exists = augeas exists => "/files/etc/hosts/*/ipaddr" => "127.0.0.1";
if($exists) {
    say "127.0.0.1 exists!";
}

🎁 get

Returns the value of the given item. Like:

my $val = augeas get => "/files/etc/hosts/1/ipaddr";

Okay that's the page, bestie πŸ’–. Cute sign-off time: this was perl v5.42.3, dated 2023-08-05, and it lives under Rex::Co...::Augeas(3). That page ate, iykyk. Mwah! 🫢✨

πŸ“¦ where this page comes from