-
-
05 Jul 2021 21:04:56 UTC
- Distribution: Rex
- Module version: v1.13.4
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (710 / 4 / 2)
- Kwalitee
Bus factor: 2- 49.25% Coverage
- License: apache_2_0
- Perl: v5.10.1
- Activity
24 month- Tools
- Download (342.78KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 118 contributors-
Jan Gehring
-
A Happy User
-
Alexander Romanenko
-
Alexandr Ciornii
-
Alex Mestiashvili
-
Ali Polatel
-
alx542
-
Anders Ossowicki
-
Andrej Zverev
-
Andrew Solomon
-
Andy Beverley
-
Arnold Bechtoldt
-
Boris Däppen
-
Brian Manning
-
Cameron Daniel
-
Chris Steigmeier
-
Christophe Wolfhugel
-
Crimson Thompson
-
Daniel Bäurer
-
Daniel Cesario
-
Daniel Dico
-
Denis Silakov
-
Dmitry Kopytov
-
Dominik Schulz
-
E. Choroba
-
Eduardo J
-
Eivin Giske Skaaren
-
elisdg
-
Elmer Quintanilla
-
Eric Johnson
-
Erik Huelsmann
-
Ferenc Erki
-
Franky Van Liedekerke
-
Fran Rodriguez
-
Gabor Szabo
-
Graham Todd
-
Harm Müller
-
Hayato Imai
-
Hiroaki Nakamura
-
Hiroki Matsuo
-
iblinder
-
Ilya Pavlov
-
James D Bearden
-
jdelgado7
-
Jean Charles Passard
-
Jean-Marie Renouard
-
Jeen Lee
-
Jens Berthold
-
Joachim Bargsten
-
John Karr
-
Jon Gentle
-
Joris DE POOTER
-
Jose Luis Martinez
-
Jose Luis Perez Diez
-
Kasim Tuman
-
Keedi Kim
-
Ken Crowell
-
Kent Fredric
-
Kirill Babikhin
-
labbeduddel
-
Leah Neukirchen
-
LeMerP
-
Mario Domgoergen
-
Max E. Aubrey
-
Mitch Broadhead
-
Nathan Abu
-
Naveed Massjouni
-
necrophcodr
-
Nicolas Leclercq
-
Nigel Gregoire
-
Nikolay A. Fetisov
-
Nils Domrose
-
okaoka
-
Oleg Hardt
-
Olivier Cherrier
-
Orange
-
Paco Esteban
-
Patrick Lauer
-
Pavel Timofeev
-
perlancar
-
Peter H. Ezetta
-
Peter Manthey
-
petersonchen
-
Pierrick DINTRAT
-
Piotr Karbowski
-
Prajithp
-
Randy Lauen
-
Renée Bäcker
-
Robert Abraham
-
Roy Storey
-
Samuele Tognini
-
Sascha Askani
-
Sascha Guenther
-
Simon Bertrang
-
Solène Rapenne
-
Stephane Benoit
-
Steve Dondley
-
Sven Dowideit
-
Tamas Molnar
-
Tianon Gravi
-
Tokuhiro Matsuno
-
Tomohiro Hosaka
-
Volker Kroll
-
Walery Wysotsky
-
Yanick Champoux
-
Yegor Korablev
-
Zane C. Bowers-Hadley
-
Сергей Романов
-
范野人
-
饶琛琳
-
Cuong Manh Le
-
David Golovan
-
Dominik Danter
-
Ilya Evseev
-
Niklas Larsson
-
Qiao Liu
-
Renato CRON
-
Peter Jankovics
- Dependencies
- AWS::Signature4
- Carp
- Cwd
- Data::Dumper
- Data::Validate::IP
- Devel::Caller
- Digest::HMAC_SHA1
- Digest::MD5
- English
- Exporter
- Fcntl
- File::Basename
- File::Spec
- File::Spec::Unix
- File::Spec::Win32
- FindBin
- HTTP::Request
- HTTP::Request::Common
- Hash::Merge
- IO::File
- IO::Select
- IO::Socket
- IO::String
- IPC::Open3
- JSON::MaybeXS
- LWP::UserAgent
- List::Util
- MIME::Base64
- Net::OpenSSH::ShellQuoter
- POSIX
- Scalar::Util
- Sort::Naturally
- Storable
- Symbol
- Term::ReadKey
- Test::Builder::Module
- Text::Glob
- Text::Wrap
- Time::HiRes
- UNIVERSAL
- URI
- URI::QueryParam
- XML::Simple
- YAML
- attributes
- base
- constant
- lib
- overload
- strict
- vars
- version
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- DESCRIPTION
- SYNOPSIS
- EXPORTED FUNCTIONS
- cloud_service($cloud_service)
- cloud_auth($param1, $param2, ...)
- cloud_region($region)
- cloud_instance_list
- cloud_volume_list
- cloud_network_list
- cloud_image_list
- cloud_upload_key
- get_cloud_instances_as_group
- cloud_instance($action, $data)
- create
- start
- stop
- terminate
- get_cloud_regions
- cloud_volume($action , $data)
- create
- attach
- detach
- delete
- get_cloud_floating_ip
- cloud_network
- create
- delete
- get_cloud_availability_zones
- get_cloud_plans
- get_cloud_operating_systems
- cloud_object
NAME
Rex::Commands::Cloud - Cloud Management Commands
DESCRIPTION
With this Module you can manage different Cloud services. Currently it supports Amazon EC2, Jiffybox and OpenStack.
Version <= 1.0: All these functions will not be reported.
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)
Define which cloud service to use.
- Services
-
- Amazon
- Jiffybox
- OpenStack
cloud_auth($param1, $param2, ...)
Set the authentication for the cloudservice.
For example for Amazon it is:
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.
cloud_instance_list
Get all instances of a cloud service.
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).
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.
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.
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.
cloud_upload_key
Upload public SSH key to cloud provider
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 fe => "fe01", "fe02", "fe03"; group ec2 => get_cloud_instances_as_group();
cloud_instance($action, $data)
This function controls all aspects of a cloud instance.
create
Create a new instance.
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
cloud_instance start => "instance-id";
stop
Stop an existing instance
cloud_instance stop => "instance-id";
terminate
Terminate an instance. This will destroy all data and remove the instance.
cloud_instance terminate => "i-zzzzzzz";
get_cloud_regions
Returns all regions as an array.
cloud_volume($action , $data)
This function controlls all aspects of a cloud volume.
create
Create a new volume. Size is in Gigabytes.
task "create-vol", sub { my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", }; };
attach
Attach a volume to an instance.
task "attach-vol", sub { cloud_volume attach => "vol-xxxxxx", to => "server-id"; };
detach
Detach a volume from an instance.
task "detach-vol", sub { cloud_volume detach => "vol-xxxxxx", from => "server-id"; };
delete
Delete a volume. This will destroy all data.
task "delete-vol", sub { cloud_volume delete => "vol-xxxxxx"; };
get_cloud_floating_ip
Returns first available floating IP
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
create
Create a new network.
task "create-net", sub { my $net_id = cloud_network create => { cidr => '192.168.0.0/24', name => "mynetwork", }; };
delete
Delete a network.
task "delete-net", sub { cloud_network delete => '18a4ccf8-f14a-a10d-1af4-4ac7fee08a81'; };
get_cloud_availability_zones
Returns all availability zones of a cloud services. If available.
task "get-zones", sub { print Dumper get_cloud_availability_zones; };
get_cloud_plans
Retrieve information of the available cloud plans. If supported.
get_cloud_operating_systems
Retrieve information of the available cloud plans. If supported.
cloud_object
Returns the cloud object itself.
Module Install Instructions
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm Rex
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.