.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Rex::Commands::Cloud 3pm" .TH Rex::Commands::Cloud 3pm "2018-02-01" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Rex::Commands::Cloud \- Cloud Management Commands .SH "DESCRIPTION" .IX Header "DESCRIPTION" With this Module you can manage different Cloud services. Currently it supports Amazon \s-1EC2,\s0 Jiffybox and OpenStack. .PP Version <= 1.0: All these functions will not be reported. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& 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"; \& }; .Ve .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .SS "cloud_service($cloud_service)" .IX Subsection "cloud_service($cloud_service)" Define which cloud service to use. .IP "Services" 4 .IX Item "Services" .RS 4 .PD 0 .IP "Amazon" 4 .IX Item "Amazon" .IP "Jiffybox" 4 .IX Item "Jiffybox" .IP "OpenStack" 4 .IX Item "OpenStack" .RE .RS 4 .RE .PD .ie n .SS "cloud_auth($param1, $param2, ...)" .el .SS "cloud_auth($param1, \f(CW$param2\fP, ...)" .IX Subsection "cloud_auth($param1, $param2, ...)" Set the authentication for the cloudservice. .PP For example for Amazon it is: .PP .Vb 1 \& cloud_auth($access_key, $secret_access_key); .Ve .PP For JiffyBox: .PP .Vb 1 \& cloud_auth($auth_key); .Ve .PP For OpenStack: .PP .Vb 5 \& cloud_auth( \& tenant_name => \*(Aqtenant\*(Aq, \& username => \*(Aquser\*(Aq, \& password => \*(Aqpassword\*(Aq, \& ); .Ve .SS "cloud_region($region)" .IX Subsection "cloud_region($region)" Set the cloud region. .SS "cloud_instance_list" .IX Subsection "cloud_instance_list" Get all instances of a cloud service. .PP .Vb 8 \& 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"}; \& } \& }; .Ve .PP There are some parameters for this function that can change the gathering of ip addresses for some cloud providers (like OpenStack). .PP .Vb 7 \& task "list", sub { \& my @instances = cloud_instance_list \& private_network => \*(Aqprivate\*(Aq, \& public_network => \*(Aqpublic\*(Aq, \& public_ip_type => \*(Aqfloating\*(Aq, \& private_ip_type => \*(Aqfixed\*(Aq; \& }; .Ve .SS "cloud_volume_list" .IX Subsection "cloud_volume_list" Get all volumes of a cloud service. .PP .Vb 8 \& 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"}; \& } \& }; .Ve .SS "cloud_network_list" .IX Subsection "cloud_network_list" Get all networks of a cloud service. .PP .Vb 7 \& task "network\-list", sub { \& for my $network (cloud_network_list()) { \& say "network : " . $network\->{network}; \& say "name : " . $network\->{name}; \& say "id : " . $network\->{id}; \& } \& }; .Ve .SS "cloud_image_list" .IX Subsection "cloud_image_list" Get a list of all available cloud images. .SS "cloud_upload_key" .IX Subsection "cloud_upload_key" Upload public \s-1SSH\s0 key to cloud provider .PP .Vb 2 \& private_key \*(Aq~/.ssh/mykey \& public_key \*(Aq~/.ssh/mykey.pub\*(Aq; \& \& task "cloudprovider", sub { \& cloud_upload_key; \& \& cloud_instance create => { \& ... \& }; \& }; .Ve .SS "get_cloud_instances_as_group" .IX Subsection "get_cloud_instances_as_group" Get a list of all running instances of a cloud service. This can be used for a \fIgroup\fR definition. .PP .Vb 2 \& group fe => "fe01", "fe02", "fe03"; \& group ec2 => get_cloud_instances_as_group(); .Ve .ie n .SS "cloud_instance($action, $data)" .el .SS "cloud_instance($action, \f(CW$data\fP)" .IX Subsection "cloud_instance($action, $data)" This function controls all aspects of a cloud instance. .SS "create" .IX Subsection "create" Create a new instance. .PP .Vb 8 \& 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 \& }; .Ve .SS "start" .IX Subsection "start" Start an existing instance .PP .Vb 1 \& cloud_instance start => "instance\-id"; .Ve .SS "stop" .IX Subsection "stop" Stop an existing instance .PP .Vb 1 \& cloud_instance stop => "instance\-id"; .Ve .SS "terminate" .IX Subsection "terminate" Terminate an instance. This will destroy all data and remove the instance. .PP .Vb 1 \& cloud_instance terminate => "i\-zzzzzzz"; .Ve .SS "get_cloud_regions" .IX Subsection "get_cloud_regions" Returns all regions as an array. .ie n .SS "cloud_volume($action , $data)" .el .SS "cloud_volume($action , \f(CW$data\fP)" .IX Subsection "cloud_volume($action , $data)" This function controls all aspects of a cloud volume. .SS "create" .IX Subsection "create" Create a new volume. Size is in Gigabytes. .PP .Vb 3 \& task "create\-vol", sub { \& my $vol_id = cloud_volume create => { size => 1, zone => "eu\-west\-1a", }; \& }; .Ve .SS "attach" .IX Subsection "attach" Attach a volume to an instance. .PP .Vb 3 \& task "attach\-vol", sub { \& cloud_volume attach => "vol\-xxxxxx", to => "server\-id"; \& }; .Ve .SS "detach" .IX Subsection "detach" Detach a volume from an instance. .PP .Vb 3 \& task "detach\-vol", sub { \& cloud_volume detach => "vol\-xxxxxx", from => "server\-id"; \& }; .Ve .SS "delete" .IX Subsection "delete" Delete a volume. This will destroy all data. .PP .Vb 3 \& task "delete\-vol", sub { \& cloud_volume delete => "vol\-xxxxxx"; \& }; .Ve .SS "get_cloud_floating_ip" .IX Subsection "get_cloud_floating_ip" Returns first available floating \s-1IP\s0 .PP .Vb 1 \& task "get_floating_ip", sub { \& \& my $ip = get_cloud_floating_ip; \& \& my $instance = cloud_instance create => { \& image_id => \*(Aqedffd57d\-82bf\-4ffe\-b9e8\-af22563741bf\*(Aq, \& name => \*(Aqinstance1\*(Aq, \& plan_id => 17, \& floating_ip => $ip \& }; \& }; .Ve .SS "cloud_network" .IX Subsection "cloud_network" .SS "create" .IX Subsection "create" Create a new network. .PP .Vb 3 \& task "create\-net", sub { \& my $net_id = cloud_network create => { cidr => \*(Aq192.168.0.0/24\*(Aq, name => "mynetwork", }; \& }; .Ve .SS "delete" .IX Subsection "delete" Delete a network. .PP .Vb 3 \& task "delete\-net", sub { \& cloud_network delete => \*(Aq18a4ccf8\-f14a\-a10d\-1af4\-4ac7fee08a81\*(Aq; \& }; .Ve .SS "get_cloud_availability_zones" .IX Subsection "get_cloud_availability_zones" Returns all availability zones of a cloud services. If available. .PP .Vb 3 \& task "get\-zones", sub { \& print Dumper get_cloud_availability_zones; \& }; .Ve .SS "get_cloud_plans" .IX Subsection "get_cloud_plans" Retrieve information of the available cloud plans. If supported. .SS "get_cloud_operating_systems" .IX Subsection "get_cloud_operating_systems" Retrieve information of the available cloud plans. If supported. .SS "cloud_object" .IX Subsection "cloud_object" Returns the cloud object itself.