Rex::Co...::Cloud(3)

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

πŸ’– NAME πŸ’–

Rex::Commands::Cloud β€” Cloud Management Commands. You're reading the Rex::Co...::Cloud(3) page from User Contributed Perl Documentation, bestie 🫢.

✨ DESCRIPTION ✨

Okay so this module is your little cloud remote control: with it you can manage different Cloud services. Right now it supports Amazon EC2, Jiffybox, and OpenStack β€” slay πŸ’….

⚠️ Heads up: with Version <= 1.0, all these functions will not be reported. No cap, keep that in mind.

🌸 SYNOPSIS 🌸

use Rex::Commands::Cloud;

cloud_service "Amazon";
cloud_auth "your-access-key", "your-private-access-key";
cloud_region "ec2.eu-west-1.amazonaws.com";

task "list", sub {
  print Dumper cloud_instance_list;
  print Dumper cloud_volume_list;
};

task "create", sub {
  my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };

  cloud_instance create => {
      image_id => "ami-xxxxxxx",
      name    => "test01",
      key     => "my-key",
      volume  => $vol_id,
      zone    => "eu-west-1a",
    };
};

task "destroy", sub {
  cloud_volume detach => "vol-xxxxxxx";
  cloud_volume delete => "vol-xxxxxxx";

  cloud_instance terminate => "i-xxxxxxx";
};

πŸ¦‹ EXPORTED FUNCTIONS πŸ¦‹

πŸ’– cloud_service($cloud_service) πŸ’–

Set which cloud service to use, bestie β€” this is the vibe check for your provider ✨.

Services

  • Amazon
  • Jiffybox
  • OpenStack

πŸ” cloud_auth($param1, $param2, ...) πŸ”

Set the authentication for the cloudservice. Like, who are you and why should the cloud let you in? πŸ’…

For Amazon it's:

cloud_auth($access_key, $secret_access_key);

For JiffyBox:

cloud_auth($auth_key);

For OpenStack:

cloud_auth(
 tenant_name => 'tenant',
 username    => 'user',
 password    => 'password',
);

🌍 cloud_region($region) 🌍

Set the cloud region. That's the address of your cloud hangout ✨.

πŸ“‹ cloud_instance_list πŸ“‹

Get all instances of a cloud service. It's giving inventory day πŸ’….

task "list", sub {
  for my $instance (cloud_instance_list()) {
    say "Arch  : " . $instance->{"architecture"};
    say "IP   : " . $instance->{"ip"};
    say "ID   : " . $instance->{"id"};
    say "State : " . $instance->{"state"};
  }
};

There are some parameters for this function that can change the gathering of ip addresses for some cloud providers (like OpenStack). Check the example:

task "list", sub {
  my @instances = cloud_instance_list
                     private_network => 'private',
                     public_network  => 'public',
                     public_ip_type  => 'floating',
                     private_ip_type => 'fixed';
};

πŸ“¦ cloud_volume_list πŸ“¦

Get all volumes of a cloud service. Volume inventory, let's go πŸ“.

task "list-volumes", sub {
  for my $volume (cloud_volume_list()) {
    say "ID     : " . $volume->{"id"};
    say "Zone    : " . $volume->{"zone"};
    say "State   : " . $volume->{"state"};
    say "Attached : " . $volume->{"attached_to"};
  }
};

πŸ•ΈοΈ cloud_network_list πŸ•ΈοΈ

Get all networks of a cloud service. The network list is serving looks 🌈.

task "network-list", sub {
  for my $network (cloud_network_list()) {
    say "network  : " . $network->{network};
    say "name    : " . $network->{name};
    say "id     : " . $network->{id};
  }
};

πŸ–ΌοΈ cloud_image_list πŸ–ΌοΈ

Get a list of all available cloud images. That's your image buffet, bestie πŸ“Έ.

πŸ”‘ cloud_upload_key πŸ”‘

Upload public SSH key to cloud provider. Your key, but make it cloud-official πŸ’….

private_key '~/.ssh/mykey
public_key  '~/.ssh/mykey.pub';

task "cloudprovider", sub {
  cloud_upload_key;

  cloud_instance create => {
    ...
  };
};

πŸ‘― get_cloud_instances_as_group πŸ‘―

