Rex::C...s::Host(3pm)

πŸ’– Rex::Commands::Host β€” bestie's guide to /etc/hosts πŸ’–

okay so real talk, this page is Rex::Commands::Host, and it's filed under the Perl documentation (the 3pm girly πŸ’…) in the User Contributed Perl Documentation section. if you've ever wanted your config management to just handle your hosts file for you... bestie, you're home. 🏠✨


🌸 NAME 🌸

Rex::Commands::Host β€” Edit /etc/hosts

like. that's literally it. that's the whole job. and she does it so well. no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

With this module you can manage the host entries in /etc/hosts. πŸ’…

that's it. that's the vibe. you get to be the main character of your own hosts file instead of hand-editing it like some sort of animal. obsessed, honestly. πŸŽ€


✨ SYNOPSIS ✨

here's a lil taste of what it looks like in the wild, bestie:

task "create-host", "remoteserver", sub {
  create_host "rexify.org" => {
   ip    => "88.198.93.110",
   aliases => ["www.rexify.org"],
  };
};

see how chill that is?? a whole task, a whole host entry, zero stress. ate. πŸ“


πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

the goods. the icons. the moment. 🫢

🌈 host_entry($name, %option)

Manages the entries in /etc/hosts. she's the flexible one, she takes options, she takes vibes.

host_entry "rexify.org",
  ensure    => "present",
  ip        => "88.198.93.110",
  aliases   => ["www.rexify.org"],
  on_change => sub { say "added host entry"; };

 host_entry "rexify.org",
   ensure    => "absent",
   on_change => sub { say "removed host entry"; };

so <purple>ensure => "present"</purple> means add it, bestie, and ensure => "absent" means it's gone, periodt. and that on_change callback?? she runs when the thing actually changes, and she is iconic for it. πŸ”₯

πŸ’œ create_host($)

Update or create a /etc/hosts entry. it's giving "make it exist, or fix it if it's already there."

create_host "rexify.org", {
  ip    => "88.198.93.110",
  aliases => ["www.rexify.org", ...]
};

that ... in the aliases array is doing the most and honestly? relatable. πŸ™ˆ

πŸŽ€ delete_host($host)

Delete a host from /etc/hosts. bye bye. no notes. πŸ’€

delete_host "www.rexify.org";

🧚 get_host($host)

Returns the information of $host in /etc/hosts. she's the nosy one and we love her for it. πŸ‘‘

my @host_info = get_host "localhost";
say "Host-IP: " . $host_info[0]->{"ip"};

look how easy that is β€” $host_info[0]->{"ip"} and boom, you've got the IP. slay. ⭐


lowkey reminder: this all edits /etc/hosts, which is a real system file, and it's the only file this module touches. treat her with respect, bestie. πŸ™

and that's the whole page, fr fr. no filler, no skips, every function accounted for. πŸ’–

perl v5.40.1 Β· 2025-10-03 Β· Rex::Commands::Host(3pm) β€” thanks for coming to my ted talk, go edit some hosts, ily, bye!! πŸŽ€πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from