» Home » Docs » Release notes » 0.4
Release notes for 0.4
Rex
Hardware and Information gathering
Now you can get information of the servers hardware and configuration.
use Rex::Hardware; use Data::Dumper; desc "Get Hardware Information"; task "hw-info", "testsystem", sub { my %hw = Rex::Hardware->get( qw/ Host Kernel Memory Network Swap / ); print Dumper(\%hw); };
Will produce the following example output:
$VAR1 = { 'Network' => { 'networkdevices' => [ 'eth0', 'wlan0' ], 'networkconfiguration' => { 'wlan0' => { 'broadcast' => '192.168.2.255', 'ip' => '192.168.2.229', 'netmask' => '255.255.255.0', 'mac' => '00:21:5C:5C:1E:5F' }, 'eth0' => { 'broadcast' => undef, 'ip' => undef, 'netmask' => undef, 'mac' => '00:1C:25:94:B0:85' } } }, 'Memory' => { 'shared' => '0', 'buffers' => '36', 'free' => '3168', 'used' => '792', 'total' => '3961', 'cached' => '407' }, 'Kernel' => { 'kernelversion' => '#1 SMP PREEMPT 2011-02-21 10:34:10 +0100', 'architecture' => 'x86_64', 'kernel' => 'Linux', 'kernelrelease' => '2.6.37.1-1.2-desktop' }, 'Swap' => { 'free' => '3812', 'used' => '0', 'total' => '3812' }, 'Host' => { 'domain' => 'site', 'manufacturer' => 'LENOVO', 'hostname' => 'linux-ymf0.site', 'operatingsystemrelease' => '11.4', 'operatingsystem' => 'SuSE' } };
Install Packages
Support for apt, yum and zypper (OpenSuSE)
Example:
# include for ,,install'' Function use Rex::Commands::Pkg; # include for ,,operating_system_is'' Function use Rex::Commands::Gather; user "root"; private_key "/Users/jan/.ssh/id_rsa"; public_key "/Users/jan/.ssh/is_rsa.pub"; # group servers group "test" => "debian01", "centos01", "suse01"; # run tasks in parallel parallelism 2; desc "Prepare System"; task "prepare", group => "test", sub { # check if operating system is CentOS, because on CentOS vim is # available through the package "vim-enhanced". if (operating_system_is("CentOS")) { install package => "vim-enhanced"; } else { install package => "vim"; } install package => "mc"; };
This task will install vim and mc on all the 3 systems.