Rex::Co...ds::Host(3)

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

✨ NAME ✨

okay bestie, welcome to the Rex::Co...ds::Host(3) page from the User Contributed Perl Documentation πŸ’– the module is Rex::Commands::Host, and its whole personality is Edit /etc/hosts. that's it, that's the name. slay.

🌸 DESCRIPTION 🌸

with this module you can manage the host entries in /etc/hosts β€” literally the whole point. host entries? managed. /etc/hosts? handled. no cap. ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe in code form, bestie:

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

πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

these are the exported functions, and yes they are the main characters πŸ’…

πŸŽ€ host_entry($name, %option) πŸŽ€

this one manages the entries in /etc/hosts. it's giving host-entry manager, fr fr.

here's the ensure => "present" moment β€” look at that on_change callback, iconic:

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

and yes, the second one is the ensure => "absent" moment β€” removal vibes, bestie 🫢

🌈 create_host($) 🌈

update or create a /etc/hosts entry. lowkey the glow-up function for your host file, periodt.

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

πŸ¦‹ delete_host($host) πŸ¦‹

delete a host from /etc/hosts. bye bestie πŸ‘‹

        delete_host "www.rexify.org";

πŸ”₯ get_host($host) πŸ”₯

returns the information of $host in /etc/hosts. it's giving data retrieval, and we love that for us.

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

okay that's the whole page, bestie 🫢 this was Rex::Co...ds::Host(3) from the User Contributed Perl Documentation, Perl v5.42.3, dated 2023-08-05 β€” slay and stay iconic πŸ’œ

πŸ“¦ where this page comes from