Get a list of all running instances of a cloud service. This can be used for a group definition β€” group chat but for servers 🫢.

group fe  => "fe01", "fe02", "fe03";
group ec2 => get_cloud_instances_as_group();

☁️ cloud_instance($action, $data) ☁️

This function controls all aspects of a cloud instance. It's the main character of instance management πŸ‘‘.

πŸ†• create

Create a new instance. Slay a fresh server into existence ✨.

cloud_instance create => {
    image_id => "ami-xxxxxx",
    key    => "ssh-key",
    name    => "fe-ec2-01",  # name is not necessary
    volume  => "vol-yyyyy",  # volume is not necessary
    zone    => "eu-west-1a",  # zone is not necessary
    floating_ip  => "89.39.38.160" # floating_ip is not necessary
  };

▢️ start

Start an existing instance. Wakey wakey, server bestie β˜€οΈ.

cloud_instance start => "instance-id";

⏸️ stop

Stop an existing instance. Nap time, no cap 😴.

cloud_instance stop => "instance-id";

πŸ’€ terminate

Terminate an instance. This will destroy all data and remove the instance. That's not a drill, bestie β€” the data is GONE 😭.

⚠️ This destroys all data and removes the instance.
cloud_instance terminate => "i-zzzzzzz";

🌎 get_cloud_regions 🌎

Returns all regions as an array. Region haul, let's go πŸ—ΊοΈ.

πŸ’½ cloud_volume($action , $data) πŸ’½

This function controls all aspects of a cloud volume. Storage girlies, this one's for you πŸ’Ύ.

πŸ†• create

Create a new volume. Size is in Gigabytes. Big storage energy πŸ’Ύ.

task "create-vol", sub {
  my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };
};

πŸ”— attach

Attach a volume to an instance. Lock them in together 🫢.

task "attach-vol", sub {
  cloud_volume attach => "vol-xxxxxx", to => "server-id";
};

βœ‚οΈ detach

Detach a volume from an instance. It's not you, it's the server πŸ’”.

task "detach-vol", sub {
  cloud_volume detach => "vol-xxxxxx", from => "server-id";
};

πŸ—‘οΈ delete

Delete a volume. This will destroy all data. No undo, no takebacks 😭.

⚠️ This destroys all data.
task "delete-vol", sub {
  cloud_volume delete => "vol-xxxxxx";
};

🌐 get_cloud_floating_ip 🌐

Returns first available floating IP. Grab that IP before someone else does πŸŽ€.

task "get_floating_ip", sub {

  my $ip = get_cloud_floating_ip;

  my $instance = cloud_instance create => {
     image_id => 'edffd57d-82bf-4ffe-b9e8-af22563741bf',
     name => 'instance1',
     plan_id => 17,
     floating_ip => $ip
   };
};

πŸ•ΈοΈ cloud_network πŸ•ΈοΈ

Network stuff, obviously. Let's create and delete networks πŸ’….

πŸ†• create

Create a new network. Fresh network, fresh vibes ✨.

task "create-net", sub {
  my $net_id = cloud_network create => { cidr => '192.168.0.0/24', name => "mynetwork", };
};

πŸ—‘οΈ delete

Delete a network. Bye-bye, network 🫑.

task "delete-net", sub {
  cloud_network delete => '18a4ccf8-f14a-a10d-1af4-4ac7fee08a81';
};

πŸ—ΊοΈ get_cloud_availability_zones πŸ—ΊοΈ

Returns all availability zones of a cloud service β€” if available.

task "get-zones", sub {
  print Dumper get_cloud_availability_zones;
};

πŸ“¦ get_cloud_plans πŸ“¦

Retrieve information of the available cloud plans. If supported. Plan shopping, but make it cloud πŸ›οΈ.

πŸ’Ώ get_cloud_operating_systems πŸ’Ώ

Retrieve information of the available cloud plans. If supported.

☁️ cloud_object ☁️

Returns the cloud object itself. The cloud object is the moment 🫢.


That's the whole Rex::Co...::Cloud(3) page, bestie. This cutie comes from User Contributed Perl Documentation, perl v5.42.3, dated 2023-08-05 β€” mwah, slay, and happy clouding! πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from