Rex::Co...::Cloud(3)
π 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
- nixos 26.05: perl5.42.3-Rex 1.14.3
- nixpkgs unstable: perl5.42.3-Rex 1.14.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms