Rex::C...:Augeas(3pm)

πŸ’– Rex::Commands::Augeas β€” the manual, but make it cute πŸ’–

okay bestie, so you found yourself in the Rex::C...:Augeas(3pm) page from the User Contributed Perl Documentation, and honestly? you're gonna eat this one up. it's a (R)?ex module. yes, really. let's go. πŸ¦‹


✨ NAME ✨

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


🌸 DESCRIPTION 🌸

so basically, this is a simple lil module that lets you manipulate configuration files with the help of augeas. that's the whole vibe. no cap. πŸŽ€


πŸ‘‘ SYNOPSIS πŸ‘‘

here's the energy upfront, bestie β€” look at these:

 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";
    };

periodt. now let's get into the actual functions. πŸ”₯


⭐ EXPORTED FUNCTIONS ⭐

🫢 augeas($action, @options)

the way that this one function does *everything*… main character energy fr fr. it returns 1 on success and 0 on failure. that's it, that's the contract. πŸ’–

Actions:

🧚 modify

this modifies the keys given in @options in $file. it's giving glow-up. ✨

 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 bestie, you won't be missed. πŸ™ˆ

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

πŸŽ€ insert

Insert an item into the file. and listen β€” here, the order of the options is important. if the order is wrong it won't save your changes. so don't be chaotic about it, okay? 😭

 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. no thoughts, just output. πŸ’œ

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

πŸ”₯ exists

Check if an item exists. vibe check, but for entries.

 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. give me what I want, literally. πŸ“

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

🌟 ok that's the whole page, you're officially certified in augeas-ing. slay, ily, go configure something.

and for the record books, this was perl v5.40.1, dated 2025-10-03, and it lives on the Rex::C...:Augeas(3pm) page. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from