The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
CONTRIBUTORS 13
ChangeLog 534
MANIFEST 210
META.json 610
META.yml 3635
README 580
bin/rexify 44
lib/Rex/Args/Integer.pm 1010
lib/Rex/Args/Single.pm 11
lib/Rex/Args/String.pm 66
lib/Rex/Args.pm 9393
lib/Rex/Batch.pm 3434
lib/Rex/Box/Amazon.pm 132132
lib/Rex/Box/Base.pm 133133
lib/Rex/Box/VBox.pm 189189
lib/Rex/Box.pm 2020
lib/Rex/CLI.pm 517550
lib/Rex/CMDB/YAML.pm 4747
lib/Rex/CMDB.pm 1818
lib/Rex/Cloud/Amazon.pm 313313
lib/Rex/Cloud/Base.pm 1617
lib/Rex/Cloud/Jiffybox.pm 162176
lib/Rex/Cloud/OpenStack.pm 0365
lib/Rex/Cloud.pm 2727
lib/Rex/Commands/Box.pm 245245
lib/Rex/Commands/Cloud.pm 169258
lib/Rex/Commands/Cron.pm 7676
lib/Rex/Commands/DB.pm 141141
lib/Rex/Commands/Download.pm 8686
lib/Rex/Commands/File.pm 600651
lib/Rex/Commands/Fs.pm 425435
lib/Rex/Commands/Gather.pm 163163
lib/Rex/Commands/Host.pm 9696
lib/Rex/Commands/Inventory.pm 109
lib/Rex/Commands/Iptables.pm 236307
lib/Rex/Commands/Kernel.pm 7878
lib/Rex/Commands/LVM.pm 153153
lib/Rex/Commands/MD5.pm 4141
lib/Rex/Commands/Network.pm 77
lib/Rex/Commands/Notify.pm 058
lib/Rex/Commands/Partition.pm 175175
lib/Rex/Commands/Pkg.pm 348388
lib/Rex/Commands/Process.pm 120120
lib/Rex/Commands/Rsync.pm 170185
lib/Rex/Commands/Run.pm 125215
lib/Rex/Commands/SCM.pm 3838
lib/Rex/Commands/Service.pm 144156
lib/Rex/Commands/SimpleCheck.pm 1818
lib/Rex/Commands/Sync.pm 300300
lib/Rex/Commands/Sysctl.pm 2828
lib/Rex/Commands/Tail.pm 6666
lib/Rex/Commands/Upload.pm 102102
lib/Rex/Commands/User.pm 104138
lib/Rex/Commands/Virtualization.pm 185185
lib/Rex/Commands/templates/append_if_no_such_line.tpl.pl 1313
lib/Rex/Commands.pm 645645
lib/Rex/Config.pm 421421
lib/Rex/Cron/Base.pm 161161
lib/Rex/Cron/Linux.pm 77
lib/Rex/Cron/SunOS.pm 1313
lib/Rex/Cron.pm 1313
lib/Rex/Exporter.pm 1919
lib/Rex/FS/File.pm 4141
lib/Rex/File/Parser/Data.pm 2929
lib/Rex/File/Parser/Ini.pm 4949
lib/Rex/Fork/Manager.pm 5454
lib/Rex/Fork/Task.pm 3838
lib/Rex/Group/Entry/Server.pm 208208
lib/Rex/Group/Lookup/Command.pm 2929
lib/Rex/Group/Lookup/File.pm 1010
lib/Rex/Group/Lookup/INI.pm 2626
lib/Rex/Group.pm 4949
lib/Rex/Hardware/Host.pm 222227
lib/Rex/Hardware/Kernel.pm 1414
lib/Rex/Hardware/Memory.pm 175175
lib/Rex/Hardware/Network/FreeBSD.pm 155155
lib/Rex/Hardware/Network/Linux.pm 215221
lib/Rex/Hardware/Network/NetBSD.pm 1010
lib/Rex/Hardware/Network/OpenBSD.pm 151151
lib/Rex/Hardware/Network/Solaris.pm 201201
lib/Rex/Hardware/Network.pm 2929
lib/Rex/Hardware/Swap.pm 132132
lib/Rex/Hardware/VirtInfo.pm 9696
lib/Rex/Hardware.pm 3030
lib/Rex/Helper/Array.pm 1818
lib/Rex/Helper/Encode.pm 4343
lib/Rex/Helper/Hash.pm 3333
lib/Rex/Helper/INI.pm 7373
lib/Rex/Helper/Path.pm 105105
lib/Rex/Helper/Run.pm 4242
lib/Rex/Helper/SSH2/Expect.pm 9191
lib/Rex/Helper/SSH2.pm 5858
lib/Rex/Helper/System.pm 2929
lib/Rex/Hook.pm 2020
lib/Rex/Interface/Cache/Base.pm 2727
lib/Rex/Interface/Cache/YAML.pm 3131
lib/Rex/Interface/Cache.pm 1010
lib/Rex/Interface/Connection/Base.pm 2525
lib/Rex/Interface/Connection/Fake.pm 1010
lib/Rex/Interface/Connection/HTTP.pm 9191
lib/Rex/Interface/Connection/HTTPS.pm 3636
lib/Rex/Interface/Connection/Local.pm 99
lib/Rex/Interface/Connection/OpenSSH.pm 111113
lib/Rex/Interface/Connection/SSH.pm 106106
lib/Rex/Interface/Connection.pm 1111
lib/Rex/Interface/Exec/Base.pm 1010
lib/Rex/Interface/Exec/HTTP.pm 4142
lib/Rex/Interface/Exec/Local.pm 6181
lib/Rex/Interface/Exec/OpenSSH.pm 1614
lib/Rex/Interface/Exec/SSH.pm 4678
lib/Rex/Interface/Exec/Sudo.pm 103153
lib/Rex/Interface/Exec.pm 1111
lib/Rex/Interface/Executor/Base.pm 1010
lib/Rex/Interface/Executor/Default.pm 3232
lib/Rex/Interface/Executor.pm 99
lib/Rex/Interface/File/Base.pm 88
lib/Rex/Interface/File/HTTP.pm 5252
lib/Rex/Interface/File/Local.pm 2727
lib/Rex/Interface/File/OpenSSH.pm 3737
lib/Rex/Interface/File/SSH.pm 3535
lib/Rex/Interface/File/Sudo.pm 7171
lib/Rex/Interface/File.pm 2121
lib/Rex/Interface/Fs/Base.pm 6969
lib/Rex/Interface/Fs/HTTP.pm 105105
lib/Rex/Interface/Fs/Local.pm 8080
lib/Rex/Interface/Fs/OpenSSH.pm 8585
lib/Rex/Interface/Fs/SSH.pm 129148
lib/Rex/Interface/Fs/Sudo.pm 138138
lib/Rex/Interface/Fs.pm 2121
lib/Rex/Interface/Shell/Ash.pm 99
lib/Rex/Interface/Shell/Base.pm 043
lib/Rex/Interface/Shell/Bash.pm 86110
lib/Rex/Interface/Shell/Csh.pm 6984
lib/Rex/Interface/Shell/Default.pm 99
lib/Rex/Interface/Shell/Ksh.pm 99
lib/Rex/Interface/Shell/Sh.pm 119
lib/Rex/Interface/Shell/Tcsh.pm 109
lib/Rex/Interface/Shell/Zsh.pm 99
lib/Rex/Interface/Shell.pm 1520
lib/Rex/Inventory/Bios.pm 99
lib/Rex/Inventory/DMIDecode/BaseBoard.pm 99
lib/Rex/Inventory/DMIDecode/Bios.pm 88
lib/Rex/Inventory/DMIDecode/CPU.pm 1717
lib/Rex/Inventory/DMIDecode/Memory.pm 2323
lib/Rex/Inventory/DMIDecode/MemoryArray.pm 99
lib/Rex/Inventory/DMIDecode/Section.pm 7676
lib/Rex/Inventory/DMIDecode/SystemInformation.pm 1212
lib/Rex/Inventory/DMIDecode.pm 140140
lib/Rex/Inventory/HP/ACU.pm 187187
lib/Rex/Inventory/Hal/Object/Net.pm 1010
lib/Rex/Inventory/Hal/Object/Storage.pm 3535
lib/Rex/Inventory/Hal/Object/Volume.pm 2828
lib/Rex/Inventory/Hal/Object.pm 5454
lib/Rex/Inventory/Hal.pm 109109
lib/Rex/Inventory/Proc/Cpuinfo.pm 047
lib/Rex/Inventory/Proc.pm 039
lib/Rex/Inventory/SMBios/BaseBoard.pm 99
lib/Rex/Inventory/SMBios/Bios.pm 88
lib/Rex/Inventory/SMBios/CPU.pm 1414
lib/Rex/Inventory/SMBios/Memory.pm 1212
lib/Rex/Inventory/SMBios/MemoryArray.pm 99
lib/Rex/Inventory/SMBios/Section.pm 8585
lib/Rex/Inventory/SMBios/SystemInformation.pm 1212
lib/Rex/Inventory/SMBios.pm 8585
lib/Rex/Inventory.pm 125183
lib/Rex/Logger.pm 118118
lib/Rex/Notify.pm 0101
lib/Rex/Output/JUnit.pm 5959
lib/Rex/Output.pm 1313
lib/Rex/Pkg/ALT.pm 7676
lib/Rex/Pkg/Base.pm 2727
lib/Rex/Pkg/Debian.pm 106106
lib/Rex/Pkg/FreeBSD.pm 6565
lib/Rex/Pkg/Gentoo.pm 100100
lib/Rex/Pkg/Mageia.pm 7676
lib/Rex/Pkg/NetBSD.pm 7070
lib/Rex/Pkg/OpenBSD.pm 66
lib/Rex/Pkg/OpenWrt.pm 8787
lib/Rex/Pkg/Redhat.pm 9595
lib/Rex/Pkg/SuSE.pm 9191
lib/Rex/Pkg/SunOS/OpenCSW.pm 4040
lib/Rex/Pkg/SunOS/pkg.pm 7676
lib/Rex/Pkg/SunOS.pm 8686
lib/Rex/Pkg/Ubuntu.pm 66
lib/Rex/Pkg.pm 4343
lib/Rex/Profiler.pm 4141
lib/Rex/Report/Base.pm 1010
lib/Rex/Report/YAML.pm 110110
lib/Rex/Report.pm 1313
lib/Rex/SCM/Git.pm 4142
lib/Rex/SCM/Subversion.pm 5050
lib/Rex/Service/ALT/systemd.pm 55
lib/Rex/Service/ALT.pm 5050
lib/Rex/Service/Debian.pm 5151
lib/Rex/Service/FreeBSD.pm 5151
lib/Rex/Service/Gentoo/systemd.pm 55
lib/Rex/Service/Gentoo.pm 5151
lib/Rex/Service/Mageia/systemd.pm 66
lib/Rex/Service/Mageia.pm 5151
lib/Rex/Service/NetBSD.pm 5151
lib/Rex/Service/OpenBSD.pm 5151
lib/Rex/Service/OpenWrt.pm 2424
lib/Rex/Service/Redhat/systemd.pm 6262
lib/Rex/Service/Redhat.pm 5353
lib/Rex/Service/SuSE/systemd.pm 66
lib/Rex/Service/SuSE.pm 5151
lib/Rex/Service/SunOS/svcadm.pm 4747
lib/Rex/Service/SunOS.pm 5252
lib/Rex/Service/Ubuntu.pm 5555
lib/Rex/Service.pm 4646
lib/Rex/Shared/Var/Array.pm 7777
lib/Rex/Shared/Var/Hash.pm 6767
lib/Rex/Shared/Var/Scalar.pm 3333
lib/Rex/Shared/Var.pm 2727
lib/Rex/Sudo/File.pm 7575
lib/Rex/Task.pm 360366
lib/Rex/TaskList/Base.pm 187187
lib/Rex/TaskList.pm 1919
lib/Rex/Template.pm 143143
lib/Rex/Transaction.pm 4949
lib/Rex/User/FreeBSD.pm 183183
lib/Rex/User/Linux.pm 320320
lib/Rex/User/NetBSD.pm 124124
lib/Rex/User/OpenBSD.pm 105105
lib/Rex/User/OpenWrt.pm 4141
lib/Rex/User/SunOS.pm 111111
lib/Rex/User.pm 2929
lib/Rex/Value.pm 99
lib/Rex/Virtualization/Base.pm 1515
lib/Rex/Virtualization/Docker/create.pm 103103
lib/Rex/Virtualization/Docker/daemon.pm 99
lib/Rex/Virtualization/Docker/delete.pm 1414
lib/Rex/Virtualization/Docker/destroy.pm 1414
lib/Rex/Virtualization/Docker/info.pm 1212
lib/Rex/Virtualization/Docker/list.pm 3535
lib/Rex/Virtualization/Docker/reboot.pm 1414
lib/Rex/Virtualization/Docker/shutdown.pm 1414
lib/Rex/Virtualization/Docker/start.pm 1414
lib/Rex/Virtualization/Docker.pm 2323
lib/Rex/Virtualization/LibVirt/blklist.pm 3842
lib/Rex/Virtualization/LibVirt/clone.pm 1011
lib/Rex/Virtualization/LibVirt/create.pm 381403
lib/Rex/Virtualization/LibVirt/delete.pm 1718
lib/Rex/Virtualization/LibVirt/destroy.pm 1718
lib/Rex/Virtualization/LibVirt/dumpxml.pm 1417
lib/Rex/Virtualization/LibVirt/guestinfo.pm 2829
lib/Rex/Virtualization/LibVirt/hypervisor.pm 5365
lib/Rex/Virtualization/LibVirt/iflist.pm 4848
lib/Rex/Virtualization/LibVirt/info.pm 2023
lib/Rex/Virtualization/LibVirt/list.pm 2940
lib/Rex/Virtualization/LibVirt/option.pm 2325
lib/Rex/Virtualization/LibVirt/reboot.pm 1922
lib/Rex/Virtualization/LibVirt/shutdown.pm 1922
lib/Rex/Virtualization/LibVirt/start.pm 1922
lib/Rex/Virtualization/LibVirt/vncdisplay.pm 1417
lib/Rex/Virtualization/LibVirt.pm 2525
lib/Rex/Virtualization/VBox/bridge.pm 3030
lib/Rex/Virtualization/VBox/create.pm 120120
lib/Rex/Virtualization/VBox/delete.pm 1414
lib/Rex/Virtualization/VBox/destroy.pm 1414
lib/Rex/Virtualization/VBox/forward_port.pm 3535
lib/Rex/Virtualization/VBox/guestinfo.pm 5353
lib/Rex/Virtualization/VBox/import.pm 1818
lib/Rex/Virtualization/VBox/info.pm 2020
lib/Rex/Virtualization/VBox/list.pm 3333
lib/Rex/Virtualization/VBox/option.pm 2424
lib/Rex/Virtualization/VBox/reboot.pm 1414
lib/Rex/Virtualization/VBox/share_folder.pm 4545
lib/Rex/Virtualization/VBox/shutdown.pm 1414
lib/Rex/Virtualization/VBox/start.pm 5050
lib/Rex/Virtualization/VBox/status.pm 1111
lib/Rex/Virtualization/VBox.pm 3535
lib/Rex/Virtualization.pm 3131
lib/Rex.pm 366376
t/base.t 22
t/base_cloud.t 22
t/base_inventory.t 23
t/env.t 013
t/file.t 6776
t/ifconfig.out7 07
t/ip.out3 03
t/network_linux.t 113
t/virtualization.t 17
283 files changed (This is a version diff) 1937220776
@@ -19,19 +19,21 @@ Jean Charles Passard
 Jeen Lee
 Jonathan Delgado
 Jon Gentle
-Joris
+Joris DE POOTER
 Jose Luis Martinez
 Kasim Tuman
 Keedi Kim
 Laird Liu
 Mario Domgoergen
 Naveed Massjouni
+Niklas Larsson
 Nikolay Fetisov
 Nils Domrose
 Peter H. Ezetta
 Piotr Karbowski
 Rao Chenlin (Chenryn)
 RenatoCRON
+Renee Bäcker
 Samuele Tognini
 Sascha Guenther
 Simon Bertrang
@@ -1,3 +1,33 @@
+2014-04-13 Jan Gehring <jan.gehring, gmail.com> (0.45.3)
+  * fixed jiffybox endless loop on creating instances. #344 - Renee
+
+2014-04-12 Jan Gehring <jan.gehring, gmail.com> (0.45.2)
+  * fixed special mkdir() case on local windows runs.
+
+2014-04-11 Jan Gehring <jan.gehring, gmail.com> (0.45.1)
+  * no_overwrite option for file() function
+  * ensure 'directory' option for file() function
+  * added notifications
+  * pkg resource (replacement for install function)
+  * allow array for file() function
+  * check if iptables rule already exists
+  * creates option for run() resource
+  * only_if and unless option for run() resrouce
+  * added notification for service() resource
+  * added account() resource (as replacement for create_user)
+  * fixed SCM::Git to work with sudo
+  * update _parse_ip subroutine. be possible to parse ppp0. #328 - Tomohiro Hosaka
+  * support -g to supply group name - #330 - fanyeren
+  * added openstack cloud support - Ferenc Erki
+  * run() resource support customized environments - #316 andrejzverev
+  * can_run() now returns the first command found as string - #193
+  * read cpu information out of /proc/cpuinfo if dmidecode is not available - #306
+  * Handles the case where rsync is missing, and that makes Rex wait forever - #331 - Joris DE POOTER
+  * fixed $Rex::Logger::format does not apply. - #335
+  * fixed download() command on windows - #271
+  * added cloud_image_list function()
+  * fixed debian system_update - #339 - Niklas Larsson
+
 2014-03-02 Jan Gehring <jan.gehring, gmail.com> (0.44.6)
   * fixed wrong expansion of home paths #324
   * fixed return code on failed connects is wrong #317
@@ -160,10 +190,10 @@
   * new keyword "case"
   * Refactored net_ssh2_exec() function - Peter H. Ezetta
   * Refactored local command execution to use IPC::Open3
-  * Changed the Debian is_installed function to use the more accurate 
+  * Changed the Debian is_installed function to use the more accurate
     get_installed function. - Samuele Tognini
-  * '-t' option should work with '-e' option. rex -t 2 -H "hostA hostB" 
-     -e 'run "sleep 10"; say run "uptime"' should run in parallel. 
+  * '-t' option should work with '-e' option. rex -t 2 -H "hostA hostB"
+     -e 'run "sleep 10"; say run "uptime"' should run in parallel.
      - Tokuhiro Matsuno
   * Fixed loading of modules in $HOME/.rex/recipes
   * Don't calculate md5 sums if there is no on_change hook for file() function - Franky Van Liedekerke
@@ -522,7 +552,7 @@
 
 2011-07-26 Jan Gehring <jan.gehring, gmail.com> (0.11.1)
   * fixed output of netstat (reported by Thomas Biege)
-  * fixed inclusion of some modules in Run.pm that causes errors under 
+  * fixed inclusion of some modules in Run.pm that causes errors under
     some circumstances (reported by Thomas Biege)
 
 2011-07-22 Jan Gehring <jan.gehring, gmail.com> (0.11.0)
@@ -588,4 +618,3 @@
   * fixed #68827, rewrote is_readable/is_writable
   * handle auth failure correctly
   * mkdir now created directories recursive
-
@@ -17,6 +17,7 @@ lib/Rex/Cloud.pm
 lib/Rex/Cloud/Amazon.pm
 lib/Rex/Cloud/Base.pm
 lib/Rex/Cloud/Jiffybox.pm
+lib/Rex/Cloud/OpenStack.pm
 lib/Rex/CMDB.pm
 lib/Rex/CMDB/YAML.pm
 lib/Rex/Commands.pm
@@ -35,6 +36,7 @@ lib/Rex/Commands/Kernel.pm
 lib/Rex/Commands/LVM.pm
 lib/Rex/Commands/MD5.pm
 lib/Rex/Commands/Network.pm
+lib/Rex/Commands/Notify.pm
 lib/Rex/Commands/Partition.pm
 lib/Rex/Commands/Pkg.pm
 lib/Rex/Commands/Process.pm
@@ -125,6 +127,7 @@ lib/Rex/Interface/Fs/SSH.pm
 lib/Rex/Interface/Fs/Sudo.pm
 lib/Rex/Interface/Shell.pm
 lib/Rex/Interface/Shell/Ash.pm
+lib/Rex/Interface/Shell/Base.pm
 lib/Rex/Interface/Shell/Bash.pm
 lib/Rex/Interface/Shell/Csh.pm
 lib/Rex/Interface/Shell/Default.pm
@@ -148,6 +151,8 @@ lib/Rex/Inventory/Hal/Object/Net.pm
 lib/Rex/Inventory/Hal/Object/Storage.pm
 lib/Rex/Inventory/Hal/Object/Volume.pm
 lib/Rex/Inventory/HP/ACU.pm
+lib/Rex/Inventory/Proc.pm
+lib/Rex/Inventory/Proc/Cpuinfo.pm
 lib/Rex/Inventory/SMBios.pm
 lib/Rex/Inventory/SMBios/BaseBoard.pm
 lib/Rex/Inventory/SMBios/Bios.pm
@@ -157,6 +162,7 @@ lib/Rex/Inventory/SMBios/MemoryArray.pm
 lib/Rex/Inventory/SMBios/Section.pm
 lib/Rex/Inventory/SMBios/SystemInformation.pm
 lib/Rex/Logger.pm
+lib/Rex/Notify.pm
 lib/Rex/Output.pm
 lib/Rex/Output/JUnit.pm
 lib/Rex/Pkg.pm
@@ -297,6 +303,7 @@ t/dmi.fbsd.out
 t/dmi.linux.out
 t/dmi.obsd.out
 t/dmi.t
+t/env.t
 t/file.t
 t/fs.t
 t/group.t
@@ -311,10 +318,12 @@ t/ifconfig.out3
 t/ifconfig.out4
 t/ifconfig.out5
 t/ifconfig.out6
+t/ifconfig.out7
 t/ini.t
 t/interface_fs_local.t
 t/ip.out1
 t/ip.out2
+t/ip.out3
 t/iptables.t
 t/last_command_output.t
 t/libvirt.t
@@ -333,5 +342,4 @@ t/test.ini
 t/url_encode.t
 t/vbox.t
 t/virtualization.t
-META.yml                                 Module YAML meta-data (added by MakeMaker)
-META.json                                Module JSON meta-data (added by MakeMaker)
+META.yml                                 Module meta-data (added by MakeMaker)
@@ -1,61 +0,0 @@
-{
-   "abstract" : "unknown",
-   "author" : [
-      "unknown"
-   ],
-   "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150",
-   "license" : [
-      "unknown"
-   ],
-   "meta-spec" : {
-      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
-      "version" : "2"
-   },
-   "name" : "Rex",
-   "no_index" : {
-      "directory" : [
-         "t",
-         "inc"
-      ]
-   },
-   "prereqs" : {
-      "build" : {
-         "requires" : {
-            "ExtUtils::MakeMaker" : 0
-         }
-      },
-      "configure" : {
-         "requires" : {
-            "ExtUtils::MakeMaker" : 0
-         }
-      },
-      "runtime" : {
-         "requires" : {
-            "DBI" : 0,
-            "Digest::HMAC_SHA1" : 0,
-            "Expect" : 0,
-            "HTTP::Date" : 0,
-            "IPC::Open3" : 0,
-            "JSON::XS" : 0,
-            "LWP::Simple" : 0,
-            "LWP::UserAgent" : 0,
-            "List::MoreUtils" : 0,
-            "MIME::Base64" : 0,
-            "Net::SSH2" : "0.33",
-            "Storable" : 0,
-            "String::Escape" : 0,
-            "Time::HiRes" : 0,
-            "XML::Simple" : 0,
-            "YAML" : 0
-         }
-      }
-   },
-   "release_status" : "stable",
-   "resources" : {
-      "repository" : {
-         "url" : "https://github.com/krimdomu/Rex"
-      }
-   },
-   "version" : "v0.44.6.1"
-}
@@ -1,39 +1,38 @@
----
-abstract: unknown
-author:
-  - unknown
-build_requires:
-  ExtUtils::MakeMaker: 0
+--- #YAML:1.0
+name:               Rex
+version:            0.45.3
+abstract:           ~
+author:  []
+license:            Apache License 2.0
+distribution_type:  module
 configure_requires:
-  ExtUtils::MakeMaker: 0
-dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150'
-license: unknown
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
-name: Rex
-no_index:
-  directory:
-    - t
-    - inc
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
 requires:
-  DBI: 0
-  Digest::HMAC_SHA1: 0
-  Expect: 0
-  HTTP::Date: 0
-  IPC::Open3: 0
-  JSON::XS: 0
-  LWP::Simple: 0
-  LWP::UserAgent: 0
-  List::MoreUtils: 0
-  MIME::Base64: 0
-  Net::SSH2: 0.33
-  Storable: 0
-  String::Escape: 0
-  Time::HiRes: 0
-  XML::Simple: 0
-  YAML: 0
+    DBI:                0
+    Digest::HMAC_SHA1:  0
+    Expect:             0
+    HTTP::Date:         0
+    IPC::Open3:         0
+    JSON::XS:           0
+    List::MoreUtils:    0
+    LWP::Simple:        0
+    LWP::UserAgent:     0
+    MIME::Base64:       0
+    Net::SSH2:          0.33
+    Storable:           0
+    String::Escape:     0
+    Time::HiRes:        0
+    XML::Simple:        0
+    YAML:               0
 resources:
-  repository: https://github.com/krimdomu/Rex
-version: v0.44.6.1
+    repository:  https://github.com/krimdomu/Rex
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.57_05
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4
@@ -1,58 +0,0 @@
-Rex - A tool to ease your daily system administration tasks
-===========================================================
-
-With Rex you can manage all your boxes from a central point through the complete process of configuration management and software deployment.
-
-INSTALLATION
-
-To install Rex type the following:
-
-   perl Makefile.PL
-   make
-   make test
-   make install
-
-DEPENDENCIES
-
-This module requires these other modules, libraries and programs:
-
-   Net::SSH2
-   Expect (If you want to use the sync command)
-   DBI (If you want to use the db command)
-   rsync (If you want to use the sync command)
-
-BUGS/FEATURE REQUESTS
-
-Please report bugs and request features on the CPAN bug tracking site,
-rt.cpan.org.  If you are able and willing to provide a fix, attach a patch
-and please provide your name to be credited in the changelog and an email
-address for verification/discussion.
-
-HACKING
-
-The module is kept in a GitHub (https://github.com/krimdomu/Rex/)
-repository.
-
-If you are interested in making a change/fix, just do a pull request.
-
-TODO
-
-More examples and guides would be nice.
-
-COPYRIGHT AND LICENCE
-
-Copyright (C) 2011 by Jan Gehring; all rights reserved.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
@@ -27,10 +27,10 @@ my $opts = {};
 
 ######
 # default server
-my $SEARCH_SERVER = "http://modules.rexify.org/api/0.44/get/recipes";
-my $RECIPE_SERVER = "http://modules.rexify.org/api/0.44/get/mod/%s";
-my $DEPEND_SERVER = "http://modules.rexify.org/api/0.44/get/dep/%s";
-my $PERL_DEPEND_SERVER = "http://modules.rexify.org/api/0.44/get/perldep/%s";
+my $SEARCH_SERVER = "http://modules.rexify.org/api/0.45/get/recipes";
+my $RECIPE_SERVER = "http://modules.rexify.org/api/0.45/get/mod/%s";
+my $DEPEND_SERVER = "http://modules.rexify.org/api/0.45/get/dep/%s";
+my $PERL_DEPEND_SERVER = "http://modules.rexify.org/api/0.45/get/perldep/%s";
 
 my $AUTH_USER;
 my $AUTH_PASSWORD;
@@ -1,28 +1,28 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Args::Integer;
-   
+  
 use strict;
 use warnings;
 
 use Rex::Logger;
 
 sub get {
-   my ($class, $name) = @_;
+  my ($class, $name) = @_;
 
-   my $arg = shift @ARGV;
+  my $arg = shift @ARGV;
 
-   if($arg =~ m/^\d+$/) {
-      return $arg;
-   }
+  if($arg =~ m/^\d+$/) {
+    return $arg;
+  }
 
-   Rex::Logger::debug("Invalid argument for $name");
+  Rex::Logger::debug("Invalid argument for $name");
 
-   return undef;
+  return undef;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
    
 package Rex::Args::Single;
@@ -1,19 +1,19 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Args::String;
-   
+  
 use strict;
 use warnings;
 
 sub get {
-   my ($class, $name) = @_;
+  my ($class, $name) = @_;
 
-   my $arg = shift @ARGV;
-   return $arg;
+  my $arg = shift @ARGV;
+  return $arg;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Args;
-   
+  
 use strict;
 use warnings;
 
@@ -18,109 +18,109 @@ our $REMOVE_TASK_OPTIONS = 0;
 our $CLEANUP = 1;
 
 sub import {
-   my ($class, %args) = @_;
-
-   #### clean up @ARGV
-   my $runner = 0;
-   for (@ARGV) {
-      if(/^\-[A-Za-z]+/ && length($_) > 2 && $CLEANUP) {
-         my @args = map { "-$_" } split(//, substr($_, 1));
-         splice(@ARGV, $runner, 1, @args);
-      }
-
-      $runner++
-   }
-
-   #### parse rex options
-   my @params = @ARGV;
-   for my $p (@params) {
-      # shift off @ARGV
-      my $shift = shift @ARGV;
-
-      if(length($p) >= 2 && substr($p, 0, 1) eq "-") {
-         my $name_param = substr($p, 1, 2);
-         # found a parameter
-
-         if(exists $args{$name_param}) {
-            Rex::Logger::debug("Option found: $name_param ($p)");
-            my $type = "Single";
-
-            if(exists $args{$name_param}->{type}) {
-               $type = $args{$name_param}->{type};
-
-               Rex::Logger::debug("   is a $type");
-               shift @params; # remove the next parameter, because it must be an option
-
-               if(! exists $ARGV[0] || ( length($ARGV[0]) == 2 && exists $args{substr($ARGV[0], 1, 2)} && substr($ARGV[0], 0, 1) eq "-" )) {
-                  # this is a typed parameter without an option!
-                  Rex::Logger::debug("   but there is no parameter");
-                  Rex::Logger::debug(Dumper(\@params));
-                  print("No parameter for $name_param\n");
-                  CORE::exit 1;
-               }
-            }
-            elsif(exists $args{$name_param}->{func}) {
-               Rex::Logger::debug("   is a function - executing now");
-               $args{$name_param}->{func}->();
-            }
-
-            my $c = "Rex::Args::\u$type";
-            eval "use $c";
-            if($@) {
-               die("No Argumentclass $type found!");
-            }
-
-            if(exists $rex_opts{$name_param} && $type eq "Single") {
-               $rex_opts{$name_param}++;
-            }
-            else {
-               $rex_opts{$name_param} = $c->get;
-            }
-         }
-         else {
-            Rex::Logger::debug("Option not known: $name_param ($p)");
-            next;
-         }
+  my ($class, %args) = @_;
+
+  #### clean up @ARGV
+  my $runner = 0;
+  for (@ARGV) {
+    if(/^\-[A-Za-z]+/ && length($_) > 2 && $CLEANUP) {
+      my @args = map { "-$_" } split(//, substr($_, 1));
+      splice(@ARGV, $runner, 1, @args);
+    }
+
+    $runner++
+  }
+
+  #### parse rex options
+  my @params = @ARGV;
+  for my $p (@params) {
+    # shift off @ARGV
+    my $shift = shift @ARGV;
+
+    if(length($p) >= 2 && substr($p, 0, 1) eq "-") {
+      my $name_param = substr($p, 1, 2);
+      # found a parameter
+
+      if(exists $args{$name_param}) {
+        Rex::Logger::debug("Option found: $name_param ($p)");
+        my $type = "Single";
+
+        if(exists $args{$name_param}->{type}) {
+          $type = $args{$name_param}->{type};
+
+          Rex::Logger::debug("  is a $type");
+          shift @params; # remove the next parameter, because it must be an option
+
+          if(! exists $ARGV[0] || ( length($ARGV[0]) == 2 && exists $args{substr($ARGV[0], 1, 2)} && substr($ARGV[0], 0, 1) eq "-" )) {
+            # this is a typed parameter without an option!
+            Rex::Logger::debug("  but there is no parameter");
+            Rex::Logger::debug(Dumper(\@params));
+            print("No parameter for $name_param\n");
+            CORE::exit 1;
+          }
+        }
+        elsif(exists $args{$name_param}->{func}) {
+          Rex::Logger::debug("  is a function - executing now");
+          $args{$name_param}->{func}->();
+        }
+
+        my $c = "Rex::Args::\u$type";
+        eval "use $c";
+        if($@) {
+          die("No Argumentclass $type found!");
+        }
+
+        if(exists $rex_opts{$name_param} && $type eq "Single") {
+          $rex_opts{$name_param}++;
+        }
+        else {
+          $rex_opts{$name_param} = $c->get;
+        }
       }
       else {
-         # unshift the last parameter
-         unshift @ARGV, $shift;
-         last;
+        Rex::Logger::debug("Option not known: $name_param ($p)");
+        next;
       }
-   }
-   
-
-   #### parse task options
-
-   @params = @ARGV[1..$#ARGV];
-
-   my $counter = 1;
-   for my $p (@params) {
-      my($key, $val) = split(/=/, $p, 2);
-
-      if(defined $val) {
-         if($REMOVE_TASK_OPTIONS) {
-            splice(@ARGV, $counter, 1);
-         }
+    }
+    else {
+      # unshift the last parameter
+      unshift @ARGV, $shift;
+      last;
+    }
+  }
+  
+
+  #### parse task options
+
+  @params = @ARGV[1..$#ARGV];
+
+  my $counter = 1;
+  for my $p (@params) {
+    my($key, $val) = split(/=/, $p, 2);
+
+    if(defined $val) {
+      if($REMOVE_TASK_OPTIONS) {
+        splice(@ARGV, $counter, 1);
       }
+    }
 
-      $key =~ s/^--//;
+    $key =~ s/^--//;
 
-      if($val) { $task_opts{$key} = $val; next; }
-      $task_opts{$key} = $KEY_VAL;
+    if($val) { $task_opts{$key} = $val; next; }
+    $task_opts{$key} = $KEY_VAL;
 
-      $counter++;
-   }
+    $counter++;
+  }
 
 }
 
 sub getopts { return %rex_opts; }
 
 sub is_opt {
-   my ($class, $opt) = @_;
-   if(exists $rex_opts{$opt}) {
-      return $rex_opts{$opt};
-   }
+  my ($class, $opt) = @_;
+  if(exists $rex_opts{$opt}) {
+    return $rex_opts{$opt};
+  }
 }
 
 sub get { return %task_opts; }
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Batch;
@@ -15,57 +15,57 @@ use Rex::TaskList;
 use vars qw(%batchs);
 
 sub create_batch {
-   my $class = shift;
-   my $batch_name = shift;
-   my $batch_desc = pop;
-   my @tasks = @_;
-
-   $batchs{$batch_name} = {
-      desc => $batch_desc,
-      tasks => \@tasks
-   };
+  my $class = shift;
+  my $batch_name = shift;
+  my $batch_desc = pop;
+  my @tasks = @_;
+
+  $batchs{$batch_name} = {
+    desc => $batch_desc,
+    tasks => \@tasks
+  };
 }
 
 sub get_batch {
-   my $class = shift;
-   my $batch_name = shift;
+  my $class = shift;
+  my $batch_name = shift;
 
-   return @{$batchs{$batch_name}->{'tasks'}};
+  return @{$batchs{$batch_name}->{'tasks'}};
 }
 
 sub get_desc {
-   my $class = shift;
-   my $batch_name = shift;
+  my $class = shift;
+  my $batch_name = shift;
 
-   return $batchs{$batch_name}->{'desc'};
+  return $batchs{$batch_name}->{'desc'};
 }
 
 sub get_batchs {
-   my $class = shift;
-   my @a = sort { $a cmp $b } keys %batchs;
+  my $class = shift;
+  my @a = sort { $a cmp $b } keys %batchs;
 }
 
 sub is_batch {
-   my $class = shift;
-   my $batch_name = shift;
+  my $class = shift;
+  my $batch_name = shift;
 
-   if(defined $batchs{$batch_name}) { return 1; }
-   return 0;
+  if(defined $batchs{$batch_name}) { return 1; }
+  return 0;
 }
 
 sub run {
-   my $class = shift;
-   my $batch = shift;
-
-   my @tasks = $class->get_batch($batch);
-   for my $t (@tasks) {
-      if(Rex::TaskList->create()->is_task($t)) {
-         Rex::TaskList->create()->run($t);
-      } else {
-         print STDERR "ERROR: no task: $t\n";
-         die;
-      }
-   }
+  my $class = shift;
+  my $batch = shift;
+
+  my @tasks = $class->get_batch($batch);
+  for my $t (@tasks) {
+    if(Rex::TaskList->create()->is_task($t)) {
+      Rex::TaskList->create()->run($t);
+    } else {
+      print STDERR "ERROR: no task: $t\n";
+      die;
+    }
+  }
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 =head1 NAME
 
 Rex::Box::Amazon - Rex/Boxes Amazon Module
@@ -18,54 +18,54 @@ To use this module inside your Rexfile you can use the following commands.
 
  use Rex::Commands::Boxes;
  set box => "Amazon", {
-    access_key => "your-access-key",
-    private_access_key => "your-private-access-key",
-    region => "ec2.eu-west-1.amazonaws.com",
-    zone => "eu-west-1a",
-    authkey => "default",
+   access_key => "your-access-key",
+   private_access_key => "your-private-access-key",
+   region => "ec2.eu-west-1.amazonaws.com",
+   zone => "eu-west-1a",
+   authkey => "default",
  };
-   
+  
  task "prepare_box", sub {
-    box {
-       my ($box) = @_;
-          
-       $box->name("mybox");
-       $box->ami("ami-c1aaabb5");
-       $box->type("m1.large"); 
-           
-       $box->security_group("default");
-           
-       $box->auth(
-          user => "root",
-          password => "box",
-       );
-           
-       $box->setup("setup_task");
-    };
+   box {
+     my ($box) = @_;
+       
+     $box->name("mybox");
+     $box->ami("ami-c1aaabb5");
+     $box->type("m1.large"); 
+        
+     $box->security_group("default");
+        
+     $box->auth(
+       user => "root",
+       password => "box",
+     );
+        
+     $box->setup("setup_task");
+   };
  };
 
 If you want to use a YAML file you can use the following template.
 
  type: Amazon
  amazon:
-    access_key: your-access-key
-    private_access_key: your-private-access-key
-    region: ec2.eu-west-1.amazonaws.com
-    zone: eu-west-1a
-    auth_key: default
+   access_key: your-access-key
+   private_access_key: your-private-access-key
+   region: ec2.eu-west-1.amazonaws.com
+   zone: eu-west-1a
+   auth_key: default
  vms:
-    vmone:
-       ami: ami-c1aaabb5
-       type: m1.large
-       security_group: default
-       setup: setup_task
+   vmone:
+     ami: ami-c1aaabb5
+     type: m1.large
+     security_group: default
+     setup: setup_task
 
 And then you can use it the following way in your Rexfile.
 
  use Rex::Commands::Box init_file => "file.yml";
-    
+   
  task "prepare_vms", sub {
-    boxes "init";
+   boxes "init";
  };
 
 
@@ -108,57 +108,57 @@ Constructor if used in OO mode.
 =cut
 
 sub new {
-   my $class = shift;
-   my $proto = ref($class) || $class;
-   my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, ref($class) || $class);
+  bless($self, ref($class) || $class);
 
-   cloud_service "Amazon";
-   cloud_auth $self->{options}->{access_key}, $self->{options}->{private_access_key};
-   cloud_region $self->{options}->{region};
+  cloud_service "Amazon";
+  cloud_auth $self->{options}->{access_key}, $self->{options}->{private_access_key};
+  cloud_region $self->{options}->{region};
 
-   return $self;
+  return $self;
 }
 
 sub import_vm {
-   my ($self) = @_;
-
-   # check if machine already exists
-
-   # Rex::Logger::debug("VM already exists. Don't import anything.");
-   #my @vms = cloud_instance_list;
-   my @vms = $self->list_boxes;
-
-   my $vminfo;
-   my $vm_exists = 0;
-   for my $vm (@vms) {
-      if($vm->{name} && $vm->{name} eq $self->{name}) {
-         Rex::Logger::debug("VM already exists. Don't import anything.");
-         $vm_exists = 1;
-         $vminfo = $vm;
-      }
-   }
-
-   if(! $vm_exists) {
-      # if not, create it
-      Rex::Logger::info("Creating Amazon instance $self->{name}.");
-      $vminfo = cloud_instance create => {
-         image_id => $self->{ami},
-         name     => $self->{name},
-         key      => $self->{options}->{auth_key},
-         zone     => $self->{options}->{zone},
-         type     => $self->{type} || "m1.large",
-         security_group => $self->{security_group} || "default",
-      };
-   }
-
-   # start if stopped
-   if($vminfo->{state} eq "stopped") {
-      cloud_instance start => $vminfo->{id};
-   }
-
-   $self->{info} = $vminfo;
+  my ($self) = @_;
+
+  # check if machine already exists
+
+  # Rex::Logger::debug("VM already exists. Don't import anything.");
+  #my @vms = cloud_instance_list;
+  my @vms = $self->list_boxes;
+
+  my $vminfo;
+  my $vm_exists = 0;
+  for my $vm (@vms) {
+    if($vm->{name} && $vm->{name} eq $self->{name}) {
+      Rex::Logger::debug("VM already exists. Don't import anything.");
+      $vm_exists = 1;
+      $vminfo = $vm;
+    }
+  }
+
+  if(! $vm_exists) {
+    # if not, create it
+    Rex::Logger::info("Creating Amazon instance $self->{name}.");
+    $vminfo = cloud_instance create => {
+      image_id => $self->{ami},
+      name    => $self->{name},
+      key    => $self->{options}->{auth_key},
+      zone    => $self->{options}->{zone},
+      type    => $self->{type} || "m1.large",
+      security_group => $self->{security_group} || "default",
+    };
+  }
+
+  # start if stopped
+  if($vminfo->{state} eq "stopped") {
+    cloud_instance start => $vminfo->{id};
+  }
+
+  $self->{info} = $vminfo;
 }
 
 =item ami($ami_id)
@@ -167,8 +167,8 @@ Set the AMI ID for the box.
 
 =cut
 sub ami {
-   my ($self, $ami) = @_;
-   $self->{ami} = $ami;
+  my ($self, $ami) = @_;
+  $self->{ami} = $ami;
 }
 
 =item type($type)
@@ -177,8 +177,8 @@ Set the type of the Instance. For example "m1.large".
 
 =cut
 sub type {
-   my ($self, $type) = @_;
-   $self->{type} = $type;
+  my ($self, $type) = @_;
+  $self->{type} = $type;
 }
 
 =item security_group($sec_group)
@@ -187,28 +187,28 @@ Set the Amazon security group for this Instance.
 
 =cut
 sub security_group {
-   my ($self, $sec_group) = @_;
-   $self->{security_group} = $sec_group;
+  my ($self, $sec_group) = @_;
+  $self->{security_group} = $sec_group;
 }
 
 sub provision_vm {
-   my ($self, @tasks) = @_;
+  my ($self, @tasks) = @_;
 
-   if(! @tasks) {
-      @tasks = @{ $self->{__tasks} };
-   }
+  if(! @tasks) {
+    @tasks = @{ $self->{__tasks} };
+  }
 
-   my $server = $self->ip;
+  my $server = $self->ip;
 
-   my ($ip, $port) = split(/:/, $server);
-   $port ||= 22;
+  my ($ip, $port) = split(/:/, $server);
+  $port ||= 22;
 
-   $self->wait_for_ssh($ip, $port);
+  $self->wait_for_ssh($ip, $port);
 
-   for my $task (@tasks) {
-      Rex::TaskList->create()->get_task($task)->set_auth(%{ $self->{__auth} });
-      Rex::TaskList->create()->get_task($task)->run($server);
-   }
+  for my $task (@tasks) {
+    Rex::TaskList->create()->get_task($task)->set_auth(%{ $self->{__auth} });
+    Rex::TaskList->create()->get_task($task)->run($server);
+  }
 }
 
 =item forward_port(%option)
@@ -226,49 +226,49 @@ Not available for Amazon Boxes.
 sub share_folder { Rex::Logger::debug("Not available for Amazon Boxes."); }
 
 sub list_boxes {
-   my ($self) = @_;
-   
-   my @vms = cloud_instance_list;
+  my ($self) = @_;
+  
+  my @vms = cloud_instance_list;
 
-   my @ret = grep { $_->{name} 
-                 && $_->{state} ne "terminated" 
-                 && $_->{state} ne "shutting-down"
-               } @vms; # only vms with names...
+  my @ret = grep { $_->{name} 
+            && $_->{state} ne "terminated" 
+            && $_->{state} ne "shutting-down"
+          } @vms; # only vms with names...
 
-   return @ret;
+  return @ret;
 }
 
 sub status {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   $self->info;
+  $self->info;
 
-   if($self->{info}->{state} eq "running") {
-      return "running";
-   }
-   else {
-      return "stopped";
-   }
+  if($self->{info}->{state} eq "running") {
+    return "running";
+  }
+  else {
+    return "stopped";
+  }
 }
 
 sub start {
-   my ($self) = @_;
-   
-   $self->info;
+  my ($self) = @_;
+  
+  $self->info;
 
-   Rex::Logger::info("Starting instance: " . $self->{name});
+  Rex::Logger::info("Starting instance: " . $self->{name});
 
-   cloud_instance start => $self->{info}->{id};
+  cloud_instance start => $self->{info}->{id};
 }
 
 sub stop {
-   my ($self) = @_;
-   
-   Rex::Logger::info("Stopping instance: " . $self->{name});
+  my ($self) = @_;
+  
+  Rex::Logger::info("Stopping instance: " . $self->{name});
 
-   $self->info;
+  $self->info;
 
-   cloud_instance stop => $self->{info}->{id};
+  cloud_instance stop => $self->{info}->{id};
 }
 
 =item info
@@ -277,18 +277,18 @@ Returns a hashRef of vm information.
 
 =cut
 sub info {
-   my ($self) = @_;
-   ($self->{info}) = grep { $_->{name} eq $self->{name} } $self->list_boxes;
-   return $self->{info};
+  my ($self) = @_;
+  ($self->{info}) = grep { $_->{name} eq $self->{name} } $self->list_boxes;
+  return $self->{info};
 }
 
 sub ip {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   # get instance info
-   ($self->{info}) = grep { $_->{name} eq $self->{name} } $self->list_boxes;
+  # get instance info
+  ($self->{info}) = grep { $_->{name} eq $self->{name} } $self->list_boxes;
 
-   return $self->{info}->{ip};
+  return $self->{info}->{ip};
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -37,21 +37,21 @@ use File::Basename qw(basename);
 use Data::Dumper;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   # default auth for rex boxes
-   $self->{__auth} = {
-      user        => Rex::Config->get_user(),
-      password    => Rex::Config->get_password(),
-      private_key => Rex::Config->get_private_key(),
-      public_key  => Rex::Config->get_public_key(),
-   };
+  # default auth for rex boxes
+  $self->{__auth} = {
+    user      => Rex::Config->get_user(),
+    password   => Rex::Config->get_password(),
+    private_key => Rex::Config->get_private_key(),
+    public_key  => Rex::Config->get_public_key(),
+  };
 
-   return $self;
+  return $self;
 }
 
 =item info
@@ -60,8 +60,8 @@ Returns a hashRef of vm information.
 
 =cut
 sub info {
-   my ($self) = @_;
-   return $self->{info};
+  my ($self) = @_;
+  return $self->{info};
 }
 
 =item name($vmname)
@@ -70,8 +70,8 @@ Sets the name of the virtual machine.
 
 =cut
 sub name {
-   my ($self, $name) = @_;
-   $self->{name} = $name;
+  my ($self, $name) = @_;
+  $self->{name} = $name;
 }
 
 =item setup(@tasks)
@@ -80,8 +80,8 @@ Sets the tasks that should be executed as soon as the VM is available throu SSH.
 
 =cut
 sub setup {
-   my ($self, @tasks) = @_;
-   $self->{__tasks} = \@tasks;
+  my ($self, @tasks) = @_;
+  $self->{__tasks} = \@tasks;
 }
 
 =item import_vm()
@@ -90,8 +90,8 @@ This method must be overwriten by the implementing class.
 
 =cut
 sub import_vm {
-   my ($self) = @_;
-   die("This method must be overwriten.");
+  my ($self) = @_;
+  die("This method must be overwriten.");
 }
 
 =item stop()
@@ -100,9 +100,9 @@ Stops the VM.
 
 =cut
 sub stop {
-   my ($self) = @_;
-   $self->info;
-   vm shutdown => $self->{name};
+  my ($self) = @_;
+  $self->info;
+  vm shutdown => $self->{name};
 }
 
 =item start()
@@ -111,9 +111,9 @@ Starts the VM.
 
 =cut
 sub start {
-   my ($self) = @_;
-   $self->info;
-   vm start => $self->{name};
+  my ($self) = @_;
+  $self->info;
+  vm start => $self->{name};
 
 }
 
@@ -132,8 +132,8 @@ Valid return values are "running" and "stopped".
 
 =cut
 sub status {
-   my ($self) = @_;
-   return vm status => $self->{name};
+  my ($self) = @_;
+  return vm status => $self->{name};
 }
 
 =item provision_vm([@tasks])
@@ -142,8 +142,8 @@ Execute's the given tasks on the VM.
 
 =cut
 sub provision_vm {
-   my ($self, @tasks) = @_;
-   die("This method must be overwriten.");
+  my ($self, @tasks) = @_;
+  die("This method must be overwriten.");
 }
 
 =item cpus($count)
@@ -152,8 +152,8 @@ Set the amount of CPUs for the VM.
 
 =cut
 sub cpus {
-   my ($self, $cpus) = @_;
-   $self->{cpus} = $cpus;
+  my ($self, $cpus) = @_;
+  $self->{cpus} = $cpus;
 }
 
 =item memory($memory_size)
@@ -162,8 +162,8 @@ Sets the memory of a VM in megabyte.
 
 =cut
 sub memory {
-   my ($self, $mem) = @_;
-   $self->{memory} = $mem;
+  my ($self, $mem) = @_;
+  $self->{memory} = $mem;
 }
 
 =item network(%option)
@@ -173,22 +173,22 @@ Configure the network for a VM.
 Currently it supports 2 modes. I<nat> and I<bridged>. Currently it supports only one network card.
 
  $box->network(
-    1 => {
-       type => "nat",
-    },
+   1 => {
+     type => "nat",
+   },
  }
-    
+   
  $box->network(
-    1 => {
-       type => "bridged",
-       bridge => "eth0",
-    },
+   1 => {
+     type => "bridged",
+     bridge => "eth0",
+   },
  );
 
 =cut
 sub network {
-   my ($self, %option) = @_;
-   $self->{__network} = \%option;
+  my ($self, %option) = @_;
+  $self->{__network} = \%option;
 }
 
 =item url($url)
@@ -197,9 +197,9 @@ The URL where to download the Base VM Image. You can use self-made images or pre
 
 =cut
 sub url {
-   my ($self, $url, $force) = @_;
-   $self->{url} = $url;
-   $self->{force} = $force;
+  my ($self, $url, $force) = @_;
+  $self->{url} = $url;
+  $self->{force} = $force;
 }
 
 =item auth(%option)
@@ -207,122 +207,122 @@ sub url {
 Configure the authentication to the VM.
 
  $box->auth(
-    user => $user,
-    password => $password,
-    private_key => $private_key,
-    public_key => $public_key,
+   user => $user,
+   password => $password,
+   private_key => $private_key,
+   public_key => $public_key,
  );
 
 =cut
 sub auth {
-   my ($self, %auth) = @_;
-   $self->{__auth} = \%auth;
+  my ($self, %auth) = @_;
+  $self->{__auth} = \%auth;
 }
 
 sub wait_for_ssh {
-   my ($self, $ip, $port) = @_;
-
-   if(! $ip) {
-      ($ip, $port) = split(/:/, $self->ip);
-      $port ||= 22;
-   }
-
-   print "Waiting for SSH to come up on $ip:$port.";
-   while( ! is_port_open ($ip, $port) ) {
-      print ".";
-      sleep 1;
-   }
-
-   my $i=5;
-   while($i != 0) {
-      sleep 1;
-      print ".";
-      $i--;
-   }
-
-   print "\n";
+  my ($self, $ip, $port) = @_;
+
+  if(! $ip) {
+    ($ip, $port) = split(/:/, $self->ip);
+    $port ||= 22;
+  }
+
+  print "Waiting for SSH to come up on $ip:$port.";
+  while( ! is_port_open ($ip, $port) ) {
+    print ".";
+    sleep 1;
+  }
+
+  my $i=5;
+  while($i != 0) {
+    sleep 1;
+    print ".";
+    $i--;
+  }
+
+  print "\n";
 }
 
 sub _download {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $filename = basename($self->{url});
-   my $force = $self->{force} || FALSE;
+  my $filename = basename($self->{url});
+  my $force = $self->{force} || FALSE;
 
-   if(is_file("./tmp/$filename")) {
-      Rex::Logger::info("File already downloaded. Please remove the file ./tmp/$filename if you want to download a fresh copy.");
-   }
-   else {
-      $force = TRUE;
-   }
+  if(is_file("./tmp/$filename")) {
+    Rex::Logger::info("File already downloaded. Please remove the file ./tmp/$filename if you want to download a fresh copy.");
+  }
+  else {
+    $force = TRUE;
+  }
 
-   if($force) {
-      Rex::Logger::info("Downloading $self->{url} to ./tmp/$filename");
-      mkdir "tmp";
-      if(Rex::is_local()) {
-         my $ua = LWP::UserAgent->new();
-         $ua->env_proxy;
-         my $final_data = "";
-         my $current_size = 0;
-         my $current_modulo = 0;
-         my $start_time = [gettimeofday()];
-         open(my $fh, ">", "./tmp/$filename") or die($!);
-         binmode $fh;
-         my $resp = $ua->get($self->{url}, ':content_cb' => sub {
-            my ($data, $response, $protocol) = @_;
+  if($force) {
+    Rex::Logger::info("Downloading $self->{url} to ./tmp/$filename");
+    mkdir "tmp";
+    if(Rex::is_local()) {
+      my $ua = LWP::UserAgent->new();
+      $ua->env_proxy;
+      my $final_data = "";
+      my $current_size = 0;
+      my $current_modulo = 0;
+      my $start_time = [gettimeofday()];
+      open(my $fh, ">", "./tmp/$filename") or die($!);
+      binmode $fh;
+      my $resp = $ua->get($self->{url}, ':content_cb' => sub {
+        my ($data, $response, $protocol) = @_;
 
-            $current_size += length($data);
+        $current_size += length($data);
 
-            my $content_length = $response->header("content-length");
+        my $content_length = $response->header("content-length");
 
-            print $fh $data;
+        print $fh $data;
 
-            my $current_time = [gettimeofday()];
-            my $time_diff = tv_interval($start_time, $current_time);
+        my $current_time = [gettimeofday()];
+        my $time_diff = tv_interval($start_time, $current_time);
 
-            my $bytes_per_seconds = $current_size / $time_diff;
+        my $bytes_per_seconds = $current_size / $time_diff;
 
-            my $mbytes_per_seconds = $bytes_per_seconds / 1024 / 1024;
+        my $mbytes_per_seconds = $bytes_per_seconds / 1024 / 1024;
 
-            my $mbytes_current = $current_size / 1024 / 1024;
-            my $mbytes_total = $content_length / 1024 / 1024;
+        my $mbytes_current = $current_size / 1024 / 1024;
+        my $mbytes_total = $content_length / 1024 / 1024;
 
-            my $left_bytes = $content_length - $current_size;
+        my $left_bytes = $content_length - $current_size;
 
-            my $time_one_byte  = $time_diff / $current_size;
-            my $time_all_bytes = $time_one_byte * ($content_length - $current_size);
+        my $time_one_byte  = $time_diff / $current_size;
+        my $time_all_bytes = $time_one_byte * ($content_length - $current_size);
 
-            if( (($current_size / (1024 * 1024)) % (1024 * 1024)) > $current_modulo ) {
-               print ".";
-               $current_modulo++;
+        if( (($current_size / (1024 * 1024)) % (1024 * 1024)) > $current_modulo ) {
+          print ".";
+          $current_modulo++;
 
-               if( $current_modulo % 10 == 0) {
-                  printf(". %.2f MBytes/s (%.2f MByte / %.2f MByte) %.2f secs left\n", $mbytes_per_seconds, $mbytes_current, $mbytes_total, $time_all_bytes);
-               }
+          if( $current_modulo % 10 == 0) {
+            printf(". %.2f MBytes/s (%.2f MByte / %.2f MByte) %.2f secs left\n", $mbytes_per_seconds, $mbytes_current, $mbytes_total, $time_all_bytes);
+          }
 
-            }
-
-         });
-         close($fh);
-
-         if($resp->is_success) {
-            print " done.\n";
-         }
-         else {
-            Rex::Logger::info("Error downloading box image.", "warn");
-            unlink "./tmp/$filename";
-         }
+        }
 
+      });
+      close($fh);
 
+      if($resp->is_success) {
+        print " done.\n";
       }
       else {
-         run "wget -c -qO ./tmp/$filename $self->{url}";
+        Rex::Logger::info("Error downloading box image.", "warn");
+        unlink "./tmp/$filename";
+      }
+
+
+    }
+    else {
+      run "wget -c -qO ./tmp/$filename $self->{url}";
 
-         if($? != 0) {
-            die("Downloading of $self->{url} failed. Please verify if wget is installed and if you have the right permissions to download this box.");
-         }
+      if($? != 0) {
+        die("Downloading of $self->{url} failed. Please verify if wget is installed and if you have the right permissions to download this box.");
       }
-   }
+    }
+  }
 }
 
 =back
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 =head1 NAME
 
 Rex::Box::VBox - Rex/Boxes VirtualBox Module
@@ -18,56 +18,56 @@ To use this module inside your Rexfile you can use the following commands.
 
  use Rex::Commands::Boxes;
  set box => "VBox";
-   
+  
  task "prepare_box", sub {
-    box {
-       my ($box) = @_;
-          
-       $box->name("mybox");
-       $box->url("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova");
-          
-       $box->network(1 => {
-          type => "nat",
-       });
-          
-       $box->network(1 => {
-          type => "bridged",
-          bridge => "eth0",
-       });
-           
-       $box->forward_port(ssh => [2222, 22]);
-          
-       $box->share_folder(myhome => "/home/myuser");
-           
-       $box->auth(
-          user => "root",
-          password => "box",
-       );
-           
-       $box->setup("setup_task");
-    };
+   box {
+     my ($box) = @_;
+       
+     $box->name("mybox");
+     $box->url("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova");
+       
+     $box->network(1 => {
+       type => "nat",
+     });
+       
+     $box->network(1 => {
+       type => "bridged",
+       bridge => "eth0",
+     });
+        
+     $box->forward_port(ssh => [2222, 22]);
+       
+     $box->share_folder(myhome => "/home/myuser");
+        
+     $box->auth(
+       user => "root",
+       password => "box",
+     );
+        
+     $box->setup("setup_task");
+   };
  };
 
 If you want to use a YAML file you can use the following template.
 
  type: VBox
  vms:
-    vmone:
-       url: http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova
-       forward_port:
-          ssh:
-             - 2222
-             - 22
-       share_folder:
-          myhome: /home/myhome
-       setup: setup_task
+   vmone:
+     url: http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova
+     forward_port:
+       ssh:
+         - 2222
+         - 22
+     share_folder:
+       myhome: /home/myhome
+     setup: setup_task
 
 And then you can use it the following way in your Rexfile.
 
  use Rex::Commands::Box init_file => "file.yml";
-    
+   
  task "prepare_vms", sub {
-    boxes "init";
+   boxes "init";
  };
 
 =head1 HEADLESS MODE
@@ -117,158 +117,158 @@ Constructor if used in OO mode.
 =cut
 
 sub new {
-   my $class = shift;
-   my $proto = ref($class) || $class;
-   my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, ref($class) || $class);
+  bless($self, ref($class) || $class);
 
-   if(exists $self->{options} && exists $self->{options}->{headless} && $self->{options}->{headless}) {
-      set virtualization => { type => "VBox", headless => TRUE };
-   }
+  if(exists $self->{options} && exists $self->{options}->{headless} && $self->{options}->{headless}) {
+    set virtualization => { type => "VBox", headless => TRUE };
+  }
 
-   return $self;
+  return $self;
 }
 
 sub import_vm {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   # check if machine already exists
-   my $vms = vm list => "all";
+  # check if machine already exists
+  my $vms = vm list => "all";
 
-   my $vm_exists = 0;
-   for my $vm (@{ $vms }) {
-      if($vm->{name} eq $self->{name}) {
-         Rex::Logger::debug("VM already exists. Don't import anything.");
-         $vm_exists = 1;
-      }
-   }
-
-   if(! $vm_exists) {
-      # if not, create it
-      $self->_download;
+  my $vm_exists = 0;
+  for my $vm (@{ $vms }) {
+    if($vm->{name} eq $self->{name}) {
+      Rex::Logger::debug("VM already exists. Don't import anything.");
+      $vm_exists = 1;
+    }
+  }
 
-      my $filename = basename($self->{url});
+  if(! $vm_exists) {
+    # if not, create it
+    $self->_download;
 
-      Rex::Logger::info("Importing VM ./tmp/$filename");
-      vm import => $self->{name}, file => "./tmp/$filename", %{ $self };
+    my $filename = basename($self->{url});
 
-      #unlink "./tmp/$filename";
-   }
+    Rex::Logger::info("Importing VM ./tmp/$filename");
+    vm import => $self->{name}, file => "./tmp/$filename", %{ $self };
 
-   my $vminfo = vm info => $self->{name};
+    #unlink "./tmp/$filename";
+  }
 
-   # check if networksettings should be set
-   if(exists $self->{__network} && $vminfo->{VMState} ne "running") {
-      my $option = $self->{__network};
-      for my $nic_no (keys %{ $option }) {
+  my $vminfo = vm info => $self->{name};
 
-         if($option->{$nic_no}->{type}) {
-            Rex::Logger::debug("Setting network type (dev: $nic_no) to: " . $option->{$nic_no}->{type});
-            vm option => $self->{name},
-                  "nic$nic_no" => $option->{$nic_no}->{type};
+  # check if networksettings should be set
+  if(exists $self->{__network} && $vminfo->{VMState} ne "running") {
+    my $option = $self->{__network};
+    for my $nic_no (keys %{ $option }) {
 
-            if($option->{$nic_no}->{type} eq "bridged") {
+      if($option->{$nic_no}->{type}) {
+        Rex::Logger::debug("Setting network type (dev: $nic_no) to: " . $option->{$nic_no}->{type});
+        vm option => $self->{name},
+            "nic$nic_no" => $option->{$nic_no}->{type};
 
-               $option->{$nic_no}->{bridge} = select_bridge()
-                  if(!$option->{$nic_no}->{bridge});
+        if($option->{$nic_no}->{type} eq "bridged") {
 
-               Rex::Logger::debug("Setting network bridge (dev: $nic_no) to: " . ($option->{$nic_no}->{bridge} || "eth0"));
-               vm option => $self->{name},
-                  "bridgeadapter$nic_no" => ($option->{$nic_no}->{bridge} || "eth0");
-            }
-         }
+          $option->{$nic_no}->{bridge} = select_bridge()
+            if(!$option->{$nic_no}->{bridge});
 
-         if($option->{$nic_no}->{driver}) {
-            Rex::Logger::debug("Setting network driver (dev: $nic_no) to: " . $option->{$nic_no}->{driver});
-            vm option => $self->{name},
-                  "nictype$nic_no" => $option->{$nic_no}->{driver};
-         }
+          Rex::Logger::debug("Setting network bridge (dev: $nic_no) to: " . ($option->{$nic_no}->{bridge} || "eth0"));
+          vm option => $self->{name},
+            "bridgeadapter$nic_no" => ($option->{$nic_no}->{bridge} || "eth0");
+        }
+      }
 
+      if($option->{$nic_no}->{driver}) {
+        Rex::Logger::debug("Setting network driver (dev: $nic_no) to: " . $option->{$nic_no}->{driver});
+        vm option => $self->{name},
+            "nictype$nic_no" => $option->{$nic_no}->{driver};
       }
-   }
-   if(exists $self->{__forward_port} && $vminfo->{VMState} ne "running") {
-      # remove all forwards
-      vm forward_port => $self->{name}, delete => -all;
 
-      # add forwards
-      vm forward_port => $self->{name}, add => $self->{__forward_port};
-   }
+    }
+  }
+  if(exists $self->{__forward_port} && $vminfo->{VMState} ne "running") {
+    # remove all forwards
+    vm forward_port => $self->{name}, delete => -all;
 
-   # shared folder
-   if(exists $self->{__shared_folder} && $vminfo->{VMState} ne "running") {
-      vm share_folder => $self->{name}, add => $self->{__shared_folder};
-   }
+    # add forwards
+    vm forward_port => $self->{name}, add => $self->{__forward_port};
+  }
 
-   if($vminfo->{VMState} ne "running") {
-      $self->start;
-   }
+  # shared folder
+  if(exists $self->{__shared_folder} && $vminfo->{VMState} ne "running") {
+    vm share_folder => $self->{name}, add => $self->{__shared_folder};
+  }
 
-   $self->{info} = vm guestinfo => $self->{name};
+  if($vminfo->{VMState} ne "running") {
+    $self->start;
+  }
+
+  $self->{info} = vm guestinfo => $self->{name};
 }
 
 
 
 sub provision_vm {
-   my ($self, @tasks) = @_;
+  my ($self, @tasks) = @_;
 
-   if(! @tasks) {
-      @tasks = @{ $self->{__tasks} };
-   }
+  if(! @tasks) {
+    @tasks = @{ $self->{__tasks} };
+  }
 
-   my $server = $self->ip;
+  my $server = $self->ip;
 
-   my ($ip, $port) = split(/:/, $server);
-   $port ||= 22;
+  my ($ip, $port) = split(/:/, $server);
+  $port ||= 22;
 
-   print "Waiting for SSH to come up on $ip:$port.";
-   while( ! is_port_open ($ip, $port) ) {
-      print ".";
-      sleep 1;
-   }
+  print "Waiting for SSH to come up on $ip:$port.";
+  while( ! is_port_open ($ip, $port) ) {
+    print ".";
+    sleep 1;
+  }
 
-   my $i=5;
-   while($i != 0) {
-      sleep 1;
-      print ".";
-      $i--;
-   }
+  my $i=5;
+  while($i != 0) {
+    sleep 1;
+    print ".";
+    $i--;
+  }
 
-   print "\n";
+  print "\n";
 
-   for my $task (@tasks) {
-      Rex::TaskList->create()->get_task($task)->set_auth(%{ $self->{__auth} });
-      Rex::TaskList->create()->get_task($task)->run($server);
-   }
+  for my $task (@tasks) {
+    Rex::TaskList->create()->get_task($task)->set_auth(%{ $self->{__auth} });
+    Rex::TaskList->create()->get_task($task)->run($server);
+  }
 }
 
 sub select_bridge {
-   my $bridges = vm "bridge";
-
-   my $ifname;
-   if (@$bridges == 1) {
-      Rex::Logger::debug("Only one bridged interface available. Using it by default.");
-      $ifname = $bridges->[0]->{name};
-   }
-   elsif (@$bridges > 1) {
-      for (my $i = 0; $i < @$bridges; $i++) {
-         my $bridge = $bridges->[$i];
-         next if ($bridge->{status} =~ /^down$/i);
-         local $Rex::Logger::format = "%s";
-         Rex::Logger::info($i + 1 . " $bridge->{name}");
-      }
-
-      my $choice;
-      do {
-         print "What interface should network bridge to? ";
-         chomp($choice = <STDIN>);
-         $choice = int($choice);
-      } while(!$choice);
-
-      $ifname = $bridges->[$choice - 1]->{name};
-   }
-
-   return $ifname;
+  my $bridges = vm "bridge";
+
+  my $ifname;
+  if (@$bridges == 1) {
+    Rex::Logger::debug("Only one bridged interface available. Using it by default.");
+    $ifname = $bridges->[0]->{name};
+  }
+  elsif (@$bridges > 1) {
+    for (my $i = 0; $i < @$bridges; $i++) {
+      my $bridge = $bridges->[$i];
+      next if ($bridge->{status} =~ /^down$/i);
+      local $Rex::Logger::format = "%s";
+      Rex::Logger::info($i + 1 . " $bridge->{name}");
+    }
+
+    my $choice;
+    do {
+      print "What interface should network bridge to? ";
+      chomp($choice = <STDIN>);
+      $choice = int($choice);
+    } while(!$choice);
+
+    $ifname = $bridges->[$choice - 1]->{name};
+  }
+
+  return $ifname;
 }
 
 =item forward_port(%option)
@@ -276,15 +276,15 @@ sub select_bridge {
 Set ports to be forwarded to the VM. This only work with VirtualBox in NAT network mode.
 
  $box->forward_port(
-    name => [$from_host_port, $to_vm_port],
-    name2 => [$from_host_port_2, $to_vm_port_2],
-    ...
+   name => [$from_host_port, $to_vm_port],
+   name2 => [$from_host_port_2, $to_vm_port_2],
+   ...
  );
 
 =cut
 sub forward_port {
-   my ($self, %option) = @_;
-   $self->{__forward_port} = \%option;
+  my ($self, %option) = @_;
+  $self->{__forward_port} = \%option;
 }
 
 =item share_folder(%option)
@@ -292,22 +292,22 @@ sub forward_port {
 Creates a shared folder inside the VM with the content from a folder from the Host machine. This only works with VirtualBox.
 
  $box->share_folder(
-    name => "/path/on/host",
-    name2 => "/path_2/on/host",
+   name => "/path/on/host",
+   name2 => "/path_2/on/host",
  );
 
 =cut
 sub share_folder {
-   my ($self, %option) = @_;
-   $self->{__shared_folder} = \%option;
+  my ($self, %option) = @_;
+  $self->{__shared_folder} = \%option;
 }
 
 sub list_boxes {
-   my ($self) = @_;
-   
-   my $vms = vm list => "all";
+  my ($self) = @_;
+  
+  my $vms = vm list => "all";
 
-   return @{ $vms };
+  return @{ $vms };
 }
 
 =item info
@@ -316,22 +316,22 @@ Returns a hashRef of vm information.
 
 =cut
 sub info {
-   my ($self) = @_;
-   $self->ip;
+  my ($self) = @_;
+  $self->ip;
 
-   my $vm_info = vm info => $self->{name};
+  my $vm_info = vm info => $self->{name};
 
-   # get forwarded ports
-   my @forwarded_ports = grep { m/^Forwarding/ } keys %{ $vm_info };
+  # get forwarded ports
+  my @forwarded_ports = grep { m/^Forwarding/ } keys %{ $vm_info };
 
-   my %forward_port;
-   for my $fwp (@forwarded_ports) {
-      my ($name, $proto, $host_ip, $host_port, $vm_ip, $vm_port) = split(/,/, $vm_info->{$fwp});
-      $forward_port{$name} = [$host_port, $vm_port];
-   }
-   $self->forward_port(%forward_port);
+  my %forward_port;
+  for my $fwp (@forwarded_ports) {
+    my ($name, $proto, $host_ip, $host_port, $vm_ip, $vm_port) = split(/,/, $vm_info->{$fwp});
+    $forward_port{$name} = [$host_port, $vm_port];
+  }
+  $self->forward_port(%forward_port);
 
-   return $self->{info};
+  return $self->{info};
 }
 
 =item ip
@@ -341,21 +341,21 @@ This method return the ip of a vm on which the ssh daemon is listening.
 =cut
 
 sub ip {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   $self->{info} = vm guestinfo => $self->{name};
+  $self->{info} = vm guestinfo => $self->{name};
 
-   my $server = $self->{info}->{net}->[0]->{ip};
-   if($self->{__forward_port} && $self->{__forward_port}->{ssh} && ! Rex::is_local()) {
-      $server = connection->server . ":" . $self->{__forward_port}->{ssh}->[0];
-   }
-   elsif($self->{__forward_port} && $self->{__forward_port}->{ssh} && Rex::is_local()) {
-      $server = "127.0.0.1:" . $self->{__forward_port}->{ssh}->[0];
-   }
+  my $server = $self->{info}->{net}->[0]->{ip};
+  if($self->{__forward_port} && $self->{__forward_port}->{ssh} && ! Rex::is_local()) {
+    $server = connection->server . ":" . $self->{__forward_port}->{ssh}->[0];
+  }
+  elsif($self->{__forward_port} && $self->{__forward_port}->{ssh} && Rex::is_local()) {
+    $server = "127.0.0.1:" . $self->{__forward_port}->{ssh}->[0];
+  }
 
-   $self->{info}->{ip} = $server;
+  $self->{info}->{ip} = $server;
 
-   return $server;
+  return $server;
 }
 
 =back
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Box;
-   
+  
 use strict;
 use warnings;
 
@@ -15,32 +15,32 @@ use Rex::Logger;
 my %BOX_PROVIDER;
 
 sub register_box_provider {
-   my ($class, $service_name, $service_class) = @_;
-   $BOX_PROVIDER{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $BOX_PROVIDER{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub create {
-   my ($class, @opts) = @_;
+  my ($class, @opts) = @_;
 
-   my $type = Rex::Config->get("box_type") || "VBox";
-   my $options = Rex::Config->get("box_options") || {};
+  my $type = Rex::Config->get("box_type") || "VBox";
+  my $options = Rex::Config->get("box_options") || {};
 
-   my $klass = "Rex::Box::${type}";
+  my $klass = "Rex::Box::${type}";
 
-   if(exists $BOX_PROVIDER{$type}) {
-      $klass = $BOX_PROVIDER{$type};
-   }
+  if(exists $BOX_PROVIDER{$type}) {
+    $klass = $BOX_PROVIDER{$type};
+  }
 
-   Rex::Logger::debug("Using $klass as box provider");
-   eval "use $klass;";
+  Rex::Logger::debug("Using $klass as box provider");
+  eval "use $klass;";
 
-   if($@) {
-      Rex::Logger::info("Box Class $klass not found.");
-      die("Box Class $klass not found.");
-   }
+  if($@) {
+    Rex::Logger::info("Box Class $klass not found.");
+    die("Box Class $klass not found.");
+  }
 
-   return $klass->new(@opts, options => $options); 
+  return $klass->new(@opts, options => $options); 
 }
 
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::CLI;
-   
+
 use strict;
 use warnings;
 
@@ -26,11 +26,11 @@ use Data::Dumper;
 
 my $no_color = 0;
 eval "use Term::ANSIColor";
-if($@) { $no_color = 1; }
+if ($@) { $no_color = 1; }
 
 # no colors under windows
-if($^O =~ m/MSWin/) {
-   $no_color = 1;
+if ( $^O =~ m/MSWin/ ) {
+  $no_color = 1;
 }
 
 # preload some modules
@@ -38,567 +38,600 @@ use Rex -base;
 
 $|++;
 
-my (%opts, @help, @exit);
+my ( %opts, @help, @exit );
 
-if($#ARGV < 0) {
-   @ARGV = qw(-h);
+if ( $#ARGV < 0 ) {
+  @ARGV = qw(-h);
 }
 
 require Rex::Args;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub __run__ {
 
-   my ($self, %more_args) = @_;
-
-   Rex::Args->import(
-      C => {},
-      c => {},
-      q => {},
-      Q => {},
-      F => {},
-      T => {},
-      h => {},
-      v => {},
-      d => {},
-      s => {},
-      m => {},
-      w => {},
-      S => { type => "string" },
-      E => { type => "string" },
-      o => { type => "string" },
-      f => { type => "string" },
-      M => { type => "string" },
-      b => { type => "string" },
-      e => { type => "string" },
-      H => { type => "string" },
-      u => { type => "string" },
-      p => { type => "string" },
-      P => { type => "string" },
-      K => { type => "string" },
-      G => { type => "string" },
-      z => { type => "string" },
-      t => { type => "integer" },
-      %more_args,
-   );
-
-   %opts = Rex::Args->getopts;
-
-   if($opts{'Q'}) {
-      my ($stdout, $stderr);
-      open(my $newout, '>', \$stdout);
-      select $newout;
-      close(STDERR);
-   }
-
-   if($opts{'m'}) {
-      $no_color = 1;
-      $Rex::Logger::no_color = 1;
-   }
-
-   if($opts{'d'}) {
-      $Rex::Logger::debug = $opts{'d'};
-      $Rex::Logger::silent = 0;
-   }
-
-   if($opts{"c"}) {
-      Rex::Config->set_use_cache(1);
-   }
-   elsif($opts{"C"}) {
-      Rex::Config->set_use_cache(0);
-   }
-
-   Rex::Logger::debug("Command Line Parameters");
-   for my $param (keys %opts) {
-      Rex::Logger::debug("\t$param = " . $opts{$param});
-   }
-
-   if($opts{'h'}) {
-      $self->__help__;
-   } elsif($opts{'v'} && ! $opts{'T'}) {
-      $self->__version__;
-   }
-
-   if($opts{'q'}) {
-      $::QUIET = 1;
-      if($opts{'w'}) {
-         $::QUIET = 2;
-      }
-   }
-
-   $::rexfile = "Rexfile";
-   if($opts{'f'}) {
-      Rex::Logger::debug("Using Rexfile: " . $opts{'f'});
-      $::rexfile = $opts{'f'};
-   } else {
-      if ((! -e $::rexfile) && ($ARGV[0] && $ARGV[0] =~ /:/)) {
-         #if there is no Rexfile, and the user asks for a longer path task, see if we can use it as the Rexfile
-         #eg: rex -H $host Misc:Example:prepare --bar=baz
-         $::rexfile = $ARGV[0];
-         $::rexfile =~ s/:[^:]*$//;
-         $::rexfile =~ s{:}{/}g;
-         $::rexfile = 'Rex/'.$::rexfile.'.pm';
-      }
-   }
-
-   FORCE_SERVER: {
-
-      if($opts{'H'}) {
-         if($opts{'H'} =~ m/^perl:(.*)/) {
-            my $host_eval = eval( $1 );
-
-            if(ref($host_eval) eq "ARRAY") {
-               $::FORCE_SERVER = join(" ", @{$host_eval});
-            }
-            else {
-               die("Perl Code have to return an array reference.");
-            }
-         }
-         else {
-            $::FORCE_SERVER = $opts{'H'};
-         }
-      }
-
-   }
-
-   if ($opts{'z'}) {
-      my $host_eval = eval {
-         `$opts{'z'}`;
-      };
-      if ($host_eval =~ m/\S/xms) {
-         $::FORCE_SERVER = join(" ", split /\n|,|;/, $host_eval);
+  my ( $self, %more_args ) = @_;
+
+  Rex::Args->import(
+    C => {},
+    c => {},
+    q => {},
+    Q => {},
+    F => {},
+    T => {},
+    h => {},
+    v => {},
+    d => {},
+    s => {},
+    m => {},
+    w => {},
+    S => { type => "string" },
+    E => { type => "string" },
+    o => { type => "string" },
+    f => { type => "string" },
+    M => { type => "string" },
+    b => { type => "string" },
+    e => { type => "string" },
+    H => { type => "string" },
+    u => { type => "string" },
+    p => { type => "string" },
+    P => { type => "string" },
+    K => { type => "string" },
+    G => { type => "string" },
+    g => { type => "string" },
+    z => { type => "string" },
+    t => { type => "integer" },
+    %more_args,
+  );
+
+  %opts = Rex::Args->getopts;
+
+  if ( $opts{'Q'} ) {
+    my ( $stdout, $stderr );
+    open( my $newout, '>', \$stdout );
+    select $newout;
+    close(STDERR);
+  }
+
+  if ( $opts{'m'} ) {
+    $no_color              = 1;
+    $Rex::Logger::no_color = 1;
+  }
+
+  if ( $opts{'d'} ) {
+    $Rex::Logger::debug  = $opts{'d'};
+    $Rex::Logger::silent = 0;
+  }
+
+  if ( $opts{"c"} ) {
+    Rex::Config->set_use_cache(1);
+  }
+  elsif ( $opts{"C"} ) {
+    Rex::Config->set_use_cache(0);
+  }
+
+  Rex::Logger::debug("Command Line Parameters");
+  for my $param ( keys %opts ) {
+    Rex::Logger::debug( "\t$param = " . $opts{$param} );
+  }
+
+  if ( $opts{'h'} ) {
+    $self->__help__;
+  }
+  elsif ( $opts{'v'} && !$opts{'T'} ) {
+    $self->__version__;
+  }
+
+  if ( $opts{'q'} ) {
+    $::QUIET = 1;
+    if ( $opts{'w'} ) {
+      $::QUIET = 2;
+    }
+  }
+
+  $::rexfile = "Rexfile";
+  if ( $opts{'f'} ) {
+    Rex::Logger::debug( "Using Rexfile: " . $opts{'f'} );
+    $::rexfile = $opts{'f'};
+  }
+  else {
+    if ( ( !-e $::rexfile ) && ( $ARGV[0] && $ARGV[0] =~ /:/ ) ) {
+
+#if there is no Rexfile, and the user asks for a longer path task, see if we can use it as the Rexfile
+#eg: rex -H $host Misc:Example:prepare --bar=baz
+      $::rexfile = $ARGV[0];
+      $::rexfile =~ s/:[^:]*$//;
+      $::rexfile =~ s{:}{/}g;
+      $::rexfile = 'Rex/' . $::rexfile . '.pm';
+    }
+  }
+
+FORCE_SERVER: {
+
+    if ( $opts{'H'} ) {
+      if ( $opts{'H'} =~ m/^perl:(.*)/ ) {
+        my $host_eval = eval($1);
+
+        if ( ref($host_eval) eq "ARRAY" ) {
+          $::FORCE_SERVER = join( " ", @{$host_eval} );
+        }
+        else {
+          die("Perl Code have to return an array reference.");
+        }
       }
       else {
-         Rex::Logger::info("you must give a valid command.");
-      }
-   }
-
-   if($opts{'o'}) {
-      Rex::Output->get($opts{'o'});
-   }
-
-   # Load Rexfile before exec in order to suppport group exec
-   if(-f $::rexfile) {
-      Rex::Logger::debug("$::rexfile exists");
-
-      Rex::Logger::debug("Checking Rexfile Syntax...");
-      
-      my $out = qx{$^X -MRex::Commands -MRex::Commands::Run -MRex::Commands::Fs -MRex::Commands::Download -MRex::Commands::Upload -MRex::Commands::File -MRex::Commands::Gather -MRex::Commands::Kernel -MRex::Commands::Pkg -MRex::Commands::Service -MRex::Commands::Sysctl -MRex::Commands::Tail -MRex::Commands::Process -c $::rexfile 2>&1};
-      if($? > 0) {
-         print $out;
-      }
-
-      if($? != 0) {
-         exit 1;
-      }
+        $::FORCE_SERVER = $opts{'H'};
+      }
+    }
+
+  }
+
+  if ( $opts{'z'} ) {
+    my $host_eval = eval { `$opts{'z'}`; };
+    if ( $host_eval =~ m/\S/xms ) {
+      $::FORCE_SERVER = join( " ", split /\n|,|;/, $host_eval );
+    }
+    else {
+      $::FORCE_SERVER = $opts{'H'};
+    }
+  }
+
+  if ( $opts{'z'} ) {
+    my $host_eval = eval { `$opts{'z'}`; };
+    if ( $host_eval =~ m/\S/xms ) {
+      $::FORCE_SERVER = join( " ", split /\n|,|;/, $host_eval );
+    }
+    else {
+      Rex::Logger::info("you must give a valid command.");
+    }
+  }
+
+  if ( $opts{'o'} ) {
+    Rex::Output->get( $opts{'o'} );
+  }
+
+  # Load Rexfile before exec in order to suppport group exec
+  if ( -f $::rexfile ) {
+    Rex::Logger::debug("$::rexfile exists");
+
+    Rex::Logger::debug("Checking Rexfile Syntax...");
+
+    my $out =
+      qx{$^X -MRex::Commands -MRex::Commands::Run -MRex::Commands::Fs -MRex::Commands::Download -MRex::Commands::Upload -MRex::Commands::File -MRex::Commands::Gather -MRex::Commands::Kernel -MRex::Commands::Pkg -MRex::Commands::Service -MRex::Commands::Sysctl -MRex::Commands::Tail -MRex::Commands::Process -c $::rexfile 2>&1};
+    if ( $? > 0 ) {
+      print $out;
+    }
+
+    if ( $? != 0 ) {
+      exit 1;
+    }
+
+    if ( $^O !~ m/^MSWin/ ) {
+      if ( -f "$::rexfile.lock" && !exists $opts{'F'} ) {
+        Rex::Logger::debug("Found $::rexfile.lock");
+        my $pid = eval { local ( @ARGV, $/ ) = ("$::rexfile.lock"); <>; };
+        system(
+          "ps aux | awk -F' ' ' { print \$2 } ' | grep $pid >/dev/null 2>&1");
+        if ( $? == 0 ) {
+          Rex::Logger::info("Rexfile is in use by $pid.");
+          CORE::exit 1;
+        }
+        else {
+          Rex::Logger::debug("Found stale lock file. Removing it.");
+          Rex::global_sudo(0);
+          CORE::unlink("$::rexfile.lock");
+        }
+      }
+
+      Rex::Logger::debug("Creating lock-file ($::rexfile.lock)");
+      open( my $f, ">$::rexfile.lock" ) or die($!);
+      print $f $$;
+      close($f);
+    }
+    else {
+      Rex::Logger::debug("Running on windows. Disabled syntax checking.");
+      Rex::Logger::debug("Running on windows. Disabled lock file support.");
+    }
+
+    Rex::Logger::debug("Including/Parsing $::rexfile");
+
+    Rex::Config->set_environment( $opts{"E"} ) if ( $opts{"E"} );
+
+    # turn sudo on with cli option s is used
+    if ( exists $opts{'s'} ) {
+      sudo("on");
+    }
+    if ( exists $opts{'S'} ) {
+      sudo_password( $opts{'S'} );
+    }
+
+    if ( exists $opts{'t'} ) {
+      parallelism( $opts{'t'} );
+    }
+
+    if ( $opts{'G'} ) {
+      $::FORCE_SERVER = "\0" . $opts{'G'};
+    }
+
+    if ( $opts{'g'} ) {
+      $::FORCE_SERVER = "\0" . $opts{'g'};
+    }
+
+    if ( -f "vars.db" ) {
+      CORE::unlink("vars.db");
+    }
 
-      if($^O !~ m/^MSWin/) {
-         if(-f "$::rexfile.lock" && ! exists $opts{'F'}) {
-            Rex::Logger::debug("Found $::rexfile.lock");
-            my $pid = eval { local(@ARGV, $/) = ("$::rexfile.lock"); <>; };
-            system("ps aux | awk -F' ' ' { print \$2 } ' | grep $pid >/dev/null 2>&1");
-            if($? == 0) {
-               Rex::Logger::info("Rexfile is in use by $pid.");
-               CORE::exit 1;
-            } else
-            {
-               Rex::Logger::debug("Found stale lock file. Removing it.");
-               Rex::global_sudo(0);
-               CORE::unlink("$::rexfile.lock");
+    if ( -f "vars.db.lock" ) {
+      CORE::unlink("vars.db.lock");
+    }
+
+    eval {
+      my $ok = do($::rexfile);
+      Rex::Logger::debug("eval your Rexfile.");
+      if ( !$ok ) {
+        Rex::Logger::info(
+          "There seems to be an error on some of your required files. $@",
+          "error" );
+        my @dir = ( dirname($::rexfile) );
+        for my $d (@dir) {
+          opendir( my $dh, $d ) or die($!);
+          while ( my $entry = readdir($dh) ) {
+            if ( $entry =~ m/^\./ ) {
+              next;
             }
-         }
-         
-         Rex::Logger::debug("Creating lock-file ($::rexfile.lock)");
-         open(my $f, ">$::rexfile.lock") or die($!);
-         print $f $$; 
-         close($f);
-      }
-      else {
-         Rex::Logger::debug("Running on windows. Disabled syntax checking.");
-         Rex::Logger::debug("Running on windows. Disabled lock file support.");
-      }
 
-      Rex::Logger::debug("Including/Parsing $::rexfile");
-
-      Rex::Config->set_environment($opts{"E"}) if($opts{"E"});
-
-      # turn sudo on with cli option s is used
-      if(exists $opts{'s'}) {
-         sudo("on");
-      }
-      if(exists $opts{'S'}) {
-         sudo_password($opts{'S'});
-      }
-
-      if(exists $opts{'t'}) {
-         parallelism($opts{'t'});
-      }
-
-      if($opts{'G'}) {
-         $::FORCE_SERVER = "\0" . $opts{'G'};
-      }
-
-      if(-f "vars.db") {
-         CORE::unlink("vars.db");
-      }
-
-      if(-f "vars.db.lock") {
-         CORE::unlink("vars.db.lock");
-      }
-
-      eval {
-         my $ok = do($::rexfile);
-         Rex::Logger::debug("eval your Rexfile.");
-         if(! $ok) {
-            Rex::Logger::info("There seems to be an error on some of your required files. $@", "error");
-            my @dir = (dirname($::rexfile));
-            for my $d (@dir) {
-               opendir(my $dh, $d) or die($!);
-               while(my $entry = readdir($dh)) {
-                  if($entry =~ m/^\./) {
-                     next;
-                  }
-
-                  if(-d "$d/$entry") {
-                     push(@dir, "$d/$entry");
-                     next;
-                  }
-
-                  if($entry =~ m/Rexfile/ || $entry =~ m/\.pm$/) {
-                     # check files for syntax errors
-                     my $check_out = qx{$^X -MRex::Commands -MRex::Commands::Run -MRex::Commands::Fs -MRex::Commands::Download -MRex::Commands::Upload -MRex::Commands::File -MRex::Commands::Gather -MRex::Commands::Kernel -MRex::Commands::Pkg -MRex::Commands::Service -MRex::Commands::Sysctl -MRex::Commands::Tail -MRex::Commands::Process -c $d/$entry 2>&1};
-                     if($? > 0) {
-                        print "$d/$entry\n";
-                        print "--------------------------------------------------------------------------------\n";
-                        print $check_out;
-                        print "\n";
-                     }
-                  }
-               }
-               closedir($dh);
+            if ( -d "$d/$entry" ) {
+              push( @dir, "$d/$entry" );
+              next;
             }
 
-            exit 1;
-         }
-      };
-
-      if($@) { print $@ . "\n"; exit 1; }
-
-   }
-   else {
-      Rex::Logger::info("No Rexfile found.", "warn");
-      Rex::Logger::info("Please create a file named 'Rexfile' inside this directory,", "warn");
-      Rex::Logger::info("or specify the file you want to use with:", "warn");
-      Rex::Logger::info("    rex -f file_to_use task_to_run", "warn");
-   }
-
-   if($opts{'e'}) {
-      Rex::Logger::debug("Executing command line code");
-      Rex::Logger::debug("\t" . $opts{'e'});
-
-      # execute the given code
-      my $code = "sub { \n";
-      $code   .= $opts{'e'} . "\n";
-      $code   .= "}";
-
-      $code = eval($code);
-
-      if($@) {
-         Rex::Logger::info("Error in eval line: $@\n", "warn");
-         exit 1;
-      }
-
-      if(exists $opts{'t'}) {
-         parallelism($opts{'t'});
-      }
-
-      my $pass_auth = 0;
-
-      if($opts{'u'}) {
-         Rex::Commands::user($opts{'u'});
-      }
-
-      if($opts{'p'}) {
-         Rex::Commands::password($opts{'p'});
-
-         unless($opts{'P'}) {
-            $pass_auth = 1;
-         }
-      }
-
-      if($opts{'P'}) {
-         Rex::Commands::private_key($opts{'P'});
-      }
-
-      if($opts{'K'}) {
-         Rex::Commands::public_key($opts{'K'});
-      }
-
-      if($pass_auth) {
-         pass_auth;
-      }
-
-      my @params = ();
-      if($opts{'H'}) {
-         push @params, split(/\s+/, $opts{'H'});
-      }
-      push @params, $code;
-      push @params, "eval-line-desc";
-      push @params, {};
-
-      Rex::TaskList->create()->create_task("eval-line", @params);
-      Rex::Commands::do_task("eval-line");
-      CORE::exit(0);
-   }
-   elsif($opts{'M'}) {
-      Rex::Logger::debug("Loading Rex-Module: " . $opts{'M'});
-      my $mod = $opts{'M'};
-      $mod =~ s{::}{/}g;
-      require "$mod.pm";
-   }
-
-   #### check if some parameters should be overwritten from the command line
-   CHECK_OVERWRITE: {
-
-      my $pass_auth = 0;
-
-      if($opts{'u'}) {
-         Rex::Commands::user($opts{'u'});
-         for my $task (Rex::TaskList->create()->get_tasks) {
-            Rex::TaskList->create()->get_task($task)->set_user($opts{'u'});
-         }
-      }
-
-      if($opts{'p'}) {
-         Rex::Commands::password($opts{'p'});
-
-         unless($opts{'P'}) {
-            $pass_auth = 1;
-         }
-
-         for my $task (Rex::TaskList->create()->get_tasks) {
-            Rex::TaskList->create()->get_task($task)->set_password($opts{'p'});
-         }
+            if ( $entry =~ m/Rexfile/ || $entry =~ m/\.pm$/ ) {
+
+              # check files for syntax errors
+              my $check_out =
+                qx{$^X -MRex::Commands -MRex::Commands::Run -MRex::Commands::Fs -MRex::Commands::Download -MRex::Commands::Upload -MRex::Commands::File -MRex::Commands::Gather -MRex::Commands::Kernel -MRex::Commands::Pkg -MRex::Commands::Service -MRex::Commands::Sysctl -MRex::Commands::Tail -MRex::Commands::Process -c $d/$entry 2>&1};
+              if ( $? > 0 ) {
+                print "$d/$entry\n";
+                print
+                  "--------------------------------------------------------------------------------\n";
+                print $check_out;
+                print "\n";
+              }
+            }
+          }
+          closedir($dh);
+        }
 
+        exit 1;
       }
+    };
 
-      if($opts{'P'}) {
-         Rex::Commands::private_key($opts{'P'});
+    if ($@) { print $@ . "\n"; exit 1; }
 
-         for my $task (Rex::TaskList->create()->get_tasks) {
-            $task->set_auth("private_key", $opts{'P'});
-            Rex::TaskList->create()->get_task($task)->set_auth("private_key", $opts{'P'});
-         }
-      }
+  }
+  else {
+    Rex::Logger::info( "No Rexfile found.", "warn" );
+    Rex::Logger::info(
+      "Please create a file named 'Rexfile' inside this directory,", "warn" );
+    Rex::Logger::info( "or specify the file you want to use with:", "warn" );
+    Rex::Logger::info( "   rex -f file_to_use task_to_run",         "warn" );
+  }
 
-      if($opts{'K'}) {
-         Rex::Commands::public_key($opts{'K'});
+  if ( $opts{'e'} ) {
+    Rex::Logger::debug("Executing command line code");
+    Rex::Logger::debug( "\t" . $opts{'e'} );
 
-         for my $task (Rex::TaskList->create()->get_tasks) {
-            Rex::TaskList->create()->get_task($task)->set_auth("public_key", $opts{'K'});
-         }
-      }
+    # execute the given code
+    my $code = "sub { \n";
+    $code .= $opts{'e'} . "\n";
+    $code .= "}";
 
-      if($pass_auth) {
-         pass_auth;
-      }
+    $code = eval($code);
 
-   }
+    if ($@) {
+      Rex::Logger::info( "Error in eval line: $@\n", "warn" );
+      exit 1;
+    }
 
+    if ( exists $opts{'t'} ) {
+      parallelism( $opts{'t'} );
+    }
 
-   Rex::Logger::debug("Initializing Logger from parameters found in $::rexfile");
+    my $pass_auth = 0;
 
-   if($opts{'T'} && $opts{'m'}) {
-      # create machine readable tasklist
-      my @tasks = Rex::TaskList->create()->get_tasks;
-      for my $task (@tasks) {
-         my $desc = Rex::TaskList->create()->get_desc($task);
-         $desc =~ s/'/\\'/gms;
-         print "'$task'" . " = '$desc'\n";
-      }
-   }
-   elsif($opts{'T'}) {
-      Rex::Logger::debug("Listing Tasks and Batches");
-      _print_color("Tasks\n", "yellow");
-      my @tasks = Rex::TaskList->create()->get_tasks;
-      unless(@tasks) {
-         print "   no tasks defined.\n";
-         exit;
-      }
-      if(defined $ARGV[0]) {
-        @tasks = map { Rex::TaskList->create()->is_task($_) ?  $_ : () } @ARGV;
-      }
-      for my $task (@tasks) {
-         printf "  %-30s %s\n", $task, Rex::TaskList->create()->get_desc($task);
-         if($opts{'v'}) {
-             _print_color("      Servers: " . join(", ", @{ Rex::TaskList->create()->get_task($task)->{'server'} }) . "\n");
-         }
-      }
-      _print_color("Batches\n", 'yellow') if(Rex::Batch->get_batchs);
-      for my $batch (Rex::Batch->get_batchs) {
-         printf "  %-30s %s\n", $batch, Rex::Batch->get_desc($batch);
-         if($opts{'v'}) {
-             _print_color("      " . join(" ", Rex::Batch->get_batch($batch)) . "\n");
-         }
-      }
-      _print_color("Environments\n", "yellow");
-      print "  " . join("\n  ", Rex::Commands->get_environments()) . "\n";
+    if ( $opts{'u'} ) {
+      Rex::Commands::user( $opts{'u'} );
+    }
 
-      my %groups = Rex::Group->get_groups;
-      _print_color("Server Groups\n", "yellow") if(keys %groups);
-      for my $group (keys %groups) {
-         printf "  %-30s %s\n", $group, join(", ", @{ $groups{$group} });
-      }
+    if ( $opts{'p'} ) {
+      Rex::Commands::password( $opts{'p'} );
 
-      Rex::global_sudo(0);
-      Rex::Logger::debug("Removing lockfile") if(! exists $opts{'F'});
-      CORE::unlink("$::rexfile.lock")               if(! exists $opts{'F'});
-      CORE::exit 0;
-   }
-
-   eval {
-      if($opts{'b'}) {
-         Rex::Logger::debug("Running batch: " . $opts{'b'});
-         my $batch = $opts{'b'};
-         if(Rex::Batch->is_batch($batch)) {
-            Rex::Batch->run($batch);
-         }
+      unless ( $opts{'P'} ) {
+        $pass_auth = 1;
       }
+    }
 
-      if(defined $ARGV[0]) {
-         for my $task (@ARGV) {
-            if(Rex::TaskList->create()->is_task($task)) {
-               Rex::Logger::debug("Running task: $task");
-               Rex::TaskList->create()->run($task);
-            }
-         }
-      }
-   };
-
-   if($@) {
-      # this is always the child
-      Rex::Logger::info("Error running task/batch: $@", "warn");
-      CORE::exit(0);
-   }
-
-   my @exit_codes;
-
-   if($Rex::WITH_EXIT_STATUS) {
-      @exit_codes = Rex::TaskList->create()->get_exit_codes();
-   }
-#print ">> $$\n";
-#print Dumper(\@exit_codes);
-   # lock loeschen
-   Rex::global_sudo(0);
-   Rex::Logger::debug("Removing lockfile") if(! exists $opts{'F'});
-   CORE::unlink("$::rexfile.lock")               if(! exists $opts{'F'});
-
-   # delete shared variable db
-   if(-f "vars.db") {
-      CORE::unlink("vars.db");
-   }
-
-   if(-f "vars.db.lock") {
-      CORE::unlink("vars.db.lock");
-   }
-
-   select STDOUT;
-
-   for my $exit_hook (@exit) {
-      &$exit_hook();
-   }
-
-   if($Rex::WITH_EXIT_STATUS) {
-      for my $exit_code (@exit_codes) {
-         if($exit_code != 0) {
-            exit($exit_code);
-         }
-      }
-   }
-   else {
-      exit(0);
-   }
-
-   sub _print_color {
-       my ($msg, $color) = @_;
-       $color = 'green' if !defined($color);
-
-       if($no_color) {
-           print $msg;
-       }
-       else {
-           print colored([$color], $msg);
-       }
-   };
+    if ( $opts{'P'} ) {
+      Rex::Commands::private_key( $opts{'P'} );
+    }
 
+    if ( $opts{'K'} ) {
+      Rex::Commands::public_key( $opts{'K'} );
+    }
 
+    if ($pass_auth) {
+      pass_auth;
+    }
+
+    my @params = ();
+    if ( $opts{'H'} ) {
+      push @params, split( /\s+/, $opts{'H'} );
+    }
+    push @params, $code;
+    push @params, "eval-line-desc";
+    push @params, {};
+
+    Rex::TaskList->create()->create_task( "eval-line", @params );
+    Rex::Commands::do_task("eval-line");
+    CORE::exit(0);
+  }
+  elsif ( $opts{'M'} ) {
+    Rex::Logger::debug( "Loading Rex-Module: " . $opts{'M'} );
+    my $mod = $opts{'M'};
+    $mod =~ s{::}{/}g;
+    require "$mod.pm";
+  }
+
+  #### check if some parameters should be overwritten from the command line
+CHECK_OVERWRITE: {
+
+    my $pass_auth = 0;
+
+    if ( $opts{'u'} ) {
+      Rex::Commands::user( $opts{'u'} );
+      for my $task ( Rex::TaskList->create()->get_tasks ) {
+        Rex::TaskList->create()->get_task($task)->set_user( $opts{'u'} );
+      }
+    }
+
+    if ( $opts{'p'} ) {
+      Rex::Commands::password( $opts{'p'} );
+
+      unless ( $opts{'P'} ) {
+        $pass_auth = 1;
+      }
+
+      for my $task ( Rex::TaskList->create()->get_tasks ) {
+        Rex::TaskList->create()->get_task($task)->set_password( $opts{'p'} );
+      }
+
+    }
+
+    if ( $opts{'P'} ) {
+      Rex::Commands::private_key( $opts{'P'} );
+
+      for my $task ( Rex::TaskList->create()->get_tasks ) {
+        $task->set_auth( "private_key", $opts{'P'} );
+        Rex::TaskList->create()->get_task($task)
+          ->set_auth( "private_key", $opts{'P'} );
+      }
+    }
+
+    if ( $opts{'K'} ) {
+      Rex::Commands::public_key( $opts{'K'} );
+
+      for my $task ( Rex::TaskList->create()->get_tasks ) {
+        Rex::TaskList->create()->get_task($task)
+          ->set_auth( "public_key", $opts{'K'} );
+      }
+    }
+
+    if ($pass_auth) {
+      pass_auth;
+    }
+
+  }
+
+  Rex::Logger::debug("Initializing Logger from parameters found in $::rexfile");
+
+  if ( $opts{'T'} && $opts{'m'} ) {
+
+    # create machine readable tasklist
+    my @tasks = Rex::TaskList->create()->get_tasks;
+    for my $task (@tasks) {
+      my $desc = Rex::TaskList->create()->get_desc($task);
+      $desc =~ s/'/\\'/gms;
+      print "'$task'" . " = '$desc'\n";
+    }
+  }
+  elsif ( $opts{'T'} ) {
+    Rex::Logger::debug("Listing Tasks and Batches");
+    _print_color( "Tasks\n", "yellow" );
+    my @tasks = Rex::TaskList->create()->get_tasks;
+    unless (@tasks) {
+      print "  no tasks defined.\n";
+      exit;
+    }
+    if ( defined $ARGV[0] ) {
+      @tasks = map { Rex::TaskList->create()->is_task($_) ? $_ : () } @ARGV;
+    }
+    for my $task (@tasks) {
+      printf "  %-30s %s\n", $task, Rex::TaskList->create()->get_desc($task);
+      if ( $opts{'v'} ) {
+        _print_color(
+          "    Servers: "
+            . join( ", ",
+            @{ Rex::TaskList->create()->get_task($task)->{'server'} } )
+            . "\n"
+        );
+      }
+    }
+    _print_color( "Batches\n", 'yellow' ) if ( Rex::Batch->get_batchs );
+    for my $batch ( Rex::Batch->get_batchs ) {
+      printf "  %-30s %s\n", $batch, Rex::Batch->get_desc($batch);
+      if ( $opts{'v'} ) {
+        _print_color(
+          "    " . join( " ", Rex::Batch->get_batch($batch) ) . "\n" );
+      }
+    }
+    _print_color( "Environments\n", "yellow" );
+    print "  " . join( "\n  ", Rex::Commands->get_environments() ) . "\n";
+
+    my %groups = Rex::Group->get_groups;
+    _print_color( "Server Groups\n", "yellow" ) if ( keys %groups );
+    for my $group ( keys %groups ) {
+      printf "  %-30s %s\n", $group, join( ", ", @{ $groups{$group} } );
+    }
+
+    Rex::global_sudo(0);
+    Rex::Logger::debug("Removing lockfile") if ( !exists $opts{'F'} );
+    CORE::unlink("$::rexfile.lock") if ( !exists $opts{'F'} );
+    CORE::exit 0;
+  }
+
+  eval {
+    if ( $opts{'b'} ) {
+      Rex::Logger::debug( "Running batch: " . $opts{'b'} );
+      my $batch = $opts{'b'};
+      if ( Rex::Batch->is_batch($batch) ) {
+        Rex::Batch->run($batch);
+      }
+    }
+
+    if ( defined $ARGV[0] ) {
+      for my $task (@ARGV) {
+        if ( Rex::TaskList->create()->is_task($task) ) {
+          Rex::Logger::debug("Running task: $task");
+          Rex::TaskList->create()->run($task);
+        }
+      }
+    }
+  };
+
+  if ($@) {
+
+    # this is always the child
+    Rex::Logger::info( "Error running task/batch: $@", "warn" );
+    CORE::exit(0);
+  }
+
+  my @exit_codes;
+
+  if ($Rex::WITH_EXIT_STATUS) {
+    @exit_codes = Rex::TaskList->create()->get_exit_codes();
+  }
+
+  #print ">> $$\n";
+  #print Dumper(\@exit_codes);
+  # lock loeschen
+  Rex::global_sudo(0);
+  Rex::Logger::debug("Removing lockfile") if ( !exists $opts{'F'} );
+  CORE::unlink("$::rexfile.lock") if ( !exists $opts{'F'} );
+
+  # delete shared variable db
+  if ( -f "vars.db" ) {
+    CORE::unlink("vars.db");
+  }
+
+  if ( -f "vars.db.lock" ) {
+    CORE::unlink("vars.db.lock");
+  }
+
+  select STDOUT;
+
+  for my $exit_hook (@exit) {
+    &$exit_hook();
+  }
+
+  if ($Rex::WITH_EXIT_STATUS) {
+    for my $exit_code (@exit_codes) {
+      if ( $exit_code != 0 ) {
+        exit($exit_code);
+      }
+    }
+  }
+  else {
+    exit(0);
+  }
+
+  sub _print_color {
+    my ( $msg, $color ) = @_;
+    $color = 'green' if !defined($color);
+
+    if ($no_color) {
+      print $msg;
+    }
+    else {
+      print colored( [$color], $msg );
+    }
+  }
 
 }
 
 sub __help__ {
 
-   print "(R)?ex - (Remote)? Execution\n";
-   printf "  %-15s %s\n", "-b", "Run batch";
-   printf "  %-15s %s\n", "-e", "Run the given code fragment";
-   printf "  %-15s %s\n", "-E", "Execute task on the given environment";
-   printf "  %-15s %s\n", "-H", "Execute task on these hosts";
-   printf "  %-15s %s\n", "-z", "Execute task on hosts from this command's output";
-   printf "  %-15s %s\n", "-G", "Execute task on these group";
-   printf "  %-15s %s\n", "-u", "Username for the ssh connection";
-   printf "  %-15s %s\n", "-p", "Password for the ssh connection";
-   printf "  %-15s %s\n", "-P", "Private Keyfile for the ssh connection";
-   printf "  %-15s %s\n", "-K", "Public Keyfile for the ssh connection";
-   printf "  %-15s %s\n", "-T", "List all known tasks.";
-   printf "  %-15s %s\n", "-Tv", "List all known tasks with all information.";
-   printf "  %-15s %s\n", "-f", "Use this file instead of Rexfile";
-   printf "  %-15s %s\n", "-h", "Display this help";
-   printf "  %-15s %s\n", "-m", "Monochrome output. No colors";
-   printf "  %-15s %s\n", "-M", "Load Module instead of Rexfile";
-   printf "  %-15s %s\n", "-v", "Display (R)?ex Version";
-   printf "  %-15s %s\n", "-F", "Force. Don't regard lock file";
-   printf "  %-15s %s\n", "-s", "Use sudo for every command";
-   printf "  %-15s %s\n", "-S", "Password for sudo";
-   printf "  %-15s %s\n", "-d", "Debug";
-   printf "  %-15s %s\n", "-dd", "More Debug (includes Profiling Output)";
-   printf "  %-15s %s\n", "-o", "Output Format";
-   printf "  %-15s %s\n", "-c", "Turn cache ON";
-   printf "  %-15s %s\n", "-C", "Turn cache OFF";
-   printf "  %-15s %s\n", "-q", "Quiet mode. No Logging output";
-   printf "  %-15s %s\n", "-qw", "Quiet mode. Only output warnings and errors";
-   printf "  %-15s %s\n", "-Q", "Really quiet. Output nothing.";
-   printf "  %-15s %s\n", "-t", "Number of threads to use.";
-   print "\n";
-
-   for my $code (@help) {
-      &$code();
-   }
-
-   CORE::exit 0;
+  print "(R)?ex - (Remote)? Execution\n";
+  printf "  %-15s %s\n", "-b", "Run batch";
+  printf "  %-15s %s\n", "-e", "Run the given code fragment";
+  printf "  %-15s %s\n", "-E", "Execute task on the given environment";
+  printf "  %-15s %s\n", "-H", "Execute task on these hosts";
+  printf "  %-15s %s\n", "-z",
+    "Execute task on hosts from this command's output";
+  printf "  %-15s %s\n", "-G|-g", "Execute task on these group";
+  printf "  %-15s %s\n", "-u",    "Username for the ssh connection";
+  printf "  %-15s %s\n", "-p",    "Password for the ssh connection";
+  printf "  %-15s %s\n", "-P",    "Private Keyfile for the ssh connection";
+  printf "  %-15s %s\n", "-K",    "Public Keyfile for the ssh connection";
+  printf "  %-15s %s\n", "-T",    "List all known tasks.";
+  printf "  %-15s %s\n", "-Tv",   "List all known tasks with all information.";
+  printf "  %-15s %s\n", "-f",    "Use this file instead of Rexfile";
+  printf "  %-15s %s\n", "-h",    "Display this help";
+  printf "  %-15s %s\n", "-m",    "Monochrome output. No colors";
+  printf "  %-15s %s\n", "-M",    "Load Module instead of Rexfile";
+  printf "  %-15s %s\n", "-v",    "Display (R)?ex Version";
+  printf "  %-15s %s\n", "-F",    "Force. Don't regard lock file";
+  printf "  %-15s %s\n", "-s",    "Use sudo for every command";
+  printf "  %-15s %s\n", "-S",    "Password for sudo";
+  printf "  %-15s %s\n", "-d",    "Debug";
+  printf "  %-15s %s\n", "-dd",   "More Debug (includes Profiling Output)";
+  printf "  %-15s %s\n", "-o",    "Output Format";
+  printf "  %-15s %s\n", "-c",    "Turn cache ON";
+  printf "  %-15s %s\n", "-C",    "Turn cache OFF";
+  printf "  %-15s %s\n", "-q",    "Quiet mode. No Logging output";
+  printf "  %-15s %s\n", "-qw",   "Quiet mode. Only output warnings and errors";
+  printf "  %-15s %s\n", "-Q",    "Really quiet. Output nothing.";
+  printf "  %-15s %s\n", "-t",    "Number of threads to use.";
+  print "\n";
+
+  for my $code (@help) {
+    &$code();
+  }
+
+  CORE::exit 0;
 
 }
 
 sub add_help {
-   my ($self, $code) = @_;
-   push(@help, $code);
+  my ( $self, $code ) = @_;
+  push( @help, $code );
 }
 
 sub add_exit {
-   my ($self, $code) = @_;
-   push(@exit, $code);
+  my ( $self, $code ) = @_;
+  push( @exit, $code );
 }
 
 sub __version__ {
-   print "(R)?ex " . $Rex::VERSION . "\n";
-   CORE::exit 0;
+  print "(R)?ex " . $Rex::VERSION . "\n";
+  CORE::exit 0;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::CMDB::YAML;
 
 use strict;
@@ -14,60 +14,60 @@ use Rex::Logger;
 use YAML;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub get {
-   my ($self, $item, $server) = @_;
-
-   # first open $server.yml
-   # second open $environment/$server.yml
-   # third open $environment/default.yml
-   # forth open default.yml
-
-   my $env = environment;
-   my $yaml_path = $self->{path};
-   my @files = ("$env/$server.yml", "$env/default.yml", "$server.yml", "default.yml");
-
-   my $all = {};
-
-   for my $file (@files) {
-      Rex::Logger::debug("CMDB - Opening $yaml_path/$file");
-      if(-f "$yaml_path/$file") {
-         my $content = eval { local(@ARGV, $/) = ("$yaml_path/$file"); <>; };
-         $content .= "\n"; # for safety
-
-         my $ref = Load($content);
-
-         if(! $item) {
-            for my $key (keys %{ $ref }) {
-               if(exists $all->{$key}) {
-                  next;
-               }
-               $all->{$key} = $ref->{$key};
-            }
-         }
-
-         if(defined $item && exists $ref->{$item}) {
-            Rex::Logger::debug("CMDB - Found $item in $file");
-            return $ref->{$item};
-         }
+  my ($self, $item, $server) = @_;
+
+  # first open $server.yml
+  # second open $environment/$server.yml
+  # third open $environment/default.yml
+  # forth open default.yml
+
+  my $env = environment;
+  my $yaml_path = $self->{path};
+  my @files = ("$env/$server.yml", "$env/default.yml", "$server.yml", "default.yml");
+
+  my $all = {};
+
+  for my $file (@files) {
+    Rex::Logger::debug("CMDB - Opening $yaml_path/$file");
+    if(-f "$yaml_path/$file") {
+      my $content = eval { local(@ARGV, $/) = ("$yaml_path/$file"); <>; };
+      $content .= "\n"; # for safety
+
+      my $ref = Load($content);
+
+      if(! $item) {
+        for my $key (keys %{ $ref }) {
+          if(exists $all->{$key}) {
+            next;
+          }
+          $all->{$key} = $ref->{$key};
+        }
       }
-   }
 
-   if(! $item) {
-      return $all;
-   }
+      if(defined $item && exists $ref->{$item}) {
+        Rex::Logger::debug("CMDB - Found $item in $file");
+        return $ref->{$item};
+      }
+    }
+  }
+
+  if(! $item) {
+    return $all;
+  }
 
-   Rex::Logger::debug("CMDB - no item ($item) found");
+  Rex::Logger::debug("CMDB - no item ($item) found");
 
-   return undef;
+  return undef;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::CMDB;
 
 use strict;
@@ -20,8 +20,8 @@ use vars qw(@EXPORT);
 my $CMDB_PROVIDER;
 
 Rex::Config->register_set_handler("cmdb" => sub {
-   my ($option) = @_;
-   $CMDB_PROVIDER = $option;
+  my ($option) = @_;
+  $CMDB_PROVIDER = $option;
 });
 
 =item cmdb([$item, $server])
@@ -29,27 +29,27 @@ Rex::Config->register_set_handler("cmdb" => sub {
 Function to query a CMDB. If this function is called without $item it should return a hash containing all the information for the requested server. If $item is given it should return only the value for $item.
 
  task "prepare", "server1", sub {
-    my $virtual_host = cmdb("vhost");
-    my %all_information = cmdb;
+   my $virtual_host = cmdb("vhost");
+   my %all_information = cmdb;
  };
 
 =cut
 sub cmdb {
-   my ($item, $server) = @_;
-   $server ||= connection->server;
+  my ($item, $server) = @_;
+  $server ||= connection->server;
 
-   my $klass = $CMDB_PROVIDER->{type};
-   if($klass !~ m/::/) {
-      $klass = "Rex::CMDB::$klass";
-   }
+  my $klass = $CMDB_PROVIDER->{type};
+  if($klass !~ m/::/) {
+    $klass = "Rex::CMDB::$klass";
+  }
 
-   eval "use $klass";
-   if($@) {
-      die("CMDB provider ($klass) not found: $@");
-   }
+  eval "use $klass";
+  if($@) {
+    die("CMDB provider ($klass) not found: $@");
+  }
 
-   my $cmdb = $klass->new(%{ $CMDB_PROVIDER });
-   return Rex::Value->new(value => $cmdb->get($item, $server));
+  my $cmdb = $klass->new(%{ $CMDB_PROVIDER });
+  return Rex::Value->new(value => $cmdb->get($item, $server));
 }
 
 1;
@@ -1,15 +1,15 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 #
 # Some of the code is based on Net::Amazon::EC2
 #
-   
+  
 package Rex::Cloud::Amazon;
-   
+  
 use strict;
 use warnings;
 
@@ -29,427 +29,427 @@ use Data::Dumper;
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   #$self->{"__version"} = "2009-11-30";
-   $self->{"__version"} = "2011-05-15";
-   $self->{"__signature_version"} = 1;
-   $self->{"__endpoint"} = "us-east-1.ec2.amazonaws.com";
+  #$self->{"__version"} = "2009-11-30";
+  $self->{"__version"} = "2011-05-15";
+  $self->{"__signature_version"} = 1;
+  $self->{"__endpoint"} = "us-east-1.ec2.amazonaws.com";
 
-   Rex::Logger::debug("Creating new Amazon Object, with endpoint: " . $self->{"__endpoint"});
-   Rex::Logger::debug("Using API Version: " . $self->{"__version"});
+  Rex::Logger::debug("Creating new Amazon Object, with endpoint: " . $self->{"__endpoint"});
+  Rex::Logger::debug("Using API Version: " . $self->{"__version"});
 
-   return $self;
+  return $self;
 }
 
 sub set_auth {
-   my ($self, $access_key, $secret_access_key) = @_;
+  my ($self, $access_key, $secret_access_key) = @_;
 
-   $self->{"__access_key"} = $access_key;
-   $self->{"__secret_access_key"} = $secret_access_key;
+  $self->{"__access_key"} = $access_key;
+  $self->{"__secret_access_key"} = $secret_access_key;
 }
 
 sub set_endpoint {
-   my ($self, $endpoint) = @_;
-   Rex::Logger::debug("Setting new endpoint to $endpoint");
-   $self->{'__endpoint'} = $endpoint;
+  my ($self, $endpoint) = @_;
+  Rex::Logger::debug("Setting new endpoint to $endpoint");
+  $self->{'__endpoint'} = $endpoint;
 }
 
 sub timestamp {
-   my $t = time2isoz();
-   chop($t);
-   $t .= ".000Z";
-   $t =~ s/\s+/T/g;
-   return $t;
+  my $t = time2isoz();
+  chop($t);
+  $t .= ".000Z";
+  $t =~ s/\s+/T/g;
+  return $t;
 }
 
 sub run_instance {
-   my ($self, %data) = @_;
-
-   Rex::Logger::debug("Trying to start a new Amazon instance with data:");
-   Rex::Logger::debug("   $_ -> " . ($data{$_}?$data{$_}:"undef")) for keys %data;
-
-   my $security_groups;
-
-   if(ref($data{security_group}) eq "ARRAY") {
-      $security_groups = $data{security_group};
-   }
-   elsif(exists $data{security_groups}) {
-      $security_groups = $data{security_groups};
-   }
-   else {
-      $security_groups = $data{security_group};
-   }
-
-   my %security_group = ();
-   if(ref($security_groups) eq "ARRAY") {
-      my $i = 0;
-      for my $sg (@{ $security_groups }) {
-         $security_group{"SecurityGroup.$i"} = $sg;
-         $i++;
-      }
-   }
-   else {
-      $security_group{SecurityGroup} = $security_groups || "default";
-   }
-
-   my $xml = $self->_request("RunInstances", 
-               ImageId  => $data{"image_id"},
-               MinCount => 1,
-               MaxCount => 1,
-               KeyName  => $data{"key"},
-               InstanceType => $data{"type"} || "m1.small",
-               "Placement.AvailabilityZone" => $data{"zone"} || "",
-               %security_group);
-
-   my $ref = $self->_xml($xml);
-
-   if(exists $data{"name"}) {
-      $self->add_tag(id => $ref->{"instancesSet"}->{"item"}->{"instanceId"},
-                     name => "Name",
-                     value => $data{"name"});
-   }
-
-   my ($info) = grep { $_->{"id"} eq $ref->{"instancesSet"}->{"item"}->{"instanceId"} } $self->list_instances();
-
-   while($info->{"state"} ne "running") {
-      Rex::Logger::debug("Waiting for instance to be created...");
-      ($info) = grep { $_->{"id"} eq $ref->{"instancesSet"}->{"item"}->{"instanceId"} } $self->list_instances();
-      sleep 1;
-   }
-
-   if(exists $data{"volume"}) {
-      $self->attach_volume(
-         volume_id => $data{"volume"},
-         instance_id => $ref->{"instancesSet"}->{"item"}->{"instanceId"},
-         name => "/dev/sdh", # default for new instances
-      );
-   }
-
-   return $info;
+  my ($self, %data) = @_;
+
+  Rex::Logger::debug("Trying to start a new Amazon instance with data:");
+  Rex::Logger::debug("  $_ -> " . ($data{$_}?$data{$_}:"undef")) for keys %data;
+
+  my $security_groups;
+
+  if(ref($data{security_group}) eq "ARRAY") {
+    $security_groups = $data{security_group};
+  }
+  elsif(exists $data{security_groups}) {
+    $security_groups = $data{security_groups};
+  }
+  else {
+    $security_groups = $data{security_group};
+  }
+
+  my %security_group = ();
+  if(ref($security_groups) eq "ARRAY") {
+    my $i = 0;
+    for my $sg (@{ $security_groups }) {
+      $security_group{"SecurityGroup.$i"} = $sg;
+      $i++;
+    }
+  }
+  else {
+    $security_group{SecurityGroup} = $security_groups || "default";
+  }
+
+  my $xml = $self->_request("RunInstances", 
+          ImageId  => $data{"image_id"},
+          MinCount => 1,
+          MaxCount => 1,
+          KeyName  => $data{"key"},
+          InstanceType => $data{"type"} || "m1.small",
+          "Placement.AvailabilityZone" => $data{"zone"} || "",
+          %security_group);
+
+  my $ref = $self->_xml($xml);
+
+  if(exists $data{"name"}) {
+    $self->add_tag(id => $ref->{"instancesSet"}->{"item"}->{"instanceId"},
+              name => "Name",
+              value => $data{"name"});
+  }
+
+  my ($info) = grep { $_->{"id"} eq $ref->{"instancesSet"}->{"item"}->{"instanceId"} } $self->list_instances();
+
+  while($info->{"state"} ne "running") {
+    Rex::Logger::debug("Waiting for instance to be created...");
+    ($info) = grep { $_->{"id"} eq $ref->{"instancesSet"}->{"item"}->{"instanceId"} } $self->list_instances();
+    sleep 1;
+  }
+
+  if(exists $data{"volume"}) {
+    $self->attach_volume(
+      volume_id => $data{"volume"},
+      instance_id => $ref->{"instancesSet"}->{"item"}->{"instanceId"},
+      name => "/dev/sdh", # default for new instances
+    );
+  }
+
+  return $info;
 }
 
 sub attach_volume {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to attach a new volume");
+  Rex::Logger::debug("Trying to attach a new volume");
 
-   $self->_request("AttachVolume", 
-      VolumeId => $data{"volume_id"},
-      InstanceId => $data{"instance_id"},
-      Device => $data{"name"} || "/dev/sdh");
+  $self->_request("AttachVolume", 
+    VolumeId => $data{"volume_id"},
+    InstanceId => $data{"instance_id"},
+    Device => $data{"name"} || "/dev/sdh");
 }
 
 sub detach_volume {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to detach a volume");
+  Rex::Logger::debug("Trying to detach a volume");
 
-   $self->_request("DetachVolume",
-         VolumeId => $data{"volume_id"},
-      );
+  $self->_request("DetachVolume",
+      VolumeId => $data{"volume_id"},
+    );
 }
 
 sub delete_volume {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to delete a volume");
+  Rex::Logger::debug("Trying to delete a volume");
 
-   $self->_request("DeleteVolume", 
-      VolumeId => $data{"volume_id"},
-   );
+  $self->_request("DeleteVolume", 
+    VolumeId => $data{"volume_id"},
+  );
 }
 
 sub terminate_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to terminate an instance");
+  Rex::Logger::debug("Trying to terminate an instance");
 
-   $self->_request("TerminateInstances",
-               "InstanceId.1" => $data{"instance_id"});
+  $self->_request("TerminateInstances",
+          "InstanceId.1" => $data{"instance_id"});
 }
 
 sub start_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to start an instance");
+  Rex::Logger::debug("Trying to start an instance");
 
-   $self->_request("StartInstances",
-               "InstanceId.1" => $data{instance_id});
+  $self->_request("StartInstances",
+          "InstanceId.1" => $data{instance_id});
 
-   my ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
+  my ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
 
-   while($info->{"state"} ne "running") {
-      Rex::Logger::debug("Waiting for instance to be started...");
-      ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
-      sleep 5;
-   }
+  while($info->{"state"} ne "running") {
+    Rex::Logger::debug("Waiting for instance to be started...");
+    ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
+    sleep 5;
+  }
 
 }
 
 sub stop_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Trying to stop an instance");
+  Rex::Logger::debug("Trying to stop an instance");
 
-   $self->_request("StopInstances",
-               "InstanceId.1" => $data{instance_id});
+  $self->_request("StopInstances",
+          "InstanceId.1" => $data{instance_id});
 
-   my ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
+  my ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
 
-   while($info->{"state"} ne "stopped") {
-      Rex::Logger::debug("Waiting for instance to be stopped...");
-      ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
-      sleep 5;
-   }
+  while($info->{"state"} ne "stopped") {
+    Rex::Logger::debug("Waiting for instance to be stopped...");
+    ($info) = grep { $_->{"id"} eq $data{"instance_id"} } $self->list_instances();
+    sleep 5;
+  }
 
 }
 
 sub add_tag {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Adding a new tag: " . $data{id} . " -> " . $data{name} .  " -> " . $data{value});
+  Rex::Logger::debug("Adding a new tag: " . $data{id} . " -> " . $data{name} .  " -> " . $data{value});
 
-   $self->_request("CreateTags",
-               "ResourceId.1" => $data{"id"},
-               "Tag.1.Key"    => $data{"name"},
-               "Tag.1.Value"  => $data{"value"});
+  $self->_request("CreateTags",
+          "ResourceId.1" => $data{"id"},
+          "Tag.1.Key"   => $data{"name"},
+          "Tag.1.Value"  => $data{"value"});
 }
 
 sub create_volume {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   Rex::Logger::debug("Creating a new volume");
+  Rex::Logger::debug("Creating a new volume");
 
-   my $xml = $self->_request("CreateVolume", 
-               "Size" => $data{"size"} || 1,
-               "AvailabilityZone" => $data{"zone"},
-               );
+  my $xml = $self->_request("CreateVolume", 
+          "Size" => $data{"size"} || 1,
+          "AvailabilityZone" => $data{"zone"},
+          );
 
-   my $ref = $self->_xml($xml);
+  my $ref = $self->_xml($xml);
 
-   return $ref->{"volumeId"};
+  return $ref->{"volumeId"};
 
-   my ($info) = grep { $_->{"id"} eq $ref->{"volumeId"} } $self->list_volumes();
+  my ($info) = grep { $_->{"id"} eq $ref->{"volumeId"} } $self->list_volumes();
 
-   while($info->{"status"} ne "available") {
-      Rex::Logger::debug("Waiting for volume to become ready...");
-      ($info) = grep { $_->{"id"} eq $ref->{"volumeId"} } $self->list_volumes();
-      sleep 1;
-   }
+  while($info->{"status"} ne "available") {
+    Rex::Logger::debug("Waiting for volume to become ready...");
+    ($info) = grep { $_->{"id"} eq $ref->{"volumeId"} } $self->list_volumes();
+    sleep 1;
+  }
 
 }
 
 sub list_volumes {
-   my ($self) = @_;
-
-   my $xml = $self->_request("DescribeVolumes");
-   my $ref = $self->_xml($xml);
-
-   return unless($ref);
-   return unless(exists $ref->{"volumeSet"}->{"item"});
-   if(ref($ref->{"volumeSet"}->{"item"}) eq "HASH") {
-      $ref->{"volumeSet"}->{"item"} = [ $ref->{"volumeSet"}->{"item"} ];
-   }
-
-   my @volumes;
-   for my $vol (@{$ref->{"volumeSet"}->{"item"}}) {
-      push(@volumes, {
-         id => $vol->{"volumeId"},
-         status => $vol->{"status"},
-         zone => $vol->{"availabilityZone"},
-         size => $vol->{"size"},
-         attached_to => $vol->{"attachmentSet"}->{"item"}->{"instanceId"},
-      });
-   }
-
-   return @volumes;
+  my ($self) = @_;
+
+  my $xml = $self->_request("DescribeVolumes");
+  my $ref = $self->_xml($xml);
+
+  return unless($ref);
+  return unless(exists $ref->{"volumeSet"}->{"item"});
+  if(ref($ref->{"volumeSet"}->{"item"}) eq "HASH") {
+    $ref->{"volumeSet"}->{"item"} = [ $ref->{"volumeSet"}->{"item"} ];
+  }
+
+  my @volumes;
+  for my $vol (@{$ref->{"volumeSet"}->{"item"}}) {
+    push(@volumes, {
+      id => $vol->{"volumeId"},
+      status => $vol->{"status"},
+      zone => $vol->{"availabilityZone"},
+      size => $vol->{"size"},
+      attached_to => $vol->{"attachmentSet"}->{"item"}->{"instanceId"},
+    });
+  }
+
+  return @volumes;
 }
 
 sub list_instances {
-   my ($self) = @_;
-
-   my @ret;
-
-   my $xml = $self->_request("DescribeInstances");
-   my $ref = $self->_xml($xml);
-
-   return unless($ref);
-   return unless(exists $ref->{"reservationSet"});
-   return unless(exists $ref->{"reservationSet"}->{"item"});
-
-   if(ref $ref->{"reservationSet"}->{"item"} eq "HASH") {
-      # if only one instance is returned, turn it to an array
-      $ref->{"reservationSet"}->{"item"} = [ $ref->{"reservationSet"}->{"item"} ];
-   }
-
-   for my $instance_set (@{$ref->{"reservationSet"}->{"item"}}) {
-       if (ref $instance_set->{"instancesSet"}->{"item"} eq 'HASH') {
-	   push(@ret, {
-	       ip => $instance_set->{"instancesSet"}->{"item"}->{"ipAddress"},
-	       id => $instance_set->{"instancesSet"}->{"item"}->{"instanceId"},
-	       architecture => $instance_set->{"instancesSet"}->{"item"}->{"architecture"},
-	       type => $instance_set->{"instancesSet"}->{"item"}->{"instanceType"},
-	       dns_name => $instance_set->{"instancesSet"}->{"item"}->{"dnsName"},
-	       state => $instance_set->{"instancesSet"}->{"item"}->{"instanceState"}->{"name"},
-	       launch_time => $instance_set->{"instancesSet"}->{"item"}->{"launchTime"},
-	       name => $instance_set->{"instancesSet"}->{"item"}->{"tagSet"}->{"item"}->{"value"},
-	       private_ip => $instance_set->{"instancesSet"}->{"item"}->{"privateIpAddress"},
-	       (security_group =>
+  my ($self) = @_;
+
+  my @ret;
+
+  my $xml = $self->_request("DescribeInstances");
+  my $ref = $self->_xml($xml);
+
+  return unless($ref);
+  return unless(exists $ref->{"reservationSet"});
+  return unless(exists $ref->{"reservationSet"}->{"item"});
+
+  if(ref $ref->{"reservationSet"}->{"item"} eq "HASH") {
+    # if only one instance is returned, turn it to an array
+    $ref->{"reservationSet"}->{"item"} = [ $ref->{"reservationSet"}->{"item"} ];
+  }
+
+  for my $instance_set (@{$ref->{"reservationSet"}->{"item"}}) {
+     if (ref $instance_set->{"instancesSet"}->{"item"} eq 'HASH') {
+	  push(@ret, {
+	     ip => $instance_set->{"instancesSet"}->{"item"}->{"ipAddress"},
+	     id => $instance_set->{"instancesSet"}->{"item"}->{"instanceId"},
+	     architecture => $instance_set->{"instancesSet"}->{"item"}->{"architecture"},
+	     type => $instance_set->{"instancesSet"}->{"item"}->{"instanceType"},
+	     dns_name => $instance_set->{"instancesSet"}->{"item"}->{"dnsName"},
+	     state => $instance_set->{"instancesSet"}->{"item"}->{"instanceState"}->{"name"},
+	     launch_time => $instance_set->{"instancesSet"}->{"item"}->{"launchTime"},
+	     name => $instance_set->{"instancesSet"}->{"item"}->{"tagSet"}->{"item"}->{"value"},
+	     private_ip => $instance_set->{"instancesSet"}->{"item"}->{"privateIpAddress"},
+	     (security_group =>
 		ref $instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"} eq 'ARRAY'
-                ? join ',', map {$_->{groupName} } @{$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}}
-                :$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}->{"groupName"}
-	       ),
-	       (security_groups =>
+           ? join ',', map {$_->{groupName} } @{$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}}
+           :$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}->{"groupName"}
+	     ),
+	     (security_groups =>
 		ref $instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"} eq 'ARRAY'
-                ? [ map { $_->{groupName} } @{$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}} ]
-                : [ $instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}->{"groupName"} ]
-	       ),
+           ? [ map { $_->{groupName} } @{$instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}} ]
+           : [ $instance_set->{"instancesSet"}->{"item"}->{"groupSet"}->{"item"}->{"groupName"} ]
+	     ),
 		})
-       }
-   }
+     }
+  }
 
-   return @ret;
+  return @ret;
 }
 
 sub list_running_instances {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   return grep { $_->{"state"} eq "running" } $self->list_instances();
+  return grep { $_->{"state"} eq "running" } $self->list_instances();
 }
 
 sub get_regions {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $content = $self->_request("DescribeRegions");
-   my %items = ($content =~ m/<regionName>([^<]+)<\/regionName>\s+<regionEndpoint>([^<]+)<\/regionEndpoint>/gsim);
+  my $content = $self->_request("DescribeRegions");
+  my %items = ($content =~ m/<regionName>([^<]+)<\/regionName>\s+<regionEndpoint>([^<]+)<\/regionEndpoint>/gsim);
 
-   return %items;
+  return %items;
 }
 
 sub get_availability_zones {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $xml = $self->_request("DescribeAvailabilityZones");
-   my $ref = $self->_xml($xml);
+  my $xml = $self->_request("DescribeAvailabilityZones");
+  my $ref = $self->_xml($xml);
 
-   my @zones;
-   for my $item (@{$ref->{"availabilityZoneInfo"}->{"item"}}) {
-      push(@zones, {
-         zone_name => $item->{"zoneName"},
-         region_name => $item->{"regionName"},
-         zone_state => $item->{"zoneState"},
-      });
-   }
+  my @zones;
+  for my $item (@{$ref->{"availabilityZoneInfo"}->{"item"}}) {
+    push(@zones, {
+      zone_name => $item->{"zoneName"},
+      region_name => $item->{"regionName"},
+      zone_state => $item->{"zoneState"},
+    });
+  }
 
-   return @zones;
+  return @zones;
 }
 
 sub _request {
-   my ($self, $action, %args) = @_;
-
-   my $ua = LWP::UserAgent->new;
-   $ua->env_proxy;
-   my %param = $self->_sign($action, %args);
-
-   Rex::Logger::debug("Sending request to: http://" . $self->{'__endpoint'});
-   Rex::Logger::debug("   $_ -> " . $param{$_}) for keys %param;
-
-   my $res = $ua->post("http://" . $self->{'__endpoint'}, \%param);
-
-   if($res->code >= 500) {
-      Rex::Logger::info("Error on request", "warn");
-      Rex::Logger::debug($res->content);
-      return;
-   }
-
-   else {
-      my $ret;
-      eval {
-         no warnings;
-         $ret = $res->content;
-         Rex::Logger::debug($ret);
-         use warnings;
-      };
-
-      return $ret;
-   }
+  my ($self, $action, %args) = @_;
+
+  my $ua = LWP::UserAgent->new;
+  $ua->env_proxy;
+  my %param = $self->_sign($action, %args);
+
+  Rex::Logger::debug("Sending request to: http://" . $self->{'__endpoint'});
+  Rex::Logger::debug("  $_ -> " . $param{$_}) for keys %param;
+
+  my $res = $ua->post("http://" . $self->{'__endpoint'}, \%param);
+
+  if($res->code >= 500) {
+    Rex::Logger::info("Error on request", "warn");
+    Rex::Logger::debug($res->content);
+    return;
+  }
+
+  else {
+    my $ret;
+    eval {
+      no warnings;
+      $ret = $res->content;
+      Rex::Logger::debug($ret);
+      use warnings;
+    };
+
+    return $ret;
+  }
 }
 
 sub _sign {
-   my ($self, $action, %o_args) = @_;  
-
-   my %args;
-   for my $key (keys %o_args) {
-      next unless $key;
-      next unless $o_args{$key};
-
-      $args{$key} = $o_args{$key};
-   }
-
-   my %sign_hash = (
-      AWSAccessKeyId   => $self->{"__access_key"},
-      Action           => $action,
-      Timestamp        => $self->timestamp(),
-      Version          => $self->{"__version"},
-      SignatureVersion => $self->{"__signature_version"},
-      %args
-   );
-
-   my $sign_this;
-   foreach my $key (sort { lc($a) cmp lc($b) } keys %sign_hash) {
-      $sign_this .= $key . $sign_hash{$key};
-   }
-
-   Rex::Logger::debug("Signed: $sign_this");
-
-   my $encoded = $self->_hash($sign_this);
-
-   my %params = (
-      Action            => $action,
-      SignatureVersion  => $self->{"__signature_version"},
-      AWSAccessKeyId    => $self->{"__access_key"},
-      Timestamp         => $self->timestamp(),
-      Version           => $self->{"__version"},
-      Signature         => $encoded,
-      %args
-   );
-
-   return %params;
+  my ($self, $action, %o_args) = @_;  
+
+  my %args;
+  for my $key (keys %o_args) {
+    next unless $key;
+    next unless $o_args{$key};
+
+    $args{$key} = $o_args{$key};
+  }
+
+  my %sign_hash = (
+    AWSAccessKeyId  => $self->{"__access_key"},
+    Action        => $action,
+    Timestamp      => $self->timestamp(),
+    Version       => $self->{"__version"},
+    SignatureVersion => $self->{"__signature_version"},
+    %args
+  );
+
+  my $sign_this;
+  foreach my $key (sort { lc($a) cmp lc($b) } keys %sign_hash) {
+    $sign_this .= $key . $sign_hash{$key};
+  }
+
+  Rex::Logger::debug("Signed: $sign_this");
+
+  my $encoded = $self->_hash($sign_this);
+
+  my %params = (
+    Action        => $action,
+    SignatureVersion  => $self->{"__signature_version"},
+    AWSAccessKeyId   => $self->{"__access_key"},
+    Timestamp      => $self->timestamp(),
+    Version        => $self->{"__version"},
+    Signature      => $encoded,
+    %args
+  );
+
+  return %params;
 }
 
 sub _hash {
-   my ($self, $query_string) = @_;
+  my ($self, $query_string) = @_;
 
-   my $hashed = Digest::HMAC_SHA1->new($self->{"__secret_access_key"});
-   $hashed->add($query_string);
+  my $hashed = Digest::HMAC_SHA1->new($self->{"__secret_access_key"});
+  $hashed->add($query_string);
 
-   return encode_base64($hashed->digest, "");
+  return encode_base64($hashed->digest, "");
 }
 
 sub _xml {
-   my ($self, $xml) = @_;
+  my ($self, $xml) = @_;
 
-   my $x = XML::Simple->new;
-   my $res = $x->XMLin($xml);
-   if(defined $res->{"Errors"}) {
-      if(ref($res->{"Errors"}) ne "ARRAY") {
-         $res->{"Errors"} = [ $res->{"Errors"} ];
-      }
+  my $x = XML::Simple->new;
+  my $res = $x->XMLin($xml);
+  if(defined $res->{"Errors"}) {
+    if(ref($res->{"Errors"}) ne "ARRAY") {
+      $res->{"Errors"} = [ $res->{"Errors"} ];
+    }
 
-      my @error_msg = ();
-      for my $error (@{$res->{"Errors"}}) {
-         push(@error_msg, $error->{"Error"}->{"Message"} . " (Code: " . $error->{"Error"}->{"Code"} . ")");
-      }
+    my @error_msg = ();
+    for my $error (@{$res->{"Errors"}}) {
+      push(@error_msg, $error->{"Error"}->{"Message"} . " (Code: " . $error->{"Error"}->{"Code"} . ")");
+    }
 
-      die(join("\n", @error_msg));
-   }
+    die(join("\n", @error_msg));
+  }
 
-   return $res;
+  return $res;
 }
 
 
@@ -1,34 +1,34 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Cloud::Base;
-   
+
 use strict;
 use warnings;
 
 use Rex::Logger;
-   
+
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub set_auth { Rex::Logger::debug("Not implemented"); }
 
 sub set_endpoint {
-   my ($self, $endpoint) = @_;
-   # only set endpoint if defined
-   if(defined $endpoint) {
-      $self->{__endpoint} = $endpoint;
-   }
+  my ($self, $endpoint) = @_;
+  # only set endpoint if defined
+  if(defined $endpoint) {
+    $self->{__endpoint} = $endpoint;
+  }
 }
 
 sub list_plans { Rex::Logger::debug("Not implemented"); }
@@ -46,9 +46,10 @@ sub attach_volume { Rex::Logger::debug("Not implemented"); }
 sub detach_volume { Rex::Logger::debug("Not implemented"); }
 sub delete_volume { Rex::Logger::debug("Not implemented"); }
 sub list_volumes { Rex::Logger::debug("Not implemented"); }
+sub list_images { Rex::Logger::debug("Not implemented"); }
 
 sub add_tag { Rex::Logger::debug("Not implemented"); }
-   
+
 sub get_regions { Rex::Logger::debug("Not implemented"); }
 sub get_availability_zones { Rex::Logger::debug("Not implemented"); }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Cloud::Jiffybox;
-   
+
 use strict;
 use warnings;
 
@@ -18,246 +18,260 @@ use Data::Dumper;
 use Rex::Cloud::Base;
 
 use base qw(Rex::Cloud::Base);
-   
+
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{"__endpoint"} = "https://api.jiffybox.de/%s/v1.0/%s";
-   Rex::Logger::debug("Creating new Jiffybox Object, with endpoint: " . $self->{"__endpoint"});
+  $self->{"__endpoint"} = "https://api.jiffybox.de/%s/v1.0/%s";
+  Rex::Logger::debug("Creating new Jiffybox Object, with endpoint: " . $self->{"__endpoint"});
 
-   return $self;
+  return $self;
 }
 
 sub _auth_key {
-   my ($self) = @_;
-   return $self->{"__auth_key"};
+  my ($self) = @_;
+  return $self->{"__auth_key"};
 }
 
 sub _do_request {
-   my ($self, $type, $action, @params) = @_;
-
-   my $url = sprintf($self->{"__endpoint"}, $self->_auth_key, $action);
-
-   Rex::Logger::debug("Requesting $url");
-
-   my $ua  = LWP::UserAgent->new;
-   $ua->env_proxy;
-   my ($res);
-
-   if($type eq "GET") {
-      $res = $ua->request(GET $url);
-   }
-   elsif($type eq "POST") {
-      $res = $ua->request(POST $url, \@params);
-   }
-   elsif($type eq "PUT") {
-      my $req = POST $url, \@params;
-      $req->method("PUT");
-      $res = $ua->request($req);
-   }
-   elsif($type eq "DELETE") {
-      my $req = GET $url;
-      $req->method("DELETE");
-      $res = $ua->request($req);
-   }
-
-   if($res->code >= 500) {
-      Rex::Logger::info($res->content);
-      die("Error on request.");
-   }
-
-   my $json = JSON::XS->new;
-   my $data = $json->decode($res->decoded_content);
-
-   Rex::Logger::debug(Dumper($data));
-
-   unless($data->{"result"}) {
-      die("Error talking to jiffybox: " . $data->{"messages"}->[0]->{"message"});
-   }
-   
-   return $data;
+  my ($self, $type, $action, @params) = @_;
+
+  my $url = sprintf($self->{"__endpoint"}, $self->_auth_key, $action);
+
+  Rex::Logger::debug("Requesting $url");
+
+  my $ua  = LWP::UserAgent->new;
+  $ua->env_proxy;
+  my ($res);
+
+  if($type eq "GET") {
+    $res = $ua->request(GET $url);
+  }
+  elsif($type eq "POST") {
+    $res = $ua->request(POST $url, \@params);
+  }
+  elsif($type eq "PUT") {
+    my $req = POST $url, \@params;
+    $req->method("PUT");
+    $res = $ua->request($req);
+  }
+  elsif($type eq "DELETE") {
+    my $req = GET $url;
+    $req->method("DELETE");
+    $res = $ua->request($req);
+  }
+
+  if($res->code >= 500) {
+    Rex::Logger::info($res->content);
+    die("Error on request.");
+  }
+
+  my $json = JSON::XS->new;
+  my $data = $json->decode($res->decoded_content);
+
+  Rex::Logger::debug(Dumper($data));
+
+  unless($data->{"result"}) {
+    die("Error talking to jiffybox: " . $data->{"messages"}->[0]->{"message"});
+  }
+
+  return $data;
 }
 
 sub _result_to_array {
-   my ($self, $data, $with_key) = @_;
+  my ($self, $data, $with_key) = @_;
 
-   my @ret = ();
+  my @ret = ();
 
-   for my $key (keys %{$data->{"result"}}) {
-      if($with_key) {
-         $data->{"result"}->{$key}->{$with_key} = $key;
-      }
-      push(@ret, $data->{"result"}->{$key});
-   }
+  for my $key (keys %{$data->{"result"}}) {
+    if($with_key) {
+      $data->{"result"}->{$key}->{$with_key} = $key;
+    }
+    push(@ret, $data->{"result"}->{$key});
+  }
 
-   return @ret;
+  return @ret;
 }
 
 sub set_auth {
-   my ($self, $key) = @_;
-   $self->{"__auth_key"} = $key;
+  my ($self, $key) = @_;
+  $self->{"__auth_key"} = $key;
 }
 
 sub list_plans {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   Rex::Logger::debug("Listing plans");
+  Rex::Logger::debug("Listing plans");
 
-   my $data = $self->_do_request("GET", "plans");
+  my $data = $self->_do_request("GET", "plans");
 
-   return $self->_result_to_array($data);
+  return $self->_result_to_array($data);
 }
 
 sub list_operating_systems {
-   my ($self) = @_;
+  my ($self) = @_;
+
+  Rex::Logger::debug("Listing operating systems");
 
-   Rex::Logger::debug("Listing operating systems");
+  my $data = $self->_do_request("GET", "distributions");
 
-   my $data = $self->_do_request("GET", "distributions");
- 
-   return $self->_result_to_array($data, "os_id");
+  return $self->_result_to_array($data, "os_id");
 }
 
 sub run_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my @jiffy_data;
+  my @jiffy_data;
 
-   Rex::Logger::debug("Trying to start a new instance with data:");
-   Rex::Logger::debug("   $_ -> " . ($data{$_}?$data{$_}:"undef")) for keys %data;
+  Rex::Logger::debug("Trying to start a new instance with data:");
+  Rex::Logger::debug("  $_ -> " . ($data{$_}?$data{$_}:"undef")) for keys %data;
 
-   push(@jiffy_data, "name" => $data{"name"}, "planid" => $data{"plan_id"}, "distribution" => $data{"image_id"});
+  push(@jiffy_data, "name" => $data{"name"}, "planid" => $data{"plan_id"}, "distribution" => $data{"image_id"});
 
-   if(exists $data{"password"}) {
-      push(@jiffy_data, "password" => $data{"password"});
-   }
+  if(exists $data{"password"}) {
+    push(@jiffy_data, "password" => $data{"password"});
+  }
 
-   if(exists $data{"key"}) {
-      push(@jiffy_data, "use_sshkey" => $data{"key"});
-   }
+  if(exists $data{"key"}) {
+    push(@jiffy_data, "use_sshkey" => $data{"key"});
+  }
 
-   if(exists $data{"metadata"}) {
-      push(@jiffy_data, "metadata" => $data{"metadata"});
-   }
+  if(exists $data{"metadata"}) {
+    push(@jiffy_data, "metadata" => $data{"metadata"});
+  }
 
-   my $data = $self->_do_request("POST", "jiffyBoxes", @jiffy_data);
-   my $instance_id = $data->{"result"}->{"id"};
+  my $data = $self->_do_request("POST", "jiffyBoxes", @jiffy_data);
+  my $instance_id = $data->{"result"}->{"id"};
 
-   my $sleep_countdown = 10;
-   sleep $sleep_countdown; # wait 10 seconds
 
-   ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  my $sleep_countdown = 10;
+  sleep $sleep_countdown; # wait 10 seconds
 
-   while($data->{"state"} ne "STOPPED") {
-      Rex::Logger::debug("Waiting for instance to be created...");
-      ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  while($data->{"state"} ne "STOPPED" && $data->{"state"} ne "RUNNING") {
+    Rex::Logger::debug("Waiting for instance to be created...");
+    ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
 
-      sleep $sleep_countdown;
+    sleep $sleep_countdown;
 
-      --$sleep_countdown;
+    --$sleep_countdown;
 
-      if($sleep_countdown <= 3) {
-         $sleep_countdown = 7;
-      }
-   }
+    if($sleep_countdown <= 3) {
+      $sleep_countdown = 7;
+    }
+  }
+
+  $self->start_instance(instance_id => $instance_id);
 
-   $self->start_instance(instance_id => $instance_id);
+  ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  while($data->{"state"} ne "RUNNING") {
+    Rex::Logger::debug("Waiting for instance to be started...");
+    ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
 
-   return $data;
+    sleep $sleep_countdown;
+
+    --$sleep_countdown;
+
+    if($sleep_countdown <= 3) {
+      $sleep_countdown = 7;
+    }
+  }
+
+  return $data;
 
 }
 
 sub start_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my $instance_id = $data{"instance_id"};
-   Rex::Logger::debug("Starting instance $instance_id");
-   $self->_do_request("PUT", "jiffyBoxes/$instance_id", status => "START");
+  my $instance_id = $data{"instance_id"};
+  Rex::Logger::debug("Starting instance $instance_id");
+  $self->_do_request("PUT", "jiffyBoxes/$instance_id", status => "START");
 
 }
 
 
 sub terminate_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my $instance_id = $data{"instance_id"};
-   Rex::Logger::debug("Terminating instance $instance_id");
-   $self->stop_instance(%data);
-   $self->_do_request("DELETE", "jiffyBoxes/$instance_id");
+  my $instance_id = $data{"instance_id"};
+  Rex::Logger::debug("Terminating instance $instance_id");
+  $self->stop_instance(%data);
+  $self->_do_request("DELETE", "jiffyBoxes/$instance_id");
 
 }
 
 sub stop_instance {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my $instance_id = $data{"instance_id"};
-   Rex::Logger::debug("Stopping instance $instance_id");
-   $self->_do_request("PUT", "jiffyBoxes/$instance_id", status => "SHUTDOWN");
+  my $instance_id = $data{"instance_id"};
+  Rex::Logger::debug("Stopping instance $instance_id");
+  $self->_do_request("PUT", "jiffyBoxes/$instance_id", status => "SHUTDOWN");
 
-   my $sleep_countdown = 10;
-   sleep $sleep_countdown; # wait 10 seconds
+  my $sleep_countdown = 10;
+  sleep $sleep_countdown; # wait 10 seconds
 
-   my ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  my ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
 
-   while($data->{"state"} ne "STOPPED") {
-      Rex::Logger::debug("Waiting for instance to be stopped...");
-      ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
+  while($data->{"state"} ne "STOPPED") {
+    Rex::Logger::debug("Waiting for instance to be stopped...");
+    ($data) = grep { $_->{"id"} eq $instance_id } $self->list_instances();
 
-      sleep $sleep_countdown;
+    sleep $sleep_countdown;
 
-      --$sleep_countdown;
+    --$sleep_countdown;
 
-      if($sleep_countdown <= 3) {
-         $sleep_countdown = 7;
-      }
-   }
-  
-   return 1;
+    if($sleep_countdown <= 3) {
+      $sleep_countdown = 7;
+    }
+  }
+
+  return 1;
 }
 
 
 sub list_instances {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @ret;
-   my $data = $self->_do_request("GET", "jiffyBoxes");
+  my @ret;
+  my $data = $self->_do_request("GET", "jiffyBoxes");
 
-   for my $instance_id (keys %{$data->{"result"}}) {
-      my $state = $data->{"result"}->{$instance_id}->{"status"};
+  for my $instance_id (keys %{$data->{"result"}}) {
+    my $state = $data->{"result"}->{$instance_id}->{"status"};
 
-      if($state eq "READY") {
-         if($data->{"result"}->{$instance_id}->{"running"}) {
-            $state = "RUNNING";
-         }
-         else {
-            $state = "STOPPED";
-         }
+    if($state eq "READY") {
+      if($data->{"result"}->{$instance_id}->{"running"}) {
+        $state = "RUNNING";
       }
-
-      push(@ret, {
-         ip => $data->{"result"}->{$instance_id}->{"ips"}->{"public"}->[0],
-         id => $instance_id,
-         architecture => undef,
-         type => $data->{"result"}->{$instance_id}->{"plan"}->{"name"},
-         dns_name => "j$instance_id.servers.jiffybox.net",
-         state => $state,
-         __state => $data->{"result"}->{$instance_id}->{"status"}, 
-         launch_time => undef,
-         name => $data->{"result"}->{$instance_id}->{"name"},
-      });
-   }
-
-   return @ret;
+      else {
+        $state = "STOPPED";
+      }
+    }
+
+    push(@ret, {
+      ip => $data->{"result"}->{$instance_id}->{"ips"}->{"public"}->[0],
+      id => $instance_id,
+      architecture => undef,
+      type => $data->{"result"}->{$instance_id}->{"plan"}->{"name"},
+      dns_name => "j$instance_id.servers.jiffybox.net",
+      state => $state,
+      __state => $data->{"result"}->{$instance_id}->{"status"},
+      launch_time => undef,
+      name => $data->{"result"}->{$instance_id}->{"name"},
+    });
+  }
+
+  return @ret;
 }
 
 sub list_running_instances {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   return grep { $_->{"__state"} eq "READY" || $_->{"__state"} eq "UPDATING" } $self->list_instances();
+  return grep { $_->{"__state"} eq "READY" || $_->{"__state"} eq "UPDATING" } $self->list_instances();
 }
 
 
@@ -0,0 +1,365 @@
+#
+# (c) Ferenc Erki <erkiferenc@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+package Rex::Cloud::OpenStack;
+
+use strict;
+use warnings;
+
+use Rex::Logger;
+
+use base 'Rex::Cloud::Base';
+
+use HTTP::Request::Common qw(:DEFAULT DELETE);
+use JSON::XS;
+use LWP::UserAgent;
+use Data::Dumper;
+use Carp;
+
+sub new {
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
+
+  bless( $self, $proto );
+
+  $self->{_agent} = LWP::UserAgent->new;
+  $self->{_agent}->env_proxy;
+
+  return $self;
+}
+
+sub set_auth {
+  my ( $self, %auth ) = @_;
+
+  $self->{auth} = \%auth;
+}
+
+sub _request {
+  my ( $self, $method, $url, %params ) = @_;
+  my $response;
+
+  Rex::Logger::debug("Sending request to $url");
+  Rex::Logger::debug("  $_ => $params{$_}") for keys %params;
+
+  {
+    no strict 'refs';
+    $response = $self->{_agent}->request( $method->( $url, %params ) );
+  }
+
+  Rex::Logger::debug( Dumper($response) );
+
+  if ( $response->is_error ) {
+    Rex::Logger::info( 'Response indicates an error', 'warn' );
+    Rex::Logger::debug( $response->content );
+  }
+
+  return decode_json( $response->content ) if $response->content;
+}
+
+sub _authenticate {
+  my $self = shift;
+
+  my $auth_data = {
+    auth => {
+      tenantName => $self->{auth}{tenant_name} || '',
+      passwordCredentials => {
+        username => $self->{auth}{username},
+        password => $self->{auth}{password},
+      }
+    }
+  };
+
+  my $content = $self->_request(
+    POST         => $self->{__endpoint} . '/tokens',
+    content_type => 'application/json',
+    content      => encode_json($auth_data),
+  );
+
+  $self->{auth}{tokenId} = $content->{access}{token}{id};
+
+  $self->{_agent}->default_header( 'X-Auth-Token' => $self->{auth}{tokenId} );
+
+  $self->{_catalog} = $content->{access}{serviceCatalog};
+}
+
+sub get_nova_url {
+  my $self = shift;
+
+  $self->_authenticate unless $self->{auth}{tokenId};
+
+  my @nova_services =
+    grep { $_->{type} eq 'compute' } @{ $self->{_catalog} };
+
+  return $nova_services[0]{endpoints}[0]{publicURL};
+}
+
+sub get_cinder_url {
+  my $self = shift;
+
+  $self->_authenticate unless $self->{auth}{tokenId};
+
+  my @cinder_services =
+    grep { $_->{type} eq 'volume' } @{ $self->{_catalog} };
+  return $cinder_services[0]{endpoints}[0]{publicURL};
+}
+
+sub run_instance {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug('Trying to start a new instance with data:');
+  Rex::Logger::debug("  $_ => $data{$_}") for keys %data;
+
+  my $request_data = {
+    server => {
+      flavorRef => $data{plan_id},
+      imageRef  => $data{image_id},
+      name      => $data{name},
+    }
+  };
+
+  my $content = $self->_request(
+    POST         => $nova_url . '/servers',
+    content_type => 'application/json',
+    content      => encode_json($request_data),
+  );
+
+  my $id = $content->{server}{id};
+  my $info;
+
+  until ( ($info) = grep { $_->{id} eq $id } $self->list_running_instances ) {
+    Rex::Logger::debug('Waiting for instance to be created...');
+    sleep 1;
+  }
+
+  if ( exists $data{volume} ) {
+    $self->attach_volume(
+      instance_id => $id,
+      volume_id   => $data{volume},
+    );
+  }
+
+  return $info;
+}
+
+sub terminate_instance {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug("Terminating instance $data{instance_id}");
+
+  $self->_request( DELETE => $nova_url . '/servers/' . $data{instance_id} );
+
+  until ( !grep { $_->{id} eq $data{instance_id} }
+      $self->list_running_instances )
+  {
+    Rex::Logger::debug('Waiting for instance to be deleted...');
+    sleep 1;
+  }
+}
+
+sub list_instances {
+  my $self     = shift;
+  my $nova_url = $self->get_nova_url;
+  my @instances;
+
+  my $content = $self->_request( GET => $nova_url . '/servers/detail' );
+
+  for my $instance ( @{ $content->{servers} } ) {
+    push @instances,
+      {
+      ip           => $instance->{addresses}{public}[0]{addr},
+      id           => $instance->{id},
+      architecture => undef,
+      type         => $instance->{flavor}{id},
+      dns_name     => undef,
+      state   => ( $instance->{status} eq 'ACTIVE' ? 'running' : 'stopped' ),
+      __state => $instance->{status},
+      launch_time     => $instance->{'OS-SRV-USG:launched_at'},
+      name            => $instance->{name},
+      private_ip      => $instance->{addresses}{private}[0]{addr},
+      security_groups => join ',',
+      map { $_->{name} } @{ $instance->{security_groups} },
+      };
+  }
+
+  return @instances;
+}
+
+sub list_running_instances {
+  my $self = shift;
+
+  return grep { $_->{state} eq 'running' } $self->list_instances;
+}
+
+sub stop_instance {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug("Suspending instance $data{instance_id}");
+
+  $self->_request(
+    POST         => $nova_url . '/servers/' . $data{instance_id} . '/action',
+    content_type => 'application/json',
+    content      => encode_json( { suspend => 'null' } ),
+  );
+
+  while ( grep { $_->{id} eq $data{instance_id} }
+    $self->list_running_instances )
+  {
+    Rex::Logger::debug('Waiting for instance to be stopped...');
+    sleep 5;
+  }
+}
+
+sub start_instance {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug("Resuming instance $data{instance_id}");
+
+  $self->_request(
+    POST         => $nova_url . '/servers/' . $data{instance_id} . '/action',
+    content_type => 'application/json',
+    content      => encode_json( { resume => 'null' } ),
+  );
+
+  until ( grep { $_->{id} eq $data{instance_id} }
+      $self->list_running_instances )
+  {
+    Rex::Logger::debug('Waiting for instance to be started...');
+    sleep 5;
+  }
+}
+
+sub list_flavors {
+  my $self     = shift;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug('Listing flavors');
+
+  $self->_request( GET => $nova_url . '/flavors' );
+}
+
+sub list_plans { return shift->list_flavors; }
+
+sub list_images {
+  my $self     = shift;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug('Listing images');
+
+  my $images = $self->_request( GET => $nova_url . '/images' );
+  confess "Error getting cloud images." if ( !exists $images->{images} );
+  return @{ $images->{images} };
+}
+
+sub create_volume {
+  my ( $self, %data ) = @_;
+  my $cinder_url = $self->get_cinder_url;
+
+  Rex::Logger::debug('Creating a new volume');
+
+  my $request_data = {
+    volume => {
+      size => $data{size} || 1,
+      availability_zone => $data{zone},
+    }
+  };
+
+  my $content = $self->_request(
+    POST         => $cinder_url . '/volumes',
+    content_type => 'application/json',
+    content      => encode_json($request_data),
+  );
+
+  my $id = $content->{volume}{id};
+
+  until ( grep { $_->{id} eq $id and $_->{status} eq 'available' }
+      $self->list_volumes )
+  {
+    Rex::Logger::debug('Waiting for volume to become available...');
+    sleep 1;
+  }
+
+  return $id;
+}
+
+sub delete_volume {
+  my ( $self, %data ) = @_;
+  my $cinder_url = $self->get_cinder_url;
+
+  Rex::Logger::debug('Trying to delete a volume');
+
+  $self->_request( DELETE => $cinder_url . '/volumes/' . $data{volume_id} );
+
+  until ( !grep { $_->{id} eq $data{volume_id} } $self->list_volumes ) {
+    Rex::Logger::debug('Waiting for volume to be delete...');
+    sleep 1;
+  }
+
+}
+
+sub list_volumes {
+  my $self       = shift;
+  my $cinder_url = $self->get_cinder_url;
+  my @volumes;
+
+  my $content = $self->_request( GET => $cinder_url . '/volumes' );
+
+  for my $volume ( @{ $content->{volumes} } ) {
+    push @volumes,
+      {
+      id          => $volume->{id},
+      status      => $volume->{status},
+      zone        => $volume->{availability_zone},
+      size        => $volume->{size},
+      attached_to => join ',',
+      map { $_->{server_id} } @{ $volume->{attachments} },
+      };
+  }
+
+  return @volumes;
+}
+
+sub attach_volume {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug('Trying to attach a new volume');
+
+  my $request_data = {
+    volumeAttachment => {
+      volumeId => $data{volume_id},
+      name     => $data{name},
+    }
+  };
+
+  $self->_request(
+    POST => $nova_url
+      . '/servers/'
+      . $data{instance_id}
+      . '/os-volume_attachments',
+    content_type => 'application/json',
+    content      => encode_json($request_data),
+  );
+}
+
+sub detach_volume {
+  my ( $self, %data ) = @_;
+  my $nova_url = $self->get_nova_url;
+
+  Rex::Logger::debug('Trying to detach a volume');
+
+  $self->_request( DELETE => $nova_url
+      . '/servers/'
+      . $data{instance_id}
+      . '/os-volume_attachments/'
+      . $data{volume_id} );
+}
+
+1;
@@ -1,60 +1,60 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Cloud;
-   
+  
 use strict;
 use warnings;
-   
+  
 require Exporter;
 use base qw(Exporter);
 use vars qw(@EXPORT);
 
 use Rex::Logger;
-    
+   
 @EXPORT = qw(get_cloud_service);
 
 my %CLOUD_SERVICE;
 
 sub register_cloud_service {
-   my ($class, $service_name, $service_class) = @_;
-   $CLOUD_SERVICE{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $CLOUD_SERVICE{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub register_cloud_provider {
-   my $class = shift;
-   $class->register_cloud_service(@_);
+  my $class = shift;
+  $class->register_cloud_service(@_);
 }
 
 sub get_cloud_service {
 
-   my ($service) = @_;
+  my ($service) = @_;
 
-   if(exists $CLOUD_SERVICE{"\L$service"}) {
-      eval "use " . $CLOUD_SERVICE{"\L$service"};
+  if(exists $CLOUD_SERVICE{"\L$service"}) {
+    eval "use " . $CLOUD_SERVICE{"\L$service"};
 
-      my $mod = $CLOUD_SERVICE{"\L$service"};
-      return $mod->new;
-   }
-   else {
-      eval "use Rex::Cloud::$service";
+    my $mod = $CLOUD_SERVICE{"\L$service"};
+    return $mod->new;
+  }
+  else {
+    eval "use Rex::Cloud::$service";
 
-      if($@) {
-         Rex::Logger::info("Cloud Service $service not supported.");
-         Rex::Logger::info($@);
-         return 0;
-      }
+    if($@) {
+      Rex::Logger::info("Cloud Service $service not supported.");
+      Rex::Logger::info($@);
+      return 0;
+    }
 
-      my $mod = "Rex::Cloud::$service";
-      return $mod->new;
-   }
+    my $mod = "Rex::Cloud::$service";
+    return $mod->new;
+  }
 
   
 
 }
-   
+  
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 =head1 NAME
 
 Rex::Commands::Box - Functions / Class to manage Virtual Machines
@@ -15,40 +15,40 @@ This is a Module to manage Virtual Machines or Cloud Instances in a simple way.
 =head1 SYNOPSIS
 
  use Rex::Commands::Box;
-    
- set box => "VBox";
    
+ set box => "VBox";
+  
  group all_my_boxes => map { get_box($_->{name})->{ip} } list_boxes;
-   
+  
  task mytask => sub {
-    
-    box {
-       my ($box) = @_;
-       $box->name("boxname");
-       $box->url("http://box.rexify.org/box/base-image.box");
-          
-       $box->network(1 => {
-         type => "nat",
-       });
-           
-       $box->network(1 => {
-         type => "bridged",
-         bridge => "eth0",
-       });
-          
-       $box->forward_port(ssh => [2222, 22]);
-          
-       $box->share_folder(myhome => "/home/myuser");
-          
-       $box->auth(
-         user => "root",
-         password => "box",
-       );
-         
-       $box->setup(qw/task_to_customize_box/);
+   
+   box {
+     my ($box) = @_;
+     $box->name("boxname");
+     $box->url("http://box.rexify.org/box/base-image.box");
        
-    };
-    
+     $box->network(1 => {
+      type => "nat",
+     });
+        
+     $box->network(1 => {
+      type => "bridged",
+      bridge => "eth0",
+     });
+       
+     $box->forward_port(ssh => [2222, 22]);
+       
+     $box->share_folder(myhome => "/home/myuser");
+       
+     $box->auth(
+      user => "root",
+      password => "box",
+     );
+      
+     $box->setup(qw/task_to_customize_box/);
+     
+   };
+   
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -87,15 +87,15 @@ use Rex::Box;
 @EXPORT = qw(box list_boxes get_box boxes);
 
 Rex::Config->register_set_handler("box", sub {
-   my ($type, @data) = @_;
-   Rex::Config->set("box_type", $type);
-
-   if(ref($data[0])) {
-      Rex::Config->set("box_options", $data[0]);
-   }
-   else {
-      Rex::Config->set("box_options", { @data });
-   }
+  my ($type, @data) = @_;
+  Rex::Config->set("box_type", $type);
+
+  if(ref($data[0])) {
+    Rex::Config->set("box_options", $data[0]);
+  }
+  else {
+    Rex::Config->set("box_options", { @data });
+  }
 });
 
 
@@ -109,8 +109,8 @@ Constructor if used in OO mode.
 =cut
 
 sub new {
-   my $class = shift;
-   return Rex::Box->create(@_);
+  my $class = shift;
+  return Rex::Box->create(@_);
 }
 
 =item box(sub {})
@@ -118,56 +118,56 @@ sub new {
 With this function you can create a new Rex/Box. The first parameter of this function is the Box object. With this object you can define your box.
 
  box {
-    my ($box) = @_;
-    $box->name("boxname");
-    $box->url("http://box.rexify.org/box/base-image.box");
-       
-    $box->network(1 => {
-      type => "nat",
-    });
-        
-    $box->network(1 => {
-      type => "bridged",
-      bridge => "eth0",
-    });
-       
-    $box->forward_port(ssh => [2222, 22]);
-       
-    $box->share_folder(myhome => "/home/myuser");
-       
-    $box->auth(
-      user => "root",
-      password => "box",
-    );
+   my ($box) = @_;
+   $box->name("boxname");
+   $box->url("http://box.rexify.org/box/base-image.box");
+     
+   $box->network(1 => {
+    type => "nat",
+   });
       
-    $box->setup(qw/task_to_customize_box/);
+   $box->network(1 => {
+    type => "bridged",
+    bridge => "eth0",
+   });
+     
+   $box->forward_port(ssh => [2222, 22]);
+     
+   $box->share_folder(myhome => "/home/myuser");
+     
+   $box->auth(
+    user => "root",
+    password => "box",
+   );
+    
+   $box->setup(qw/task_to_customize_box/);
  };
  
 
 =cut
 
 sub box(&) {
-   my $code = shift;
+  my $code = shift;
 
-   #### too much black magic...
-   #my ($caller_box) = do {
-   #   my $pkg = caller();
-   #   no strict 'refs';
-   #   \*{ $pkg . "::box" };
-   #};
+  #### too much black magic...
+  #my ($caller_box) = do {
+  #  my $pkg = caller();
+  #  no strict 'refs';
+  #  \*{ $pkg . "::box" };
+  #};
 
-   my $self = Rex::Box->create;
+  my $self = Rex::Box->create;
 
-   #local( *$caller_box );
-   #*$caller_box = \$self;
+  #local( *$caller_box );
+  #*$caller_box = \$self;
 
-   $code->($self);
+  $code->($self);
 
-   #*$caller_box = \{}; # undef $box
+  #*$caller_box = \{}; # undef $box
 
-   $self->import_vm();
+  $self->import_vm();
 
-   $self->provision_vm();
+  $self->provision_vm();
 }
 
 =item list_boxes
@@ -176,42 +176,42 @@ This function returns an array of hashes containing all information that can be
 
  use Data::Dumper;
  task "get_infos", sub {
-    my @all_boxes = list_boxes;
-    print Dumper(\@all_boxes);
+   my @all_boxes = list_boxes;
+   print Dumper(\@all_boxes);
  };
 
 =cut
 sub list_boxes {
-   my $ref = LOCAL {
-      my $box = Rex::Box->create;
-      my @ret = $box->list_boxes;
-
-      if( -f ".box.cache") {
-         my $yaml_str = eval { local(@ARGV, $/) = (".box.cache"); <>; };
-         $yaml_str .= "\n";
-         my $yaml_ref = Load($yaml_str);
-         
-         for my $box (keys %{ $yaml_ref }) {
-            my ($found_box) = grep { $_->{name} eq $box } @ret;
-            if(! $found_box) {
-               $yaml_ref->{$box} = undef;
-               delete $yaml_ref->{$box};
-            }
-         }
-
-         open(my $fh, ">", ".box.cache") or die($!);
-         print $fh Dump($yaml_ref);
-         close($fh);
-      }
+  my $ref = LOCAL {
+    my $box = Rex::Box->create;
+    my @ret = $box->list_boxes;
 
-      if(wantarray) {
-         return @ret;
+    if( -f ".box.cache") {
+      my $yaml_str = eval { local(@ARGV, $/) = (".box.cache"); <>; };
+      $yaml_str .= "\n";
+      my $yaml_ref = Load($yaml_str);
+      
+      for my $box (keys %{ $yaml_ref }) {
+        my ($found_box) = grep { $_->{name} eq $box } @ret;
+        if(! $found_box) {
+          $yaml_ref->{$box} = undef;
+          delete $yaml_ref->{$box};
+        }
       }
 
-      return \@ret;
-   };
+      open(my $fh, ">", ".box.cache") or die($!);
+      print $fh Dump($yaml_ref);
+      close($fh);
+    }
+
+    if(wantarray) {
+      return @ret;
+    }
+
+    return \@ret;
+  };
 
-   return @{ $ref };
+  return @{ $ref };
 }
 
 =item get_box($box_name)
@@ -220,76 +220,76 @@ This function tries to gather all information of a Rex/Box. This function also s
 
  use Data::Dumper;
  task "get_box_info", sub {
-    my $data = get_box($box_name);
-    print Dumper($data);
+   my $data = get_box($box_name);
+   print Dumper($data);
  };
 
 =cut
 sub get_box {
-   my ($box_name) = @_;
+  my ($box_name) = @_;
 
-   return LOCAL {
-      my $box = Rex::Box->create(name => $box_name);
-      $box->info;
+  return LOCAL {
+    my $box = Rex::Box->create(name => $box_name);
+    $box->info;
 
-      if($box->status eq "stopped") {
-         $box->start;
-         $box->wait_for_ssh;
-      }
+    if($box->status eq "stopped") {
+      $box->start;
+      $box->wait_for_ssh;
+    }
 
-      if( -f ".box.cache") {
-         Rex::Logger::debug("Loading box information of cache file: .box.cache.");
-         my $yaml_str = eval { local(@ARGV, $/) = (".box.cache"); <>; };
-         $yaml_str .= "\n";
-         my $yaml_ref = Load($yaml_str);
-         %vm_infos = %{ $yaml_ref };
-      }
+    if( -f ".box.cache") {
+      Rex::Logger::debug("Loading box information of cache file: .box.cache.");
+      my $yaml_str = eval { local(@ARGV, $/) = (".box.cache"); <>; };
+      $yaml_str .= "\n";
+      my $yaml_ref = Load($yaml_str);
+      %vm_infos = %{ $yaml_ref };
+    }
 
-      if(exists $vm_infos{$box_name}) {
-         return $vm_infos{$box_name};
+    if(exists $vm_infos{$box_name}) {
+      return $vm_infos{$box_name};
+    }
+
+    my $pid = fork;
+    if($pid == 0) {
+      print "Gathering system information from $box_name.\nThis may take a while..";
+      while(1) {
+        print ".";
+        sleep 1;
       }
 
-      my $pid = fork;
-      if($pid == 0) {
-         print "Gathering system information from $box_name.\nThis may take a while..";
-         while(1) {
-            print ".";
-            sleep 1;
-         }
+      CORE::exit;
+    }
 
-         CORE::exit;
-      }
+    my $old_q = $::QUIET;
+    $::QUIET = 1;
 
-      my $old_q = $::QUIET;
-      $::QUIET = 1;
-
-      eval {
-         $vm_infos{$box_name} = run_task "get_sys_info", on => $box->ip;
-      } or do {
-         $::QUIET = $old_q;
-         print STDERR "\n";
-         Rex::Logger::info("There was an error connecting to your Box. Please verify the login credentials.", "warn");
-         Rex::Logger::debug("You have to define login credentials before calling get_box()");
-         # cleanup
-         kill 9, $pid;
-         CORE::exit(1);
-      };
+    eval {
+      $vm_infos{$box_name} = run_task "get_sys_info", on => $box->ip;
+    } or do {
       $::QUIET = $old_q;
+      print STDERR "\n";
+      Rex::Logger::info("There was an error connecting to your Box. Please verify the login credentials.", "warn");
+      Rex::Logger::debug("You have to define login credentials before calling get_box()");
+      # cleanup
+      kill 9, $pid;
+      CORE::exit(1);
+    };
+    $::QUIET = $old_q;
 
-      my $box_info = $box->info;
-      for my $key (keys %{ $box_info }) {
-         $vm_infos{$box_name}->{$key} = $box_info->{$key};
-      }
+    my $box_info = $box->info;
+    for my $key (keys %{ $box_info }) {
+      $vm_infos{$box_name}->{$key} = $box_info->{$key};
+    }
 
-      kill 9, $pid;
-      print "\n";
+    kill 9, $pid;
+    print "\n";
 
-      open(my $fh, ">", ".box.cache") or die($!);
-      print $fh Dump(\%vm_infos);
-      close($fh);
+    open(my $fh, ">", ".box.cache") or die($!);
+    print $fh Dump(\%vm_infos);
+    close($fh);
 
-      return $vm_infos{$box_name};
-   };
+    return $vm_infos{$box_name};
+  };
 
 }
 
@@ -304,7 +304,7 @@ With this function you can control your boxes. Currently there are 3 actions.
 This action can only  be used if you're using a YAML file to describe your Rex/Boxes.
 
  task "prepare_boxes", sub {
-    boxes "init";
+   boxes "init";
  };
 
 =item start
@@ -312,7 +312,7 @@ This action can only  be used if you're using a YAML file to describe your Rex/B
 This action start one or more Rex/Boxes.
 
  task "start_boxes", sub {
-    boxes "start", "box1", "box2";
+   boxes "start", "box1", "box2";
  };
 
 =item stop
@@ -320,119 +320,119 @@ This action start one or more Rex/Boxes.
 This action stop one or more Rex/Boxes.
 
  task "stop_boxes", sub {
-    boxes "stop", "box1", "box2";
+   boxes "stop", "box1", "box2";
  };
 
 =back
 
 =cut
 sub boxes {
-   my ($action, @data) = @_;
+  my ($action, @data) = @_;
 
-   if(substr($action, 0, 1) eq "-") {
-      $action = substr($action, 1);
-   }
+  if(substr($action, 0, 1) eq "-") {
+    $action = substr($action, 1);
+  }
 
-   if($action eq "init") {
+  if($action eq "init") {
 
-      if(-f ".box.cache") {
-         unlink ".box.cache";
-      }
+    if(-f ".box.cache") {
+      unlink ".box.cache";
+    }
 
-      my $yaml_ref = $VM_STRUCT;
+    my $yaml_ref = $VM_STRUCT;
 
-      my @vms;
+    my @vms;
 
-      if(ref $yaml_ref->{vms} eq "HASH") {
-         for my $vm (keys %{ $yaml_ref->{vms} }) {
-            push(@vms, {
-               name => $vm,
-               %{ $yaml_ref->{vms}->{$vm} }
-            });
-         }
+    if(ref $yaml_ref->{vms} eq "HASH") {
+      for my $vm (keys %{ $yaml_ref->{vms} }) {
+        push(@vms, {
+          name => $vm,
+          %{ $yaml_ref->{vms}->{$vm} }
+        });
       }
-      else {
-         @vms = @{ $yaml_ref->{vms} };
-      }
-
-      for my $vm_ref (@vms) {
-         my $vm = $vm_ref->{name};
-         box {
-            my ($box) = @_;
-
-            $box->name($vm);
-
-            for my $key (keys %{ $vm_ref }) {
-               if(ref($vm_ref->{$key}) eq "HASH") {
-                  $box->$key(%{ $vm_ref->{$key} });
-               }
-               elsif(ref($vm_ref->{$key}) eq "ARRAY") {
-                  $box->$key(@{ $vm_ref->{$key} });
-               }
-               else {
-                  $box->$key($vm_ref->{$key});
-               }
-            }
-         };
-      }
-   }
-
-   if($action eq "stop") {
-      for my $box (@data) {
-         my $o = Rex::Commands::Box->new(name => $box);
-         $o->stop;
-      }
-   }
-
-   if($action eq "start") {
-      for my $box (@data) {
-         my $o = Rex::Commands::Box->new(name => $box);
-         $o->start;
-      }
-   }
+    }
+    else {
+      @vms = @{ $yaml_ref->{vms} };
+    }
+
+    for my $vm_ref (@vms) {
+      my $vm = $vm_ref->{name};
+      box {
+        my ($box) = @_;
+
+        $box->name($vm);
+
+        for my $key (keys %{ $vm_ref }) {
+          if(ref($vm_ref->{$key}) eq "HASH") {
+            $box->$key(%{ $vm_ref->{$key} });
+          }
+          elsif(ref($vm_ref->{$key}) eq "ARRAY") {
+            $box->$key(@{ $vm_ref->{$key} });
+          }
+          else {
+            $box->$key($vm_ref->{$key});
+          }
+        }
+      };
+    }
+  }
+
+  if($action eq "stop") {
+    for my $box (@data) {
+      my $o = Rex::Commands::Box->new(name => $box);
+      $o->stop;
+    }
+  }
+
+  if($action eq "start") {
+    for my $box (@data) {
+      my $o = Rex::Commands::Box->new(name => $box);
+      $o->start;
+    }
+  }
 
 }
 
 Rex::TaskList->create()->create_task("get_sys_info", sub {
-   return { get_system_information() };
+  return { get_system_information() };
 }, { dont_register => 1, exit_on_connect_fail => 0 });
 
 sub import {
-   my ($class, %option) = @_;
+  my ($class, %option) = @_;
 
-   if($option{init_file}) {
-      my $file = $option{init_file};
+  if($option{init_file}) {
+    my $file = $option{init_file};
 
-      if(! -f $file) {
-         die("Error: Wrong configuration file: $file.");
-      }
+    if(! -f $file) {
+      die("Error: Wrong configuration file: $file.");
+    }
 
-      my $yaml_str = eval { local(@ARGV, $/) = ($file); <>; };
-      $yaml_str .= "\n";
+    my $yaml_str = eval { local(@ARGV, $/) = ($file); <>; };
+    $yaml_str .= "\n";
 
-      my $yaml_ref = Load($yaml_str);
+    my $yaml_ref = Load($yaml_str);
 
-      if(! exists $yaml_ref->{type}) {
-         die("You have to define a type.");
-      }
+    if(! exists $yaml_ref->{type}) {
+      die("You have to define a type.");
+    }
 
-      my $type = ucfirst $yaml_ref->{type};
-      set box_type => $type;
+    my $type = ucfirst $yaml_ref->{type};
+    set box_type => $type;
 
-      # set special box options, like amazon out
-      if(exists $yaml_ref->{"\L$type"}) {
-         set box_options => $yaml_ref->{"\L$type"};
-      }
-      elsif(exists $yaml_ref->{$type}) {
-         set box_options => $yaml_ref->{$type};
-      }
+    # set special box options, like amazon out
+    if(exists $yaml_ref->{"\L$type"}) {
+      set box_options => $yaml_ref->{"\L$type"};
+    }
+    elsif(exists $yaml_ref->{$type}) {
+      set box_options => $yaml_ref->{$type};
+    }
 
-      $VM_STRUCT = $yaml_ref;
+    $VM_STRUCT = $yaml_ref;
 
-      @_ = ($class);
-   }
+    @_ = ($class);
+  }
 
-   __PACKAGE__->export_to_level(1, @_);
+  __PACKAGE__->export_to_level(1, @_);
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -10,38 +10,38 @@ Rex::Commands::Cloud - Cloud Management Commands
 
 =head1 DESCRIPTION
 
-With this Module you can manage different Cloud services. Currently it supports Amazon EC2 and Jiffybox.
+With this Module you can manage different Cloud services. Currently it supports Amazon EC2, Jiffybox and OpenStack.
 
 =head1 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;
+   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",
-       };
+   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";
+   cloud_volume detach => "vol-xxxxxxx";
+   cloud_volume delete => "vol-xxxxxxx";
+ 
+   cloud_instance terminate => "i-xxxxxxx";
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -51,10 +51,10 @@ With this Module you can manage different Cloud services. Currently it supports
 =cut
 
 package Rex::Commands::Cloud;
-   
+
 use strict;
 use warnings;
-   
+
 require Rex::Exporter;
 use base qw(Rex::Exporter);
 use vars qw(@EXPORT $cloud_service $cloud_region @cloud_auth);
@@ -63,29 +63,30 @@ use Rex::Logger;
 use Rex::Config;
 use Rex::Cloud;
 use Rex::Group::Entry::Server;
-    
-@EXPORT = qw(cloud_instance cloud_volume 
-               cloud_instance_list cloud_volume_list
-               cloud_service cloud_auth cloud_region 
-               get_cloud_instances_as_group get_cloud_regions get_cloud_availability_zones
-               get_cloud_plans
-               get_cloud_operating_systems);
+
+@EXPORT = qw(cloud_instance cloud_volume cloud_network
+          cloud_instance_list cloud_volume_list cloud_network_list
+          cloud_service cloud_auth cloud_region
+          get_cloud_instances_as_group get_cloud_regions get_cloud_availability_zones
+          get_cloud_plans
+          get_cloud_operating_systems
+          cloud_image_list);
 
 Rex::Config->register_set_handler("cloud" => sub {
-   my ($name, @options) = @_;
-   my $sub_name = "cloud_$name";
+  my ($name, @options) = @_;
+  my $sub_name = "cloud_$name";
 
-   if($name eq "service") {
-      cloud_service(@options);
-   }
+  if($name eq "service") {
+    cloud_service(@options);
+  }
 
-   if($name eq "auth") {
-      cloud_auth(@options);
-   }
+  if($name eq "auth") {
+    cloud_auth(@options);
+  }
 
-   if($name eq "region") {
-      cloud_region(@options);
-   }
+  if($name eq "region") {
+    cloud_region(@options);
+  }
 });
 
 =item cloud_service($cloud_service)
@@ -102,6 +103,8 @@ Define which cloud service to use.
 
 =item Jiffybox
 
+=item OpenStack
+
 =back
 
 =back
@@ -109,12 +112,12 @@ Define which cloud service to use.
 
 =cut
 sub cloud_service {
-   ($cloud_service) = @_;
+  ($cloud_service) = @_;
 
-   # set retry counter to a higher value
-   if(Rex::Config->get_max_connect_fails() < 5) {
-      Rex::Config->set_max_connect_fails(15);
-   }
+  # set retry counter to a higher value
+  if(Rex::Config->get_max_connect_fails() < 5) {
+    Rex::Config->set_max_connect_fails(15);
+  }
 }
 
 
@@ -130,9 +133,17 @@ For JiffyBox:
 
  cloud_auth($auth_key);
 
+For OpenStack:
+
+ cloud_auth(
+  tenantName => 'tenant',
+  username   => 'user',
+  password   => 'password',
+ );
+
 =cut
 sub cloud_auth {
-   @cloud_auth = @_;
+  @cloud_auth = @_;
 }
 
 =item cloud_region($region)
@@ -142,7 +153,7 @@ Set the cloud region.
 =cut
 
 sub cloud_region {
-   ($cloud_region) = @_;
+  ($cloud_region) = @_;
 }
 
 =item cloud_instance_list
@@ -150,23 +161,23 @@ sub cloud_region {
 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"};
-    }
+   for my $instance (cloud_instance_list()) {
+     say "Arch  : " . $instance->{"architecture"};
+     say "IP   : " . $instance->{"ip"};
+     say "ID   : " . $instance->{"id"};
+     say "State : " . $instance->{"state"};
+   }
  };
 
 =cut
 
 sub cloud_instance_list {
 
-   my $cloud = get_cloud_service($cloud_service);
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  my $cloud = get_cloud_service($cloud_service);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   return $cloud->list_instances();
+  return $cloud->list_instances();
 
 }
 
@@ -175,26 +186,62 @@ sub cloud_instance_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"};
-    }
+   for my $volume (cloud_volume_list()) {
+     say "ID     : " . $volume->{"id"};
+     say "Zone    : " . $volume->{"zone"};
+     say "State   : " . $volume->{"state"};
+     say "Attached : " . $volume->{"attached_to"};
+   }
  };
 
 =cut
 
 sub cloud_volume_list {
-   
-   my $cloud = get_cloud_service($cloud_service);
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
 
-   return $cloud->list_volumes();
+  my $cloud = get_cloud_service($cloud_service);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
+
+  return $cloud->list_volumes();
+
+}
+
+=item 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};
+   }
+ };
+
+=cut
+sub cloud_network_list {
+
+  my $cloud = get_cloud_service($cloud_service);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
+
+  return $cloud->list_networks();
 
 }
 
+=item cloud_image_list
+
+Get a list of all available cloud images.
+
+=cut
+sub cloud_image_list {
+  my $cloud = get_cloud_service($cloud_service);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
+
+  return $cloud->list_images();
+}
+
 =item get_cloud_instances_as_group
 
 Get a list of all running instances of a cloud service. This can be used for a I<group> definition.
@@ -205,23 +252,23 @@ Get a list of all running instances of a cloud service. This can be used for a I
 =cut
 
 sub get_cloud_instances_as_group {
-   
-   # return funcRef
-   return sub {
-      my $cloud = get_cloud_service($cloud_service);
-      $cloud->set_auth(@cloud_auth);
-      $cloud->set_endpoint($cloud_region);
 
-      my @list = $cloud->list_running_instances();
+  # return funcRef
+  return sub {
+    my $cloud = get_cloud_service($cloud_service);
+    $cloud->set_auth(@cloud_auth);
+    $cloud->set_endpoint($cloud_region);
 
-      my @ret;
+    my @list = $cloud->list_running_instances();
 
-      for my $instance (@list) {
-         push(@ret, Rex::Group::Entry::Server->new(name => $instance->{"ip"}));
-      }
+    my @ret;
 
-      return @ret;
-   };
+    for my $instance (@list) {
+      push(@ret, Rex::Group::Entry::Server->new(name => $instance->{"ip"}));
+    }
+
+    return @ret;
+  };
 
 }
 
@@ -233,46 +280,46 @@ This function controlls all aspects of a cloud instance.
 
 sub cloud_instance {
 
-   my ($action, $data) = @_;
-   my $cloud = get_cloud_service($cloud_service);
+  my ($action, $data) = @_;
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   if($action eq "list") {
-      return $cloud->list_running_instances();
-   }
+  if($action eq "list") {
+    return $cloud->list_running_instances();
+  }
 
 =item 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
-    };
+     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
+   };
 
 =cut
 
-   elsif($action eq "create") {
-      my %data_hash = (
-         image_id => $data->{"image_id"},
-         name     => $data->{"name"} || undef,
-         key      => $data->{"key"} || undef,
-         zone     => $data->{"zone"} || undef,
-         volume   => $data->{"volume"} || undef,
-         password => $data->{"password"} || undef,
-         plan_id  => $data->{"plan_id"} || undef,
-         type     => $data->{"type"} || undef,
-         security_group => $data->{"security_group"} || undef,
-         %{ $data },
-      );
-
-      $cloud->run_instance(%data_hash);
-   }
+  elsif($action eq "create") {
+    my %data_hash = (
+      # image_id => $data->{"image_id"},
+      # name    => $data->{"name"} || undef,
+      # key    => $data->{"key"} || undef,
+      # zone    => $data->{"zone"} || undef,
+      # volume  => $data->{"volume"} || undef,
+      # password => $data->{"password"} || undef,
+      # plan_id  => $data->{"plan_id"} || undef,
+      # type    => $data->{"type"} || undef,
+      # security_group => $data->{"security_group"} || undef,
+      %{ $data },
+    );
+
+    $cloud->run_instance(%data_hash);
+  }
 
 =item start
 
@@ -282,9 +329,9 @@ Start an existing instance
 
 =cut
 
-   elsif($action eq "start") {
-      $cloud->start_instance(instance_id => $data);
-   }
+  elsif($action eq "start") {
+    $cloud->start_instance(instance_id => $data);
+  }
 
 =item stop
 
@@ -294,9 +341,9 @@ Stop an existing instance
 
 =cut
 
-   elsif($action eq "stop") {
-      $cloud->stop_instance(instance_id => $data);
-   }
+  elsif($action eq "stop") {
+    $cloud->stop_instance(instance_id => $data);
+  }
 
 =item terminate
 
@@ -306,9 +353,9 @@ Terminate an instance. This will destroy all data and remove the instance.
 
 =cut
 
-   elsif($action eq "terminate") {
-      $cloud->terminate_instance(instance_id => $data);
-   }
+  elsif($action eq "terminate") {
+    $cloud->terminate_instance(instance_id => $data);
+  }
 
 }
 
@@ -320,12 +367,12 @@ Returns all regions as an array.
 
 sub get_cloud_regions {
 
-   my $cloud = get_cloud_service($cloud_service);
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   return $cloud->get_regions;
+  return $cloud->get_regions;
 }
 
 =item cloud_volume($action , $data)
@@ -336,11 +383,11 @@ This function controlls all aspects of a cloud volume.
 
 sub cloud_volume {
 
-   my ($action, $data) = @_;
-   my $cloud = get_cloud_service($cloud_service);
+  my ($action, $data) = @_;
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
 
 =item create
@@ -348,61 +395,103 @@ sub cloud_volume {
 Create a new volume. Size is in Gigabytes.
 
  task "create-vol", sub {
-    my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };
+   my $vol_id = cloud_volume create => { size => 1, zone => "eu-west-1a", };
  };
 
 =cut
 
-   if($action eq "create") {
-      $cloud->create_volume(
-                        size => $data->{"size"} || 1,
-                        zone => $data->{"zone"} || undef,
-                     );
-   }
+  if($action eq "create") {
+    $cloud->create_volume(
+                size => $data->{"size"} || 1,
+                zone => $data->{"zone"} || undef,
+              );
+  }
 
 =item detach
 
 Detach a volume from an instance.
 
  task "detach-vol", sub {
-    cloud_volume detach => "vol-xxxxxx";
+   cloud_volume detach => "vol-xxxxxx";
  };
 
 =cut
 
-   elsif($action eq "detach") {
-      my $vol_id;
+  elsif($action eq "detach") {
+    my $vol_id;
 
-      if(ref($data)) {
-         $vol_id = $data->{"id"};
-      }
-      else {
-         $vol_id = $data;
-      }
+    if(ref($data)) {
+      $vol_id = $data->{"id"};
+    }
+    else {
+      $vol_id = $data;
+    }
 
-      $cloud->detach_volume(
-         volume_id => $vol_id,
-      );
-   }
+    $cloud->detach_volume(
+      volume_id => $vol_id,
+    );
+  }
 
 =item delete
 
 Delete a volume. This will destroy all data.
 
  task "delete-vol", sub {
-    cloud_volume delete => "vol-xxxxxx";
+   cloud_volume delete => "vol-xxxxxx";
  };
 
 =cut
 
-   elsif($action eq "delete") {
-      $cloud->delete_volume(volume_id => $data);
-   }
+  elsif($action eq "delete") {
+    $cloud->delete_volume(volume_id => $data);
+  }
 
-   elsif($action eq "list") {
-      return $cloud->list_volumes();
-   }
+  elsif($action eq "list") {
+    return $cloud->list_volumes();
+  }
+
+}
+
+=item cloud_network
+
+=cut
+
+sub cloud_network {
+
+  my ($action, $data) = @_;
+  my $cloud = get_cloud_service($cloud_service);
+
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
+
+
+=item create
+
+Create a new network.
+
+ task "create-net", sub {
+   my $net_id = cloud_network create => { cidr => '192.168.0.0/24', name => "mynetwork", };
+ };
+
+=cut
+
+  if($action eq "create") {
+    $cloud->create_network(%{ $data });
+  }
+
+=item delete
+
+Delete a network.
+
+ task "delete-net", sub {
+   cloud_network delete => '18a4ccf8-f14a-a10d-1af4-4ac7fee08a81';
+ };
+
+=cut
 
+  elsif($action eq "delete") {
+    $cloud->delete_network($data);
+  }
 }
 
 =item get_cloud_availability_zones
@@ -410,19 +499,19 @@ Delete a volume. This will destroy all data.
 Returns all availability zones of a cloud services. If available.
 
  task "get-zones", sub {
-    print Dumper get_cloud_availability_zones;
+   print Dumper get_cloud_availability_zones;
  };
 
 =cut
 
 sub get_cloud_availability_zones {
 
-   my $cloud = get_cloud_service($cloud_service);
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   return $cloud->get_availability_zones();
+  return $cloud->get_availability_zones();
 
 }
 
@@ -432,12 +521,12 @@ Retrieve information of the available cloud plans. If supported.
 
 =cut
 sub get_cloud_plans {
-   my $cloud = get_cloud_service($cloud_service);
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   return $cloud->list_plans;
+  return $cloud->list_plans;
 }
 
 =item get_cloud_operating_systems
@@ -446,12 +535,12 @@ Retrieve information of the available cloud plans. If supported.
 
 =cut
 sub get_cloud_operating_systems {
-   my $cloud = get_cloud_service($cloud_service);
+  my $cloud = get_cloud_service($cloud_service);
 
-   $cloud->set_auth(@cloud_auth);
-   $cloud->set_endpoint($cloud_region);
+  $cloud->set_auth(@cloud_auth);
+  $cloud->set_endpoint($cloud_region);
 
-   return $cloud->list_operating_systems;
+  return $cloud->list_operating_systems;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,18 +15,18 @@ With this Module you can manage your cronjobs.
 =head1 SYNOPSIS
 
  use Rex::Commands::Cron;
-     
+    
  cron add => "root", {
-            minute => '5',
-            hour   => '*',
-            day_of_month    => '*',
-            month => '*',
-            day_of_week => '*',
-            command => '/path/to/your/cronjob',
-         };
-           
+        minute => '5',
+        hour  => '*',
+        day_of_month   => '*',
+        month => '*',
+        day_of_week => '*',
+        command => '/path/to/your/cronjob',
+      };
+        
  cron list => "root";
-      
+    
  cron delete => "root", 3;
 
 =head1 EXPORTED FUNCTIONS
@@ -56,10 +56,10 @@ List cronjobs.
 
  use Rex::Commands::Cron;
  use Data::Dumper;
-    
+   
  task "listcron", "server1", sub {
-    my @crons = cron list => "root";
-    print Dumper(\@crons);
+   my @crons = cron list => "root";
+   print Dumper(\@crons);
  };
 
 Add a cronjob.
@@ -68,25 +68,25 @@ This example will add a cronjob running on minute 1, 5, 19 and 40. Every hour an
 
  use Rex::Commands::Cron;
  use Data::Dumper;
-    
+   
  task "addcron", "server1", sub {
-     cron add => "root", {
-        minute => "1,5,19,40",
-        command => '/path/to/your/cronjob',
-     };
+    cron add => "root", {
+      minute => "1,5,19,40",
+      command => '/path/to/your/cronjob',
+    };
  };
 
 This example will add a cronjob only running on the 1st, 3rd and 5th day of a month. But only when these days are monday or wednesday. And only in January and May. To the 11th and 23th hour. And to the 1st and 5th minute.
 
  task "addcron", "server1", sub {
-     cron add => "root", {
-        minute => "1,5",
-        hour   => "11,23",
-        month  => "1,5",
-        day_of_week => "1,3",
-        day_of_month => "1,3,5",
-        command => '/path/to/your/cronjob',
-     };
+    cron add => "root", {
+      minute => "1,5",
+      hour  => "11,23",
+      month  => "1,5",
+      day_of_week => "1,3",
+      day_of_month => "1,3,5",
+      command => '/path/to/your/cronjob',
+    };
  };
 
 Delete a cronjob.
@@ -94,78 +94,78 @@ Delete a cronjob.
 This example will delete the 4th cronjob. It starts counting by zero (0).
 
  task "delcron", "server1", sub {
-     cron delete => "root", 3;
+    cron delete => "root", 3;
  };
 
 Managing Environment Variables inside cron.
 
  task "mycron", "server1", sub {
-     cron env => user => add => {
-        MYVAR => "foo",
-     };
-         
-     cron env => user => delete => $index;
-     cron env => user => delete => 1;
+    cron env => user => add => {
+      MYVAR => "foo",
+    };
       
-     cron env => user => "list";
+    cron env => user => delete => $index;
+    cron env => user => delete => 1;
+    
+    cron env => user => "list";
  };
 
 =cut
 
 sub cron {
 
-   my ($action, $user, $config, @more) = @_;
+  my ($action, $user, $config, @more) = @_;
 
-   my $c = Rex::Cron->create();
-   $c->read_user_cron($user); # this must always be the first action
+  my $c = Rex::Cron->create();
+  $c->read_user_cron($user); # this must always be the first action
 
-   if($action eq "list") {
-      return $c->list_jobs;
-   }
+  if($action eq "list") {
+    return $c->list_jobs;
+  }
 
-   elsif($action eq "add") {
-      if($c->add(%{ $config })) {
-         my $rnd_file = $c->write_cron;
-         $c->activate_user_cron($rnd_file, $user);
+  elsif($action eq "add") {
+    if($c->add(%{ $config })) {
+      my $rnd_file = $c->write_cron;
+      $c->activate_user_cron($rnd_file, $user);
+    }
+  }
+
+  elsif($action eq "delete") {
+    my $to_delete = $config;
+    $c->delete_job($to_delete);
+    my $rnd_file = $c->write_cron;
+    $c->activate_user_cron($rnd_file, $user);
+  }
+
+  elsif($action eq "env") {
+    my $env_action = $config;
+
+    if($env_action eq "add") {
+      my $data = shift @more;
+
+      for my $key (keys %{ $data }) {
+        $c->add_env(
+          $key => $data->{$key},
+        );
       }
-   }
 
-   elsif($action eq "delete") {
-      my $to_delete = $config;
-      $c->delete_job($to_delete);
       my $rnd_file = $c->write_cron;
       $c->activate_user_cron($rnd_file, $user);
-   }
-
-   elsif($action eq "env") {
-      my $env_action = $config;
-
-      if($env_action eq "add") {
-         my $data = shift @more;
-
-         for my $key (keys %{ $data }) {
-            $c->add_env(
-               $key => $data->{$key},
-            );
-         }
-
-         my $rnd_file = $c->write_cron;
-         $c->activate_user_cron($rnd_file, $user);
-      }
+    }
 
-      elsif($env_action eq "list") {
-         return $c->list_envs;
-      }
+    elsif($env_action eq "list") {
+      return $c->list_envs;
+    }
 
-      elsif($env_action eq "delete") {
-         my $num = shift @more;
-         $c->delete_env($num);
+    elsif($env_action eq "delete") {
+      my $num = shift @more;
+      $c->delete_env($num);
 
-         my $rnd_file = $c->write_cron;
-         $c->activate_user_cron($rnd_file, $user);
-      }
+      my $rnd_file = $c->write_cron;
+      $c->activate_user_cron($rnd_file, $user);
+    }
 
-   }
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,36 +15,36 @@ This module gives you simple access to a database. Currently I<select>, I<delete
 =head1 SYNOPSIS
 
  use Rex::Commands::DB {
-                           dsn      => "DBI:mysql:database=test;host=dbhost",
-                           user     => "username",
-                           password => "password",
-                       };
+                  dsn    => "DBI:mysql:database=test;host=dbhost",
+                  user    => "username",
+                  password => "password",
+                };
  
  task "list", sub {
-    my @data = db select => {
-                  fields => "*",
-                  from   => "table",
-                  where  => "enabled=1",
-               };
+   my @data = db select => {
+            fields => "*",
+            from  => "table",
+            where  => "enabled=1",
+          };
+        
+  db insert => "table", {
+           field1 => "value1",
+            field2 => "value2",
+            field3 => 5,
+          };
            
-   db insert => "table", {
-                field1 => "value1",
-                 field2 => "value2",
-                 field3 => 5,
-               };
-                
-   db update => "table", {
-                    set => {
-                       field1 => "newvalue",
-                       field2 => "newvalue2",
-                    },
-                    where => "id=5",
-                };
-                
-   db delete => "table", {
-                 where => "id < 5",
-              };
+  db update => "table", {
+              set => {
+                field1 => "newvalue",
+                field2 => "newvalue2",
+              },
+              where => "id=5",
+           };
            
+  db delete => "table", {
+            where => "id < 5",
+          };
+        
  };
 
 
@@ -72,117 +72,117 @@ use vars qw(@EXPORT $dbh);
 Do a database action.
 
  my @data = db select => {
-               fields => "*",
-               from   => "table",
-               where  => "host='myhost'",
-            };
-            
+          fields => "*",
+          from  => "table",
+          where  => "host='myhost'",
+        };
+        
  db insert => "table", {
-               field1 => "value1",
-               field2 => "value2",
-               field3 => 5,
-            };
-             
+          field1 => "value1",
+          field2 => "value2",
+          field3 => 5,
+        };
+         
  db update => "table", {
-                  set => {
-                     field1 => "newvalue",
-                     field2 => "newvalue2",
-                  },
-                  where => "id=5",
-             };
-             
+            set => {
+              field1 => "newvalue",
+              field2 => "newvalue2",
+            },
+            where => "id=5",
+         };
+         
  db delete => "table", {
-               where => "id < 5",
-            };
+          where => "id < 5",
+        };
 
 =cut
 
 sub db {
 
-   my ($type, $table, $data) = @_;
-   if(ref($table)) {
-      my %d = %{$table};
-      delete $d{"from"};
-      $data = \%d;
-
-      $table = $table->{"from"};
-   }
-
-   unless($table) {
-      Rex::Logger::info("No table defined...')");
-      return;
-   }
-
-   if($type eq "select") {
-      my $sql = sprintf("SELECT %s FROM %s WHERE %s", $data->{"fields"} || "*", $table, $data->{"where"} || "1=1");
-      if(defined $data->{"order"}) {
-         $sql .= " ORDER BY " . $data->{"order"};
-      }
-      Rex::Logger::debug("sql: $sql");
-
-      my $sth = $dbh->prepare($sql);
-      $sth->execute or die($sth->errstr);
-
-      my @return;
-
-      while(my $row = $sth->fetchrow_hashref) {
-         push @return, $row;
-      }
-      $sth->finish;
-
-      return @return;
-   }
-   elsif($type eq "insert") {
-      my $sql = "INSERT INTO %s (%s) VALUES(%s)";
-
-      my @values;
-      for my $key (keys %{$data}) {
-         push(@values, "?");
-      }
-
-      $sql = sprintf($sql, $table, join(",", keys %{$data}), join(",", @values));
-      Rex::Logger::debug("sql: $sql");
-
-      my $sth = $dbh->prepare($sql);
-      my $i=1;
-      for my $key (keys %{$data}) {
-         $data->{$key} ||= '';
-         Rex::Logger::debug("sql: binding: " . $data->{$key});
-         $sth->bind_param($i, $data->{$key}) or die($sth->errstr);
-         $i++;
-      }
-
-      $sth->execute or die($sth->errstr);
-   }
-   elsif($type eq "update") {
-      my $sql = "UPDATE %s SET %s WHERE %s";
-
-      my @values;
-      for my $key (keys %{$data->{"set"}}) {
-         push(@values, "$key = ?");
-      }
-
-      $sql = sprintf($sql, $table, join(",", @values), $data->{"where"});
-      Rex::Logger::debug("sql: $sql");
-
-      my $sth = $dbh->prepare($sql);
-      my $i=1;
-      for my $key (keys %{$data->{"set"}}) {
-         Rex::Logger::debug("sql: binding: " . $data->{"set"}->{$key});
-         $sth->bind_param($i, $data->{"set"}->{$key}) or die($sth->errstr);
-         $i++;
-      }
-
-      $sth->execute or die($sth->errstr);
-   }
-   elsif($type eq "delete") {
-      my $sql = sprintf("DELETE FROM %s WHERE %s", $table, $data->{"where"});
-      my $sth = $dbh->prepare($sql);
-      $sth->execute or die($sth->errstr);
-   }
-   else {
-      Rex::Logger::info("DB: action $type not supported.");
-   }
+  my ($type, $table, $data) = @_;
+  if(ref($table)) {
+    my %d = %{$table};
+    delete $d{"from"};
+    $data = \%d;
+
+    $table = $table->{"from"};
+  }
+
+  unless($table) {
+    Rex::Logger::info("No table defined...')");
+    return;
+  }
+
+  if($type eq "select") {
+    my $sql = sprintf("SELECT %s FROM %s WHERE %s", $data->{"fields"} || "*", $table, $data->{"where"} || "1=1");
+    if(defined $data->{"order"}) {
+      $sql .= " ORDER BY " . $data->{"order"};
+    }
+    Rex::Logger::debug("sql: $sql");
+
+    my $sth = $dbh->prepare($sql);
+    $sth->execute or die($sth->errstr);
+
+    my @return;
+
+    while(my $row = $sth->fetchrow_hashref) {
+      push @return, $row;
+    }
+    $sth->finish;
+
+    return @return;
+  }
+  elsif($type eq "insert") {
+    my $sql = "INSERT INTO %s (%s) VALUES(%s)";
+
+    my @values;
+    for my $key (keys %{$data}) {
+      push(@values, "?");
+    }
+
+    $sql = sprintf($sql, $table, join(",", keys %{$data}), join(",", @values));
+    Rex::Logger::debug("sql: $sql");
+
+    my $sth = $dbh->prepare($sql);
+    my $i=1;
+    for my $key (keys %{$data}) {
+      $data->{$key} ||= '';
+      Rex::Logger::debug("sql: binding: " . $data->{$key});
+      $sth->bind_param($i, $data->{$key}) or die($sth->errstr);
+      $i++;
+    }
+
+    $sth->execute or die($sth->errstr);
+  }
+  elsif($type eq "update") {
+    my $sql = "UPDATE %s SET %s WHERE %s";
+
+    my @values;
+    for my $key (keys %{$data->{"set"}}) {
+      push(@values, "$key = ?");
+    }
+
+    $sql = sprintf($sql, $table, join(",", @values), $data->{"where"});
+    Rex::Logger::debug("sql: $sql");
+
+    my $sth = $dbh->prepare($sql);
+    my $i=1;
+    for my $key (keys %{$data->{"set"}}) {
+      Rex::Logger::debug("sql: binding: " . $data->{"set"}->{$key});
+      $sth->bind_param($i, $data->{"set"}->{$key}) or die($sth->errstr);
+      $i++;
+    }
+
+    $sth->execute or die($sth->errstr);
+  }
+  elsif($type eq "delete") {
+    my $sql = sprintf("DELETE FROM %s WHERE %s", $table, $data->{"where"});
+    my $sth = $dbh->prepare($sql);
+    $sth->execute or die($sth->errstr);
+  }
+  else {
+    Rex::Logger::info("DB: action $type not supported.");
+  }
 
 }
 
@@ -192,20 +192,20 @@ sub db {
 
 sub import {
 
-   my ($class, $opt) = @_;
+  my ($class, $opt) = @_;
 
-   if($opt) {
-      $dbh = DBI->connect($opt->{"dsn"}, $opt->{"user"}, $opt->{"password"} || "", $opt->{"attr"} );  
-      $dbh->{mysql_auto_reconnect} = 1;
-   }
+  if($opt) {
+    $dbh = DBI->connect($opt->{"dsn"}, $opt->{"user"}, $opt->{"password"} || "", $opt->{"attr"} );  
+    $dbh->{mysql_auto_reconnect} = 1;
+  }
 
-   my ($ns_register_to, $file, $line) = caller;   
+  my ($ns_register_to, $file, $line) = caller;  
 
-   no strict 'refs';
-   for my $func_name (@EXPORT) {
-      *{"${ns_register_to}::$func_name"} = \&$func_name;
-   }
-   use strict;
+  no strict 'refs';
+  for my $func_name (@EXPORT) {
+    *{"${ns_register_to}::$func_name"} = \&$func_name;
+  }
+  use strict;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -16,12 +16,12 @@ With this module you can download a remotefile via sftp, http and ftp from a hos
 
  # sftp
  task "download", "remoteserver", sub {
-    download "/remote/file", "localfile";
+   download "/remote/file", "localfile";
  };
  
  # http
  task "download2", sub {
-    download "http://server/remote/file";
+   download "http://server/remote/file";
  };
 
 
@@ -41,23 +41,23 @@ use vars qw($has_wget $has_curl $has_lwp);
 # check which download type we should use
 BEGIN {
 
-   if($^O !~ m/^MSWin/) {
-      system("which wget >/dev/null 2>&1");
-      $has_wget = !$?;
+  if($^O !~ m/^MSWin/) {
+    system("which wget >/dev/null 2>&1");
+    $has_wget = !$?;
 
-      system("which curl >/dev/null 2>&1");
-      $has_curl = !$?;
-   }
+    system("which curl >/dev/null 2>&1");
+    $has_curl = !$?;
+  }
 
-   eval {
-      require LWP::Simple;
-      LWP::Simple->import;
-      $has_lwp = 1;
-   };
+  eval {
+    require LWP::Simple;
+    LWP::Simple->import;
+    $has_lwp = 1;
+  };
 
-   if($^O =~ m/^MSWin/ && ! $has_lwp) {
-      Rex::Logger::info("Please install LWP::Simple to allow file downloads.");
-   }
+  if($^O =~ m/^MSWin/ && ! $has_lwp) {
+    Rex::Logger::info("Please install LWP::Simple to allow file downloads.");
+  }
 
 };
 
@@ -78,102 +78,102 @@ use File::Basename qw(basename);
 Perform a download. If no local file is specified it will download the file to the current directory.
 
  task "download", "remoteserver", sub {
-    download "/remote/file", "localfile";
+   download "/remote/file", "localfile";
  };
-
+ 
  task "download", sub {
-    download "http://www.rexify.org/index.html", "localfile.html";
+   download "http://www.rexify.org/index.html", "localfile.html";
  };
 
 =cut
 
 sub download {
-   my $remote = shift;
-   my $local = shift;
-
-   $remote = resolv_path($remote);
-   $local  = resolv_path($local, 1);
-
-   if($remote =~ m/^(https?|ftp):\/\//) {
-      _http_download($remote, $local);
-   }
-   else {
-      _sftp_download($remote, $local);
-   }
+  my $remote = shift;
+  my $local = shift;
+
+  $remote = resolv_path($remote);
+  $local  = resolv_path($local, 1);
+
+  if($remote =~ m/^(https?|ftp):\/\//) {
+    _http_download($remote, $local);
+  }
+  else {
+    _sftp_download($remote, $local);
+  }
 }
 
 sub _sftp_download {
-   my $remote = shift;
-   my $local = shift;
+  my $remote = shift;
+  my $local = shift;
 
 
-   my $fs = Rex::Interface::Fs->create;
+  my $fs = Rex::Interface::Fs->create;
 
-   Rex::Logger::debug("Downloading via SFTP");
-   unless($local) {
-      $local = basename($remote);
-   }
-   Rex::Logger::debug("saving file to $local");
+  Rex::Logger::debug("Downloading via SFTP");
+  unless($local) {
+    $local = basename($remote);
+  }
+  Rex::Logger::debug("saving file to $local");
 
-   unless(is_file($remote)) {
-      Rex::Logger::info("File $remote not found");
-      die("$remote not found.");
-   }
-   
-   unless(is_readable($remote)) {
-      Rex::Logger::info("File $remote is not readable.");
-      die("$remote is not readable.");
-   }
+  unless(is_file($remote)) {
+    Rex::Logger::info("File $remote not found");
+    die("$remote not found.");
+  }
+  
+  unless(is_readable($remote)) {
+    Rex::Logger::info("File $remote is not readable.");
+    die("$remote is not readable.");
+  }
 
-   if(-d $local) {
-      $local = $local . '/' . basename($remote);
-   }
+  if(-d $local) {
+    $local = $local . '/' . basename($remote);
+  }
 
-   $fs->download($remote, $local);
+  $fs->download($remote, $local);
 
 }
 
 sub _http_download {
-   my ($remote, $local) = @_;
+  my ($remote, $local) = @_;
 
-   unless($local) {
-      $local = basename($remote);
-   }
-   Rex::Logger::debug("saving file to $local");
+  unless($local) {
+    $local = basename($remote);
+  }
+  Rex::Logger::debug("saving file to $local");
 
-   my $content = _get_http($remote);
+  my $content = _get_http($remote);
 
-   if(-d $local) {
-      $local = $local . '/' . basename($remote);
-   }
+  if(-d $local) {
+    $local = $local . '/' . basename($remote);
+  }
 
-   open(my $fh, ">", $local) or die($!);
-   binmode $fh;
-   print $fh $content;
-   close($fh);
+  open(my $fh, ">", $local) or die($!);
+  binmode $fh;
+  print $fh $content;
+  close($fh);
 }
 
 sub _get_http {
-   my ($url) = @_;
-
-   my $html;
-   if($has_curl) {
-      Rex::Logger::debug("Downloading via curl");
-      $html = qx{curl -# -L -k '$url' 2>/dev/null};
-   }
-   elsif($has_wget) {
-      Rex::Logger::debug("Downloading via wget");
-      $html = qx{wget --no-check-certificate -O - '$url' 2>/dev/null};
-   }
-   elsif($has_lwp) {
-      Rex::Logger::debug("Downloading via LWP::Simple");
-      $html = get($url);
-   }
-   else {
-      die("No tool found to download something. (curl, wget, LWP::Simple)");
-   }
-
-   return $html;
+  my ($url) = @_;
+
+  my $html;
+  if($has_curl) {
+    Rex::Logger::debug("Downloading via curl");
+    $html = qx{curl -# -L -k '$url' 2>/dev/null};
+  }
+  elsif($has_wget) {
+    Rex::Logger::debug("Downloading via wget");
+    $html = qx{wget --no-check-certificate -O - '$url' 2>/dev/null};
+  }
+  elsif($has_lwp) {
+    Rex::Logger::debug("Downloading via LWP::Simple");
+    $html = get($url);
+  }
+  else {
+    die("No tool found to download something. (curl, wget, LWP::Simple)");
+  }
+
+  return $html;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,42 +15,42 @@ With this module you can manipulate files.
 =head1 SYNOPSIS
 
  task "read-passwd", "server01", sub {
-    my $fh = file_read "/etc/passwd";
-    for my $line = ($fh->read_all) {
-       print $line;
-    }
-    $fh->close;
+   my $fh = file_read "/etc/passwd";
+   for my $line = ($fh->read_all) {
+     print $line;
+   }
+   $fh->close;
  };
-
+ 
  task "read-passwd2", "server01", sub {
-    say cat "/etc/passwd";
+   say cat "/etc/passwd";
  };
- 
- 
+
+
  task "write-passwd", "server01", sub {
-    my $fh = file_write "/etc/passwd";
-    $fh->write("root:*:0:0:root user:/root:/bin/sh\n");
-    $fh->close;
+   my $fh = file_write "/etc/passwd";
+   $fh->write("root:*:0:0:root user:/root:/bin/sh\n");
+   $fh->close;
  };
-    
+ 
  delete_lines_matching "/var/log/auth.log", matching => "root";
  delete_lines_matching "/var/log/auth.log", matching => qr{Failed};
- delete_lines_matching "/var/log/auth.log", 
-                        matching => "root", qr{Failed}, "nobody";
-    
- file "/path/on/the/remote/machine",
-    source => "/path/on/local/machine";
-    
+ delete_lines_matching "/var/log/auth.log",
+                matching => "root", qr{Failed}, "nobody";
+ 
  file "/path/on/the/remote/machine",
-    content => "foo bar";
-    
+   source => "/path/on/local/machine";
+ 
  file "/path/on/the/remote/machine",
-    source => "/path/on/local/machine",
-    owner  => "root",
-    group  => "root",
-    mode   => 400,
-    on_change => sub { say "File was changed."; };
+   content => "foo bar";
  
+ file "/path/on/the/remote/machine",
+   source => "/path/on/local/machine",
+   owner  => "root",
+   group  => "root",
+   mode  => 400,
+   on_change => sub { say "File was changed."; };
+
 
 =head1 EXPORTED FUNCTIONS
 
@@ -86,11 +86,11 @@ use File::Basename qw(dirname);
 use vars qw(@EXPORT);
 use base qw(Rex::Exporter);
 
-@EXPORT = qw(file_write file_read file_append 
-               cat sed
-               delete_lines_matching append_if_no_such_line delete_lines_according_to 
-               file template
-               extract);
+@EXPORT = qw(file_write file_read file_append
+          cat sed
+          delete_lines_matching append_if_no_such_line delete_lines_according_to
+          file template
+          extract);
 
 use vars qw(%file_handles);
 
@@ -98,107 +98,107 @@ use vars qw(%file_handles);
 
 Parse a template and return the content.
 
- my $content = template("/files/templates/vhosts.tpl", 
-                     name => "test.lan",
-                     webmaster => 'webmaster@test.lan');
+ my $content = template("/files/templates/vhosts.tpl",
+              name => "test.lan",
+              webmaster => 'webmaster@test.lan');
 
 =cut
 sub template {
-   my ($file, @params) = @_;
-   my $param;
-
-   $file = resolv_path($file);
-   
-   if(ref $params[0] eq "HASH") {
-      $param = $params[0];
-   }
-   else {
-      $param = { @params };
-   }
-
-   if(! exists $param->{server}) {
-      $param->{server} = Rex::Commands::connection()->server;
-   }
-
-   unless($file =~ m/^\// || $file =~ m/^\@/) {
-      # path is relative and no template
-      Rex::Logger::debug("Relativ path $file");
-
-      $file = Rex::Helper::Path::get_file_path($file, caller());
-
-      Rex::Logger::debug("New filename: $file");
-   }
-
-   # if there is a file called filename.environment then use this file
-   # ex: 
-   # $content = template("files/hosts.tpl");
-   # 
-   # rex -E live ...
-   # will first look if files/hosts.tpl.live is available, if not it will
-   # use files/hosts.tpl
-   if(-f "$file." . Rex::Config->get_environment) {
-      $file = "$file." . Rex::Config->get_environment;
-   }
-
-   my $content;
-
-   if(-f $file) {
-      $content = eval { local(@ARGV, $/) = ($file); <>; };
-   }
-   elsif($file =~ m/^\@/) {
-      my @caller = caller(0);
-      my $file_path = Rex::get_module_path($caller[0]);
-
-      if(! -f $file_path) {
-         if(-f "$file_path/__module__.pm") {
-            $file_path = "$file_path/__module__.pm";
-         }
-         elsif(-f "$file_path/Module.pm") {
-            $file_path = "$file_path/Module.pm";
-         }
-         elsif(-f $caller[1]) {
-            $file_path = $caller[1];
-         }
+  my ($file, @params) = @_;
+  my $param;
+
+  $file = resolv_path($file);
+
+  if(ref $params[0] eq "HASH") {
+    $param = $params[0];
+  }
+  else {
+    $param = { @params };
+  }
+
+  if(! exists $param->{server}) {
+    $param->{server} = Rex::Commands::connection()->server;
+  }
+
+  unless($file =~ m/^\// || $file =~ m/^\@/) {
+    # path is relative and no template
+    Rex::Logger::debug("Relativ path $file");
+
+    $file = Rex::Helper::Path::get_file_path($file, caller());
+
+    Rex::Logger::debug("New filename: $file");
+  }
+
+  # if there is a file called filename.environment then use this file
+  # ex:
+  # $content = template("files/hosts.tpl");
+  #
+  # rex -E live ...
+  # will first look if files/hosts.tpl.live is available, if not it will
+  # use files/hosts.tpl
+  if(-f "$file." . Rex::Config->get_environment) {
+    $file = "$file." . Rex::Config->get_environment;
+  }
+
+  my $content;
+
+  if(-f $file) {
+    $content = eval { local(@ARGV, $/) = ($file); <>; };
+  }
+  elsif($file =~ m/^\@/) {
+    my @caller = caller(0);
+    my $file_path = Rex::get_module_path($caller[0]);
+
+    if(! -f $file_path) {
+      if(-f "$file_path/__module__.pm") {
+        $file_path = "$file_path/__module__.pm";
       }
-      my $file_content = eval { local(@ARGV, $/) = ($file_path); <>; };
-      my ($data) = ($file_content =~ m/.*__DATA__(.*)/ms);
-      my $fp = Rex::File::Parser::Data->new(data => [ split(/\n/, $data) ]);
-      my $snippet_to_read = substr($file, 1);
-      $content = $fp->read($snippet_to_read);
-   }
-   else {
-      die("$file not found");
-   }
-
-   my %template_vars;
-   if(! exists $param->{__no_sys_info__}) {
-      %template_vars = _get_std_template_vars($param);
-   }
-   else {
-      delete $param->{__no_sys_info__};
-      %template_vars = %{ $param };
-   }
-
-   return Rex::Config->get_template_function()->($content, \%template_vars);
+      elsif(-f "$file_path/Module.pm") {
+        $file_path = "$file_path/Module.pm";
+      }
+      elsif(-f $caller[1]) {
+        $file_path = $caller[1];
+      }
+    }
+    my $file_content = eval { local(@ARGV, $/) = ($file_path); <>; };
+    my ($data) = ($file_content =~ m/.*__DATA__(.*)/ms);
+    my $fp = Rex::File::Parser::Data->new(data => [ split(/\n/, $data) ]);
+    my $snippet_to_read = substr($file, 1);
+    $content = $fp->read($snippet_to_read);
+  }
+  else {
+    die("$file not found");
+  }
+
+  my %template_vars;
+  if(! exists $param->{__no_sys_info__}) {
+    %template_vars = _get_std_template_vars($param);
+  }
+  else {
+    delete $param->{__no_sys_info__};
+    %template_vars = %{ $param };
+  }
+
+  return Rex::Config->get_template_function()->($content, \%template_vars);
 }
 
 sub _get_std_template_vars {
-   my ($param) = @_;
+  my ($param) = @_;
 
-   my %merge1 = %{$param || {}};
-   my %merge2;
+  my %merge1 = %{$param || {}};
+  my %merge2;
 
-   if(Rex::get_cache()->valid("system_information_info")) {
-      %merge2 = %{ Rex::get_cache()->get("system_information_info") };
-   }
-   else {
-      %merge2 = Rex::Helper::System::info();
-      Rex::get_cache()->set("system_information_info", \%merge2);
-   }
+  if(Rex::get_cache()->valid("system_information_info")) {
+    %merge2 = %{ Rex::get_cache()->get("system_information_info") };
+  }
+  else {
+    %merge2 = Rex::Helper::System::info();
+    Rex::get_cache()->set("system_information_info", \%merge2);
+  }
 
-   my %template_vars = (%merge1, %merge2);
+  my %template_vars = (%merge1, %merge2);
 
-   return %template_vars;
+  return %template_vars;
 }
 
 =item file($file_name, %options)
@@ -206,29 +206,42 @@ sub _get_std_template_vars {
 This function is the successor of I<install file>. Please use this function to upload files to you server.
 
  task "prepare", "server1", "server2", sub {
-    file "/file/on/remote/machine",
-       source => "/file/on/local/machine";
-       
-    file "/etc/hosts",
-       content => template("templates/etc/hosts.tpl"),
-       owner   => "user",
-       group   => "group",
-       mode    => 700,
-       on_change => sub { say "Something was changed." };
-        
-    file "/etc/motd",
-       content => `fortune`;
-      
-    file "/etc/httpd/conf/httpd.conf",
-       source => "/files/etc/httpd/conf/httpd.conf",
-       on_change => sub { service httpd => "restart"; };
+   file "/file/on/remote/machine",
+     source => "/file/on/local/machine";
+ 
+   file "/etc/hosts",
+     content => template("templates/etc/hosts.tpl"),
+     owner  => "user",
+     group  => "group",
+     mode   => 700,
+     on_change => sub { say "Something was changed." };
+ 
+   file "/etc/motd",
+     content => `fortune`;
+ 
+   file "/etc/named.conf",
+     content    => template("templates/etc/named.conf.tpl"),
+     no_overwrite => TRUE;  # this file will not be overwritten if already exists.
+ 
+   file "/etc/httpd/conf/httpd.conf",
+     source => "/files/etc/httpd/conf/httpd.conf",
+     on_change => sub { service httpd => "restart"; };
+ 
+   file "/etc/named.d",
+     ensure => "directory",  # this will create a directory
+     owner  => "root",
+     group  => "root";
+ 
+   file "/etc/motd",
+     ensure => "absent";   # this will remove the file or directory
+ 
  };
 
 If I<source> is relative it will search from the location of your I<Rexfile> or the I<.pm> file if you use Perl packages.
 
 This function supports the following hooks:
 
-=over 8 
+=over 8
 
 =item before
 
@@ -250,197 +263,235 @@ This gets executed right before the file() function returns.
 
 =cut
 sub file {
-   my ($file, @options) = @_;
+  my ($file, @options) = @_;
 
-   my $option = { @options };
+  if(ref $file eq "ARRAY") {
+    my @ret;
+    # $file is an array, so iterate over these files
+    for my $f (@{$file}) {
+      push(@ret, file($f, @options));
+    }
 
-   $file = resolv_path($file);
+    return \@ret;
+  }
 
-   if(exists $option->{source}) {
-      $option->{source} = resolv_path($option->{source});
-   }
+  my $option = { @options };
 
-   #### check and run before hook
-   eval {
-      my @new_args = Rex::Hook::run_hook(file => "before", @_);
-      if(@new_args) {
-         ($file, @options) = @new_args;
-         $option = { @options };
-      }
-      1;
-   } or do {
-      die("Before-Hook failed. Canceling file() action: $@");
-   };
-   ##############################
+  $file = resolv_path($file);
 
+  my ($is_directory);
+  if(exists $option->{ensure} && $option->{ensure} eq "directory") {
+    $is_directory = 1;
+  }
 
-   my $need_md5 = ($option->{"on_change"} ? 1 : 0);
-   my $on_change = $option->{"on_change"} || sub {};
+  if(exists $option->{source} && ! $is_directory) {
+    $option->{source} = resolv_path($option->{source});
+  }
 
-   my $fs = Rex::Interface::Fs->create;
+  #### check and run before hook
+  eval {
+    my @new_args = Rex::Hook::run_hook(file => "before", @_);
+    if(@new_args) {
+      ($file, @options) = @new_args;
+      $option = { @options };
+    }
+    1;
+  } or do {
+    die("Before-Hook failed. Canceling file() action: $@");
+  };
+  ##############################
 
-   my $__ret = {changed => 0};
 
-   my ($new_md5, $old_md5);
-   eval {
-      $old_md5 = md5($file);
-   };
+  my $need_md5 = ($option->{"on_change"} && ! $is_directory ? 1 : 0);
+  my $on_change = $option->{"on_change"} || sub {};
 
-   if(exists $option->{"content"}) {
-      # first upload file to tmp location, to get md5 sum.
-      # than we can decide if we need to replace the current (old) file.
+  my $fs = Rex::Interface::Fs->create;
 
-      my @splitted_file = split(/\//, $file);
-      my $file_name = ".rex.tmp." . pop(@splitted_file);
-      my $tmp_file_name = ($#splitted_file != -1 ? (join("/", @splitted_file) . "/" . $file_name) : $file_name);
+  my $__ret = {changed => 0};
 
-      my $fh = file_write($tmp_file_name);
-      my @lines = split(qr{$/}, $option->{"content"});
-      for my $line (@lines) {
-         $fh->write($line . $/);
-      }
-      $fh->close;
+  my ($new_md5, $old_md5);
+  eval {
+    $old_md5 = md5($file);
+  };
 
-      # now get md5 sums
-      $new_md5 = md5($tmp_file_name);
+  if(exists $option->{no_overwrite} && $option->{no_overwrite} && $old_md5) {
+    Rex::Logger::debug("File already exists and no_overwrite option given. Doing nothing.");
+    $__ret = {changed => 0};
+  }
 
-      if($new_md5 && $old_md5 && $new_md5 eq $old_md5) {
-         Rex::Logger::debug("No need to overwrite exiting file. Old and new files are the same. $old_md5 eq $new_md5.");
-         # md5 sums are the same, delete tmp.
-         $fs->unlink($tmp_file_name);
-         $need_md5 = 0; # we don't need to execute on_change hook
-      }
-      else {
-         $old_md5 ||= "";
-         Rex::Logger::debug("Need to use the new file. md5 sums are different. <<$old_md5>> = <<$new_md5>>");
+  elsif(exists $option->{"content"} && ! $is_directory) {
+    # first upload file to tmp location, to get md5 sum.
+    # than we can decide if we need to replace the current (old) file.
 
-         #### check and run before_change hook
-         Rex::Hook::run_hook(file => "before_change", @_);
-         ##############################
+    my @splitted_file = split(/\//, $file);
+    my $file_name = ".rex.tmp." . pop(@splitted_file);
+    my $tmp_file_name = ($#splitted_file != -1 ? (join("/", @splitted_file) . "/" . $file_name) : $file_name);
 
+    my $fh = file_write($tmp_file_name);
+    my @lines = split(qr{$/}, $option->{"content"});
+    for my $line (@lines) {
+      $fh->write($line . $/);
+    }
+    $fh->close;
 
-         $fs->rename($tmp_file_name, $file);
-         $__ret = {changed => 1};
+    # now get md5 sums
+    $new_md5 = md5($tmp_file_name);
 
-         #### check and run after_change hook
-         Rex::Hook::run_hook(file => "after_change", @_, $__ret);
-         ##############################
+    if($new_md5 && $old_md5 && $new_md5 eq $old_md5) {
+      Rex::Logger::debug("No need to overwrite exiting file. Old and new files are the same. $old_md5 eq $new_md5.");
+      # md5 sums are the same, delete tmp.
+      $fs->unlink($tmp_file_name);
+      $need_md5 = 0; # we don't need to execute on_change hook
+    }
+    else {
+      $old_md5 ||= "";
+      Rex::Logger::debug("Need to use the new file. md5 sums are different. <<$old_md5>> = <<$new_md5>>");
 
-      }
+      #### check and run before_change hook
+      Rex::Hook::run_hook(file => "before_change", @_);
+      ##############################
 
 
-   }
-   elsif(exists $option->{"source"}) {
-      $option->{source} = Rex::Helper::Path::get_file_path($option->{source}, caller());
+      $fs->rename($tmp_file_name, $file);
+      $__ret = {changed => 1};
 
-      # HOOKS: for this case you have to use the upload hooks!
-      $__ret = upload $option->{"source"}, "$file", force => 1;
-   }
+      #### check and run after_change hook
+      Rex::Hook::run_hook(file => "after_change", @_, $__ret);
+      ##############################
+
+    }
+
+
+  }
+  elsif(exists $option->{"source"} && ! $is_directory) {
+    $option->{source} = Rex::Helper::Path::get_file_path($option->{source}, caller());
+
+    # HOOKS: for this case you have to use the upload hooks!
+    $__ret = upload $option->{"source"}, "$file", force => 1;
+  }
 
-   if(exists $option->{"ensure"}) {
-      if($option->{ensure} eq "present") {
-         if(! $fs->is_file($file)) {
+  if(exists $option->{"ensure"}) {
+    if($option->{ensure} eq "present") {
+      if(! $fs->is_file($file)) {
 
-            #### check and run before_change hook
-            Rex::Hook::run_hook(file => "before_change", @_);
-            ##############################
+        #### check and run before_change hook
+        Rex::Hook::run_hook(file => "before_change", @_);
+        ##############################
 
-            my $fh = file_write($file);
-            $fh->write("");
-            $fh->close;
-            $__ret = {changed => 1};
+        my $fh = file_write($file);
+        $fh->write("");
+        $fh->close;
+        $__ret = {changed => 1};
 
-            #### check and run after_change hook
-            Rex::Hook::run_hook(file => "after_change", @_, $__ret);
-            ##############################
+        #### check and run after_change hook
+        Rex::Hook::run_hook(file => "after_change", @_, $__ret);
+        ##############################
 
-         }
-         else {
-            $__ret = {changed => 0};
-         }
       }
-      elsif($option->{ensure} eq "absent") {
-         $need_md5 = 0;
-         delete $option->{mode};
-         delete $option->{group};
-         delete $option->{owner};
-
-         #### check and run before_change hook
-         Rex::Hook::run_hook(file => "before_change", @_);
-         ##############################
-
-         if($fs->is_file($file)) {
-            $fs->unlink($file);
-            $__ret = {changed => 1};
-         }
-         else {
-            $__ret = {changed => 0};
-         }
-
-         #### check and run after_change hook
-         Rex::Hook::run_hook(file => "after_change", @_, $__ret);
-         ##############################
+      else {
+        $__ret = {changed => 0};
+      }
+    }
+    elsif($option->{ensure} eq "absent") {
+      $need_md5 = 0;
+      delete $option->{mode};
+      delete $option->{group};
+      delete $option->{owner};
+
+      #### check and run before_change hook
+      Rex::Hook::run_hook(file => "before_change", @_);
+      ##############################
+
+      if($fs->is_file($file)) {
+        $fs->unlink($file);
+        $__ret = {changed => 1};
+      }
+      elsif($fs->is_dir($file)) {
+        $fs->rmdir($file);
+        $__ret = {changed => 1};
+      }
+      else {
+        $__ret = {changed => 0};
+      }
+
+      #### check and run after_change hook
+      Rex::Hook::run_hook(file => "after_change", @_, $__ret);
+      ##############################
 
+    }
+    elsif($option->{ensure} eq "directory") {
+      Rex::Logger::debug("file() should be a directory");
+      my %dir_option;
+      if(exists $option->{owner}) {
+        $dir_option{owner} = $option->{owner};
       }
-   }
+      if(exists $option->{group}) {
+        $dir_option{group} = $option->{group};
+      }
+      if(exists $option->{mode}) {
+        $dir_option{mode} = $option->{mode};
+      }
+      Rex::Commands::Fs::mkdir($file, %dir_option);
+    }
+  }
 
-   if(! exists $option->{content} && ! exists $option->{source}) {
-      # no content and no source, so just verify that the file is present
-      if(! $fs->is_file($file)) {
+  if(! exists $option->{content} && ! exists $option->{source}) {
+    # no content and no source, so just verify that the file is present
+    if(! $fs->is_file($file) && ! $is_directory) {
 
-         #### check and run before_change hook
-         Rex::Hook::run_hook(file => "before_change", @_);
-         ##############################
+      #### check and run before_change hook
+      Rex::Hook::run_hook(file => "before_change", @_);
+      ##############################
 
-         my $fh = file_write($file);
-         $fh->write("");
-         $fh->close;
+      my $fh = file_write($file);
+      $fh->write("");
+      $fh->close;
 
-         #### check and run after_change hook
-         Rex::Hook::run_hook(file => "after_change", @_, $__ret);
-         ##############################
+      #### check and run after_change hook
+      Rex::Hook::run_hook(file => "after_change", @_, $__ret);
+      ##############################
 
-      }
-   }
+    }
+  }
 
-   if($need_md5) {
-      eval {
-         $new_md5 = md5($file);
-      };
-   }
+  if($need_md5) {
+    eval {
+      $new_md5 = md5($file);
+    };
+  }
 
-   if(exists $option->{"mode"}) {
-      $fs->chmod($option->{"mode"}, $file);
-   }
+  if(exists $option->{"mode"}) {
+    $fs->chmod($option->{"mode"}, $file);
+  }
 
-   if(exists $option->{"group"}) {
-      $fs->chgrp($option->{"group"}, $file);
-   }
+  if(exists $option->{"group"}) {
+    $fs->chgrp($option->{"group"}, $file);
+  }
 
-   if(exists $option->{"owner"}) {
-      $fs->chown($option->{"owner"}, $file);
-   }
+  if(exists $option->{"owner"}) {
+    $fs->chown($option->{"owner"}, $file);
+  }
 
-   if($need_md5) {
-      unless($old_md5 && $new_md5 && $old_md5 eq $new_md5) {
-         $old_md5 ||= "";
-         $new_md5 ||= "";
+  if($need_md5) {
+    unless($old_md5 && $new_md5 && $old_md5 eq $new_md5) {
+      $old_md5 ||= "";
+      $new_md5 ||= "";
 
-         Rex::Logger::debug("File $file has been changed... Running on_change");
-         Rex::Logger::debug("old: $old_md5");
-         Rex::Logger::debug("new: $new_md5");
+      Rex::Logger::debug("File $file has been changed... Running on_change");
+      Rex::Logger::debug("old: $old_md5");
+      Rex::Logger::debug("new: $new_md5");
 
-         &$on_change($file);
+      &$on_change($file);
 
-         return {changed => 1};
-      }
-   }
+      return {changed => 1};
+    }
+  }
 
-   #### check and run before hook
-   Rex::Hook::run_hook(file => "after", @_, $__ret);
-   ##############################
+  #### check and run before hook
+  Rex::Hook::run_hook(file => "after", @_, $__ret);
+  ##############################
 
-   return $__ret;
+  return $__ret;
 }
 
 =item file_write($file_name)
@@ -451,12 +502,12 @@ On failure it will die.
 
  my $fh;
  eval {
-    $fh = file_write("/etc/groups");
+   $fh = file_write("/etc/groups");
  };
  
  # catch an error
  if($@) {
-    print "An error occured. $@.\n";
+   print "An error occured. $@.\n";
  }
  
  # work with the filehandle
@@ -466,18 +517,18 @@ On failure it will die.
 =cut
 
 sub file_write {
-   my ($file) = @_;
-   $file = resolv_path($file);
+  my ($file) = @_;
+  $file = resolv_path($file);
 
-   Rex::Logger::debug("Opening file: $file for writing.");
+  Rex::Logger::debug("Opening file: $file for writing.");
 
-   my $fh = Rex::Interface::File->create;
-   if( ! $fh->open(">", $file)) {
-      Rex::Logger::debug("Can't open $file for writing.");
-      die("Can't open $file for writing.");
-   }
+  my $fh = Rex::Interface::File->create;
+  if( ! $fh->open(">", $file)) {
+    Rex::Logger::debug("Can't open $file for writing.");
+    die("Can't open $file for writing.");
+  }
 
-   return Rex::FS::File->new(fh => $fh);
+  return Rex::FS::File->new(fh => $fh);
 }
 
 =item file_append($file_name)
@@ -485,19 +536,19 @@ sub file_write {
 =cut
 
 sub file_append {
-   my ($file) = @_;
-   $file = resolv_path($file);
+  my ($file) = @_;
+  $file = resolv_path($file);
 
-   Rex::Logger::debug("Opening file: $file for appending.");
+  Rex::Logger::debug("Opening file: $file for appending.");
 
-   my $fh = Rex::Interface::File->create;
+  my $fh = Rex::Interface::File->create;
 
-   if( ! $fh->open(">>", $file)) {
-      Rex::Logger::debug("Can't open $file for appending.");
-      die("Can't open $file for appending.");
-   }
+  if( ! $fh->open(">>", $file)) {
+    Rex::Logger::debug("Can't open $file for appending.");
+    die("Can't open $file for appending.");
+  }
 
-   return Rex::FS::File->new(fh => $fh);
+  return Rex::FS::File->new(fh => $fh);
 }
 
 =item file_read($file_name)
@@ -508,12 +559,12 @@ On failure it will die.
 
  my $fh;
  eval {
-    $fh = read("/etc/groups");
+   $fh = read("/etc/groups");
  };
  
  # catch an error
  if($@) {
-    print "An error occured. $@.\n";
+   print "An error occured. $@.\n";
  }
  
  # work with the filehandle
@@ -523,19 +574,19 @@ On failure it will die.
 =cut
 
 sub file_read {
-   my ($file) = @_;
-   $file = resolv_path($file);
+  my ($file) = @_;
+  $file = resolv_path($file);
 
-   Rex::Logger::debug("Opening file: $file for reading.");
+  Rex::Logger::debug("Opening file: $file for reading.");
 
-   my $fh = Rex::Interface::File->create;
+  my $fh = Rex::Interface::File->create;
 
-   if( ! $fh->open("<", $file)) {
-      Rex::Logger::debug("Can't open $file for reading.");
-      die("Can't open $file for reading.");
-   }
+  if( ! $fh->open("<", $file)) {
+    Rex::Logger::debug("Can't open $file for reading.");
+    die("Can't open $file for reading.");
+  }
 
-   return Rex::FS::File->new(fh => $fh);
+  return Rex::FS::File->new(fh => $fh);
 }
 
 =item cat($file_name)
@@ -547,17 +598,17 @@ This function returns the complete content of $file_name as a string.
 =cut
 
 sub cat {
-   my ($file) = @_;
-   $file = resolv_path($file);
+  my ($file) = @_;
+  $file = resolv_path($file);
 
-   my $fh = file_read($file);
-   unless($fh) {
-      die("Can't open $file for reading");
-   }
-   my $content = $fh->read_all;
-   $fh->close;
+  my $fh = file_read($file);
+  unless($fh) {
+    die("Can't open $file for reading");
+  }
+  my $content = $fh->read_all;
+  $fh->close;
 
-   return $content;
+  return $content;
 }
 
 =item delete_lines_matching($file, $regexp)
@@ -565,52 +616,52 @@ sub cat {
 Delete lines that match $regexp in $file.
 
  task "clean-logs", sub {
-     delete_lines_matching "/var/log/auth.log" => "root";
+    delete_lines_matching "/var/log/auth.log" => "root";
  };
 
 =cut
 sub delete_lines_matching {
-   my ($file, @m) = @_;
-   $file = resolv_path($file);
-
-   for (@m) {
-      if(ref($_) ne "Regexp") {
-         $_ = qr{\Q$_\E};
-      }
-   }
+  my ($file, @m) = @_;
+  $file = resolv_path($file);
 
-   my $fs = Rex::Interface::Fs->create;
-
-   if(! $fs->is_file($file)) {
-      Rex::Logger::info("File: $file not found.");
-      die("$file not found");
-   }
-
-   if(! $fs->is_writable($file)) {
-      Rex::Logger::info("File: $file not writable.");
-      die("$file not writable");
-   }
-
-   my $nl = $/;
-   my @content = split(/$nl/, cat ($file));
-
-   my $fh = file_write $file;
-   unless($fh) {
-      die("Can't open $file for writing");
-   }
-
-   OUT:
-   for my $line (@content) {
-      IN:
-      for my $match (@m) {
-         if($line =~ $match) {
-            next OUT;
-         }
+  for (@m) {
+    if(ref($_) ne "Regexp") {
+      $_ = qr{\Q$_\E};
+    }
+  }
+
+  my $fs = Rex::Interface::Fs->create;
+
+  if(! $fs->is_file($file)) {
+    Rex::Logger::info("File: $file not found.");
+    die("$file not found");
+  }
+
+  if(! $fs->is_writable($file)) {
+    Rex::Logger::info("File: $file not writable.");
+    die("$file not writable");
+  }
+
+  my $nl = $/;
+  my @content = split(/$nl/, cat ($file));
+
+  my $fh = file_write $file;
+  unless($fh) {
+    die("Can't open $file for writing");
+  }
+
+  OUT:
+  for my $line (@content) {
+    IN:
+    for my $match (@m) {
+      if($line =~ $match) {
+        next OUT;
       }
+    }
 
-      $fh->write($line . $nl);
-   }
-   $fh->close;
+    $fh->write($line . $nl);
+  }
+  $fh->close;
 
 }
 
@@ -621,35 +672,35 @@ This is the successor of the delete_lines_matching() function. This function als
 It will search for $search in $file and remove the found lines. If on_change hook is present it will execute this if the file was changed.
 
  task "cleanup", "server1", sub {
-    delete_lines_according_to qr{^foo:}, "/etc/passwd",
-      on_change => sub {
-         say "removed user foo.";
-      };
+   delete_lines_according_to qr{^foo:}, "/etc/passwd",
+    on_change => sub {
+      say "removed user foo.";
+    };
  };
 
 =cut
 sub delete_lines_according_to {
-   my ($search, $file, @options) = @_;
-   $file = resolv_path($file);
+  my ($search, $file, @options) = @_;
+  $file = resolv_path($file);
 
-   my $option = { @options };
-   my $on_change = $option->{on_change} || undef;
+  my $option = { @options };
+  my $on_change = $option->{on_change} || undef;
 
-   my ($old_md5, $new_md5);
+  my ($old_md5, $new_md5);
 
-   if($on_change) {
-      $old_md5 = md5($file);
-   }
+  if($on_change) {
+    $old_md5 = md5($file);
+  }
 
-   delete_lines_matching($file, $search);
+  delete_lines_matching($file, $search);
 
-   if($on_change) {
-      $new_md5 = md5($file);
+  if($on_change) {
+    $new_md5 = md5($file);
 
-      if($old_md5 ne $new_md5) {
-         &$on_change($file);
-      }
-   }
+    if($old_md5 ne $new_md5) {
+      &$on_change($file);
+    }
+  }
 }
 
 =item append_if_no_such_line($file, $new_line, @regexp)
@@ -659,133 +710,133 @@ supplied, the line is appended unless there is already an identical line
 in $file.
 
  task "add-group", sub {
-    append_if_no_such_line "/etc/groups", "mygroup:*:100:myuser1,myuser2", on_change => sub { service sshd => "restart"; };
+   append_if_no_such_line "/etc/groups", "mygroup:*:100:myuser1,myuser2", on_change => sub { service sshd => "restart"; };
  };
 
 Since 0.42 you can use named parameters as well
 
  task "add-group", sub {
-    append_if_no_such_line "/etc/groups",
-       line   => "mygroup:*:100:myuser1,myuser2",
-       regexp => qr{^mygroup},
-       on_change => sub {
-                       say "file was changed, do something.";
-                    };
-          
-    append_if_no_such_line "/etc/groups",
-       line   => "mygroup:*:100:myuser1,myuser2",
-       regexp => [qr{^mygroup:}, qr{^ourgroup:}]; # this is an OR
+   append_if_no_such_line "/etc/groups",
+     line  => "mygroup:*:100:myuser1,myuser2",
+     regexp => qr{^mygroup},
+     on_change => sub {
+                say "file was changed, do something.";
+              };
+ 
+   append_if_no_such_line "/etc/groups",
+     line  => "mygroup:*:100:myuser1,myuser2",
+     regexp => [qr{^mygroup:}, qr{^ourgroup:}]; # this is an OR
  };
 
 =cut
 
 sub append_if_no_such_line {
-   my $file = shift;
-   $file = resolv_path($file);
-   my ($new_line, @m);
-
-   # check if parameters are in key => value format
-   my ($option, $on_change);
-
-   eval {
-      no warnings;
-      $option = { @_ };
-      # if there is no line parameter, it is the old parameter format
-      # so go dieing
-      if(! exists $option->{line}) {
-         die;
-      }
-      $new_line = $option->{line};
-      if(exists $option->{regexp} && ref $option->{regexp} eq "Regexp") {
-         @m = ($option->{regexp});
-      }
-      elsif(ref $option->{regexp} eq "ARRAY") {
-         @m = @{ $option->{regexp} };
-      }
-      $on_change = $option->{on_change} || undef;
-      1;
-   } or do {
-      ($new_line, @m) = @_;
-      # check if something in @m (the regexpes) is named on_change
-      for (my $i = 0; $i<$#m; $i++ ) {
-         if ( $m[$i] eq "on_change" && ref($m[$i+1]) eq "CODE" ) {
-            $on_change = $m[$i+1];
-            splice(@m,$i,2);
-            last;
-         }
+  my $file = shift;
+  $file = resolv_path($file);
+  my ($new_line, @m);
+
+  # check if parameters are in key => value format
+  my ($option, $on_change);
+
+  eval {
+    no warnings;
+    $option = { @_ };
+    # if there is no line parameter, it is the old parameter format
+    # so go dieing
+    if(! exists $option->{line}) {
+      die;
+    }
+    $new_line = $option->{line};
+    if(exists $option->{regexp} && ref $option->{regexp} eq "Regexp") {
+      @m = ($option->{regexp});
+    }
+    elsif(ref $option->{regexp} eq "ARRAY") {
+      @m = @{ $option->{regexp} };
+    }
+    $on_change = $option->{on_change} || undef;
+    1;
+  } or do {
+    ($new_line, @m) = @_;
+    # check if something in @m (the regexpes) is named on_change
+    for (my $i = 0; $i<$#m; $i++ ) {
+      if ( $m[$i] eq "on_change" && ref($m[$i+1]) eq "CODE" ) {
+        $on_change = $m[$i+1];
+        splice(@m,$i,2);
+        last;
       }
-   };
-
-   my $fs = Rex::Interface::Fs->create;
-
-   my ($old_md5, $ret);
-   if ($on_change) {
-      $old_md5 = md5($file);
-   }
-
-   # slow but secure way
-   my @content;
-   eval {
-      @content = split(/\n/, cat($file));
-      1;
-   } or do {
-      $ret = 1;
-   };
-
-   if ( !@m ) {
-      push @m, qr{\Q$new_line\E};
-   }
-
-   for my $line (@content) {
-      for my $match (@m) {
-         if(ref($match) ne "Regexp") {
-            $match = qr{$match};
-         }
-         if ( $line =~ $match ) {
-            return 0;
-         }
+    }
+  };
+
+  my $fs = Rex::Interface::Fs->create;
+
+  my ($old_md5, $ret);
+  if ($on_change) {
+    $old_md5 = md5($file);
+  }
+
+  # slow but secure way
+  my @content;
+  eval {
+    @content = split(/\n/, cat($file));
+    1;
+  } or do {
+    $ret = 1;
+  };
+
+  if ( !@m ) {
+    push @m, qr{\Q$new_line\E};
+  }
+
+  for my $line (@content) {
+    for my $match (@m) {
+      if(ref($match) ne "Regexp") {
+        $match = qr{$match};
       }
-   }
-
-   push @content, "$new_line\n";
-
-   eval {
-      my $fh = file_write $file;
-      unless($fh) {
-         die("can't open file for writing");
+      if ( $line =~ $match ) {
+        return 0;
       }
-      $fh->write(join("\n", @content));
-      $fh->close;
-      $ret = 0;
-      1;
-   } or do {
-      $ret = 3;
-   };
-
-   if ($ret==1) {
-      die("Can't open $file for reading");
-   }
-   elsif ($ret==2) {
-      die("Can't open temp file for writing");
-   }
-   elsif ($ret==3) {
-      die("Can't open $file for writing");
-   }
+    }
+  }
 
-   if ($on_change) {
-      my $new_md5 = md5($file);
-      if($old_md5 && $new_md5 && $old_md5 ne $new_md5) {
-         $old_md5 ||= "";
-         $new_md5 ||= "";
+  push @content, "$new_line\n";
 
-         Rex::Logger::debug("File $file has been changed... Running on_change");
-         Rex::Logger::debug("old: $old_md5");
-         Rex::Logger::debug("new: $new_md5");
-         &$on_change($file);
-      }
-   }
+  eval {
+    my $fh = file_write $file;
+    unless($fh) {
+      die("can't open file for writing");
+    }
+    $fh->write(join("\n", @content));
+    $fh->close;
+    $ret = 0;
+    1;
+  } or do {
+    $ret = 3;
+  };
+
+  if ($ret==1) {
+    die("Can't open $file for reading");
+  }
+  elsif ($ret==2) {
+    die("Can't open temp file for writing");
+  }
+  elsif ($ret==3) {
+    die("Can't open $file for writing");
+  }
+
+  if ($on_change) {
+    my $new_md5 = md5($file);
+    if($old_md5 && $new_md5 && $old_md5 ne $new_md5) {
+      $old_md5 ||= "";
+      $new_md5 ||= "";
+
+      Rex::Logger::debug("File $file has been changed... Running on_change");
+      Rex::Logger::debug("old: $old_md5");
+      Rex::Logger::debug("new: $new_md5");
+      &$on_change($file);
+    }
+  }
 
-#   &$on_change() if defined $on_change;
+#  &$on_change() if defined $on_change;
 }
 
 =item extract($file [, %options])
@@ -793,82 +844,82 @@ sub append_if_no_such_line {
 This function extracts a file. Supported formats are .box, .tar, .tar.gz, .tgz, .tar.Z, .tar.bz2, .tbz2, .zip, .gz, .bz2, .war, .jar.
 
  task prepare => sub {
-    extract "/tmp/myfile.tar.gz",
-      owner => "root",
-      group => "root",
-      to    => "/etc";
-
-    extract "/tmp/foo.tgz",
-      type => "tgz",
-      mode => "g+rwX";
- };
+   extract "/tmp/myfile.tar.gz",
+    owner => "root",
+    group => "root",
+    to   => "/etc";
  
+   extract "/tmp/foo.tgz",
+    type => "tgz",
+    mode => "g+rwX";
+ };
+
 Can use the type=> option if the file suffix has been changed. (types are tar, tgz, tbz, zip, gz, bz2)
 
 =cut
 sub extract {
-   my ($file, %option) = @_;
-   $file = resolv_path($file);
-
-   my $pre_cmd = "";
-   my $to = ".";
-   my $type = "";
-
-   if($option{chdir}) {
-      $to = $option{chdir};
-   }
-
-   if($option{to}) {
-      $to = $option{to};
-   }
-   $to = resolv_path($to);
-
-   if($option{type}) {
-      $type = $option{type};
-   }
-
-   $pre_cmd = "cd $to; ";
-
-   my $exec = Rex::Interface::Exec->create;
-   my $cmd = "";
-
-   if($type eq 'tgz' || $file =~ m/\.tar\.gz$/ || $file =~ m/\.tgz$/ || $file =~ m/\.tar\.Z$/) {
-      $cmd = "${pre_cmd}gunzip -c $file | tar -xf -";
-   }
-   elsif($type eq 'tbz' || $file =~ m/\.tar\.bz2/ || $file =~ m/\.tbz2/) {
-      $cmd = "${pre_cmd}bunzip2 -c $file | tar -xf -";
-   }
-   elsif($type eq 'tar' || $file =~ m/\.(tar|box)/) {
-      $cmd = "${pre_cmd}tar -xf $file";
-   }
-   elsif($type eq 'zip' || $file =~ m/\.(zip|war|jar)$/) {
-      $cmd = "${pre_cmd}unzip -o $file";
-   }
-   elsif($type eq 'gz' || $file =~ m/\.gz$/) {
-      $cmd = "${pre_cmd}gunzip -f $file";
-   }
-   elsif($type eq 'bz2' || $file =~ m/\.bz2$/) {
-      $cmd = "${pre_cmd}bunzip2 -f $file";
-   }
-   else {
-      Rex::Logger::info("File not supported.");
-      die("File ($file) not supported.");
-   }
-
-   $exec->exec($cmd);
-
-   my $fs = Rex::Interface::Fs->create;
-   if($option{owner}) {
-      $fs->chown($option{owner}, $to, recursive => 1);
-   }
-
-   if($option{group}) {
-      $fs->chgrp($option{group}, $to, recursive => 1);
-   }
-
-   if($option{mode}) {
-      $fs->chmod($option{mode}, $to, recursive => 1);
-   }
+  my ($file, %option) = @_;
+  $file = resolv_path($file);
+
+  my $pre_cmd = "";
+  my $to = ".";
+  my $type = "";
+
+  if($option{chdir}) {
+    $to = $option{chdir};
+  }
+
+  if($option{to}) {
+    $to = $option{to};
+  }
+  $to = resolv_path($to);
+
+  if($option{type}) {
+    $type = $option{type};
+  }
+
+  $pre_cmd = "cd $to; ";
+
+  my $exec = Rex::Interface::Exec->create;
+  my $cmd = "";
+
+  if($type eq 'tgz' || $file =~ m/\.tar\.gz$/ || $file =~ m/\.tgz$/ || $file =~ m/\.tar\.Z$/) {
+    $cmd = "${pre_cmd}gunzip -c $file | tar -xf -";
+  }
+  elsif($type eq 'tbz' || $file =~ m/\.tar\.bz2/ || $file =~ m/\.tbz2/) {
+    $cmd = "${pre_cmd}bunzip2 -c $file | tar -xf -";
+  }
+  elsif($type eq 'tar' || $file =~ m/\.(tar|box)/) {
+    $cmd = "${pre_cmd}tar -xf $file";
+  }
+  elsif($type eq 'zip' || $file =~ m/\.(zip|war|jar)$/) {
+    $cmd = "${pre_cmd}unzip -o $file";
+  }
+  elsif($type eq 'gz' || $file =~ m/\.gz$/) {
+    $cmd = "${pre_cmd}gunzip -f $file";
+  }
+  elsif($type eq 'bz2' || $file =~ m/\.bz2$/) {
+    $cmd = "${pre_cmd}bunzip2 -f $file";
+  }
+  else {
+    Rex::Logger::info("File not supported.");
+    die("File ($file) not supported.");
+  }
+
+  $exec->exec($cmd);
+
+  my $fs = Rex::Interface::Fs->create;
+  if($option{owner}) {
+    $fs->chown($option{owner}, $to, recursive => 1);
+  }
+
+  if($option{group}) {
+    $fs->chgrp($option{group}, $to, recursive => 1);
+  }
+
+  if($option{mode}) {
+    $fs->chmod($option{mode}, $to, recursive => 1);
+  }
 
 }
 
@@ -877,44 +928,44 @@ sub extract {
 Search some string in a file and replace it.
 
  task sar => sub {
-    # this will work line by line
-    sed qr{search}, "replace", "/var/log/auth.log";
-        
-    # to use it in a multiline way
-    sed qr{search}, "replace", "/var/log/auth.log",
-      multiline => TRUE;
+   # this will work line by line
+   sed qr{search}, "replace", "/var/log/auth.log";
+ 
+   # to use it in a multiline way
+   sed qr{search}, "replace", "/var/log/auth.log",
+    multiline => TRUE;
  };
 
 =cut
 sub sed {
-   my ($search, $replace, $file, @option) = @_;
-   $file = resolv_path($file);
-   my $options = {};
-   
-   if(ref($option[0])) {
-      $options = $option[0];
-   }
-   else {
-      $options = { @option };
-   }
-
-   my $on_change = $options->{"on_change"} || undef;
-
-   my @content;
-
-   if(exists $options->{multiline}) {
-      $content[0] = cat($file);
-      $content[0] =~ s/$search/$replace/gms; 
-   }
-   else {
-      @content = split(/\n/, cat($file));
-      map { s/$search/$replace/ } @content; 
-   }
-
-   my $fs = Rex::Interface::Fs->create;
-   my %stat = $fs->stat($file);
-
-   file($file, content => join("\n", @content), on_change => $on_change, owner => $stat{uid}, group => $stat{gid}, mode => $stat{mode});
+  my ($search, $replace, $file, @option) = @_;
+  $file = resolv_path($file);
+  my $options = {};
+
+  if(ref($option[0])) {
+    $options = $option[0];
+  }
+  else {
+    $options = { @option };
+  }
+
+  my $on_change = $options->{"on_change"} || undef;
+
+  my @content;
+
+  if(exists $options->{multiline}) {
+    $content[0] = cat($file);
+    $content[0] =~ s/$search/$replace/gms;
+  }
+  else {
+    @content = split(/\n/, cat($file));
+    map { s/$search/$replace/ } @content;
+  }
+
+  my $fs = Rex::Interface::Fs->create;
+  my %stat = $fs->stat($file);
+
+  file($file, content => join("\n", @content), on_change => $on_change, owner => $stat{uid}, group => $stat{gid}, mode => $stat{mode});
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -34,7 +34,7 @@ With this module you can do file system tasks like creating a directory, removin
  is_dir("/etc");
  is_writeable("/tmp");
  is_writable("/tmp");
-    
+   
  chmod 755, "/tmp";
  chown "user", "/tmp";
  chgrp "group", "/tmp";
@@ -67,12 +67,12 @@ use vars qw(@EXPORT);
 use base qw(Rex::Exporter);
 
 @EXPORT = qw(list_files ls
-            unlink rm rmdir mkdir stat readlink symlink ln rename mv chdir cd cp
-            chown chgrp chmod
-            is_file is_dir is_readable is_writeable is_writable
-            df du
-            mount umount
-            glob);
+        unlink rm rmdir mkdir stat readlink symlink ln rename mv chdir cd cp
+        chown chgrp chmod
+        is_file is_dir is_readable is_writeable is_writable
+        df du
+        mount umount
+        glob);
 
 use vars qw(%file_handles);
 
@@ -81,19 +81,19 @@ use vars qw(%file_handles);
 This function list all entries (files, directories, ...) in a given directory and returns a array.
 
  task "ls-etc", "server01", sub {
-    my @tmp_files = grep { /\.tmp$/ } list_files("/etc");
+   my @tmp_files = grep { /\.tmp$/ } list_files("/etc");
  };
 
 =cut
 
 sub list_files {
-   my $path = shift;
-   $path = resolv_path($path);
+  my $path = shift;
+  $path = resolv_path($path);
 
-   my $fs = Rex::Interface::Fs->create;
-   my @ret = $fs->ls($path);
+  my $fs = Rex::Interface::Fs->create;
+  my @ret = $fs->ls($path);
 
-   return @ret;
+  return @ret;
 }
 
 =item ls($path)
@@ -103,7 +103,7 @@ Just an alias for I<list_files>
 =cut
 
 sub ls {
-   return list_files(@_);
+  return list_files(@_);
 }
 
 =item symlink($from, $to)
@@ -111,18 +111,18 @@ sub ls {
 This function will create a symlink from $from to $to.
 
  task "symlink", "server01", sub {
-    symlink("/var/www/versions/1.0.0", "/var/www/html");
+   symlink("/var/www/versions/1.0.0", "/var/www/html");
  };
 
 =cut
 
 sub symlink {
-   my ($from, $to) = @_;
-   $from = resolv_path($from);
-   $to = resolv_path($to);
+  my ($from, $to) = @_;
+  $from = resolv_path($from);
+  $to = resolv_path($to);
 
-   my $fs = Rex::Interface::Fs->create;
-   $fs->ln($from, $to) or die("Can't link $from -> $to");
+  my $fs = Rex::Interface::Fs->create;
+  $fs->ln($from, $to) or die("Can't link $from -> $to");
 }
 
 =item ln($from, $to)
@@ -132,7 +132,7 @@ ln is an alias for I<symlink>
 =cut
 
 sub ln {
-   &symlink(@_);
+  &symlink(@_);
 }
 
 =item unlink($file)
@@ -140,17 +140,17 @@ sub ln {
 This function will remove the given file.
 
  task "unlink", "server01", sub {
-    unlink("/tmp/testfile");
+   unlink("/tmp/testfile");
  };
 
 =cut
 
 sub unlink {
-   my @files = @_;
-   @files = map { resolv_path($_) } @files;
+  my @files = @_;
+  @files = map { resolv_path($_) } @files;
 
-   my $fs = Rex::Interface::Fs->create;
-   $fs->unlink(@files);
+  my $fs = Rex::Interface::Fs->create;
+  $fs->unlink(@files);
 }
 
 =item rm($file)
@@ -160,7 +160,7 @@ This is an alias for unlink.
 =cut
 
 sub rm {
-   &unlink(@_);
+  &unlink(@_);
 }
 
 =item rmdir($dir)
@@ -168,21 +168,21 @@ sub rm {
 This function will remove the given directory.
 
  task "rmdir", "server01", sub {
-    rmdir("/tmp");
+   rmdir("/tmp");
  };
 
 =cut
 
 sub rmdir {
-   my @dirs = @_;
-   @dirs = map { resolv_path($_) } @dirs;
+  my @dirs = @_;
+  @dirs = map { resolv_path($_) } @dirs;
 
-   my $fs = Rex::Interface::Fs->create;
+  my $fs = Rex::Interface::Fs->create;
 
-   if(! $fs->rmdir(@dirs)) {
-      Rex::Logger::debug("Can't delete " . join(", ", @dirs));
-      die("Can't delete " . join(", ", @dirs));
-   }
+  if(! $fs->rmdir(@dirs)) {
+    Rex::Logger::debug("Can't delete " . join(", ", @dirs));
+    die("Can't delete " . join(", ", @dirs));
+  }
 
 }
 
@@ -191,128 +191,140 @@ sub rmdir {
 This function will create a new directory.
 
  task "mkdir", "server01", sub {
-    mkdir "/tmp";
-         
-    mkdir "/tmp",
-      owner => "root",
-      group => "root",
-      mode => 1777;
+   mkdir "/tmp";
+      
+   mkdir "/tmp",
+    owner => "root",
+    group => "root",
+    mode => 1777;
  };
 
 =cut
 
 sub mkdir {
-   Rex::Logger::debug("Creating directory $_[0]");
-   my $dir = shift;
-   $dir = resolv_path($dir);
+  Rex::Logger::debug("Creating directory $_[0]");
+  my $dir = shift;
+  $dir = resolv_path($dir);
 
-   my $options = { @_ };
+  my $options = { @_ };
 
-   my $fs = Rex::Interface::Fs->create;
+  my $fs = Rex::Interface::Fs->create;
 
-   my $not_created = 0;
-   my %old_stat;
-   if(Rex::Config->get_do_reporting) {
-      if($fs->is_dir($dir)) {
-         $not_created = 1;
-      }
-   }
+  my $not_created = 0;
+  my %old_stat;
+  if(Rex::Config->get_do_reporting) {
+    if($fs->is_dir($dir)) {
+      $not_created = 1;
+    }
+  }
 
-   my $mode  = $options->{"mode"}  || 755;
-   my $owner = $options->{"owner"} || "";
-   my $group = $options->{"group"} || "";
-   my $not_recursive = $options->{"not_recursive"} || 0;
+  my $mode  = $options->{"mode"}  || 755;
+  my $owner = $options->{"owner"} || "";
+  my $group = $options->{"group"} || "";
+  my $not_recursive = $options->{"not_recursive"} || 0;
+
+  if($not_recursive) {
+    if(! $fs->mkdir($dir)) {
+      Rex::Logger::debug("Can't create directory $dir");
+      die("Can't create directory $dir");
+    }
 
-   if($not_recursive) {
-      if(! $fs->mkdir($dir)) {
-         Rex::Logger::debug("Can't create directory $dir");
-         die("Can't create directory $dir");
+    my ($ret_a, $ret_b, $ret_c);
+
+    $ret_a = &chown($owner, $dir) if $owner;
+    $ret_b = &chgrp($group, $dir) if $group;
+    $ret_c = &chmod($mode, $dir)  if $owner;
+
+    if(Rex::Config->get_do_reporting) {
+      my $changed = 0;
+      if(ref $ret_a) {
+        $changed = $ret_a->{changed};
       }
 
-      my ($ret_a, $ret_b, $ret_c);
+      if(ref $ret_b) {
+        $changed = $ret_b->{changed};
+      }
 
-      $ret_a = &chown($owner, $dir) if $owner;
-      $ret_b = &chgrp($group, $dir) if $group;
-      $ret_c = &chmod($mode, $dir)  if $owner;
+      if(ref $ret_c) {
+        $changed = $ret_c->{changed};
+      }
 
-      if(Rex::Config->get_do_reporting) {
-         my $changed = 0;
-         if(ref $ret_a) {
-            $changed = $ret_a->{changed};
-         }
-
-         if(ref $ret_b) {
-            $changed = $ret_b->{changed};
-         }
-
-         if(ref $ret_c) {
-            $changed = $ret_c->{changed};
-         }
-
-         if(! $not_created) {
-            $changed = 1;
-         }
-
-         return {
-            changed => $changed,
-            ret     => undef,
-         };
+      if(! $not_created) {
+        $changed = 1;
       }
 
-      return;
-   }
+      return {
+        changed => $changed,
+        ret    => undef,
+      };
+    }
+
+    return;
+  }
 
-   my @splitted_dir = map { $_="/$_"; } split(/\//, $dir);
-   unless($splitted_dir[0] eq "/") {
+  my @splitted_dir;
+ 
+  if(Rex::is_ssh == 0 && $^O =~ m/^MSWin/) {
+    # special case for local windows runs
+    @splitted_dir = map { $_="\\$_"; } split(/[\\\/]/, $dir);
+    if ($splitted_dir[0] =~ m/([a-z]):/i) {
+      $splitted_dir[0] = "$1:\\";
+    }
+  }
+  else {
+    @splitted_dir = map { $_="/$_"; } split(/\//, $dir);
+   
+    unless($splitted_dir[0] eq "/") {
       $splitted_dir[0] = "." . $splitted_dir[0];
-   }
-   else {
+    }
+    else {
       shift @splitted_dir;
-   }
+    }
+  }
 
-   my $str_part="";
-   my $changed = 0;
-   for my $part (@splitted_dir) {
-      $str_part .= "$part";
+  my $str_part="";
+  my $changed = 0;
+  for my $part (@splitted_dir) {
+    $str_part .= "$part";
 
-      if(! is_dir($str_part) && ! is_file($str_part)) {
-         if(! $fs->mkdir($str_part)) {
-            Rex::Logger::debug("Can't create directory $dir");
-            die("Can't create directory $dir");
-         }
+    if(! is_dir($str_part) && ! is_file($str_part)) {
+      if(! $fs->mkdir($str_part)) {
+        Rex::Logger::debug("Can't create directory $dir");
+        die("Can't create directory $dir");
+      }
 
-         my ($ret_a, $ret_b, $ret_c);
+      my ($ret_a, $ret_b, $ret_c);
 
-         $ret_a = &chown($owner, $str_part) if $owner;
-         $ret_b = &chgrp($group, $str_part) if $group;
-         $ret_c = &chmod($mode, $str_part)  if $owner;
+      $ret_a = &chown($owner, $str_part) if $owner;
+      $ret_b = &chgrp($group, $str_part) if $group;
+      $ret_c = &chmod($mode, $str_part)  if $owner;
 
-         if(Rex::Config->get_do_reporting) {
-            my $changed = 0;
-            if(ref $ret_a) {
-               $changed = $ret_a->{changed};
-            }
+      if(Rex::Config->get_do_reporting) {
+        my $changed = 0;
+        if(ref $ret_a) {
+          $changed = $ret_a->{changed};
+        }
 
-            if(ref $ret_b) {
-               $changed = $ret_b->{changed};
-            }
+        if(ref $ret_b) {
+          $changed = $ret_b->{changed};
+        }
 
-            if(ref $ret_c) {
-               $changed = $ret_c->{changed};
-            }
+        if(ref $ret_c) {
+          $changed = $ret_c->{changed};
+        }
 
-            if(! $not_created) {
-               $changed = 1;
-            }
+        if(! $not_created) {
+          $changed = 1;
+        }
 
-         }
       }
-   }
+    }
+  }
 
-   return {
-      changed => $changed,
-      ret     => undef,
-   };
+  return {
+    changed => $changed,
+    ret    => undef,
+  };
 
 }
 
@@ -321,41 +333,41 @@ sub mkdir {
 Change the owner of a file or a directory.
 
  chown "www-data", "/var/www/html";
-     
+    
  chown "www-data", "/var/www/html",
-                        recursive => 1;
+                recursive => 1;
 
 =cut
 
 sub chown {
-   my ($user, $file, @opts) = @_;
-   $file = resolv_path($file);
-
-   my $fs = Rex::Interface::Fs->create;
-   my %stat;
-   if(Rex::Config->get_do_reporting) {
-      %stat = $fs->stat($file);
-   }
-
-   my $ret = $fs->chown($user, $file, @opts) or die("Can't chown $file");
-
-   if(Rex::Config->get_do_reporting) {
-      my %new_stat = $fs->stat($file);
-      if($stat{uid} == $new_stat{uid}) {
-         return {
-            changed => 0,
-            ret     => $ret,
-         };
-      }
-      else {
-         return {
-            changed => 1,
-            ret     => $ret,
-         };
-      }
-   }
+  my ($user, $file, @opts) = @_;
+  $file = resolv_path($file);
+
+  my $fs = Rex::Interface::Fs->create;
+  my %stat;
+  if(Rex::Config->get_do_reporting) {
+    %stat = $fs->stat($file);
+  }
+
+  my $ret = $fs->chown($user, $file, @opts) or die("Can't chown $file");
+
+  if(Rex::Config->get_do_reporting) {
+    my %new_stat = $fs->stat($file);
+    if($stat{uid} == $new_stat{uid}) {
+      return {
+        changed => 0,
+        ret    => $ret,
+      };
+    }
+    else {
+      return {
+        changed => 1,
+        ret    => $ret,
+      };
+    }
+  }
 
-   return $ret;
+  return $ret;
 }
 
 =item chgrp($group, $file)
@@ -363,42 +375,42 @@ sub chown {
 Change the group of a file or a directory.
 
  chgrp "nogroup", "/var/www/html";
-    
+   
  chgrp "nogroup", "/var/www/html",
-                     recursive => 1;
+              recursive => 1;
 
 =cut
 
 sub chgrp {
-   my ($group, $file, @opts) = @_;
-   $file = resolv_path($file);
+  my ($group, $file, @opts) = @_;
+  $file = resolv_path($file);
 
-   my $fs = Rex::Interface::Fs->create;
-   my %stat;
+  my $fs = Rex::Interface::Fs->create;
+  my %stat;
 
-   if(Rex::Config->get_do_reporting) {
-      %stat = $fs->stat($file);
-   }
+  if(Rex::Config->get_do_reporting) {
+    %stat = $fs->stat($file);
+  }
 
-   my $ret = $fs->chgrp($group, $file, @opts) or die("Can't chgrp $file");
+  my $ret = $fs->chgrp($group, $file, @opts) or die("Can't chgrp $file");
 
-   if(Rex::Config->get_do_reporting) {
-      my %new_stat = $fs->stat($file);
-      if($stat{gid} == $new_stat{gid}) {
-         return {
-            changed => 0,
-            ret     => $ret,
-         };
-      }
-      else {
-         return {
-            changed => 1,
-            ret     => $ret,
-         };
-      }
-   }
+  if(Rex::Config->get_do_reporting) {
+    my %new_stat = $fs->stat($file);
+    if($stat{gid} == $new_stat{gid}) {
+      return {
+        changed => 0,
+        ret    => $ret,
+      };
+    }
+    else {
+      return {
+        changed => 1,
+        ret    => $ret,
+      };
+    }
+  }
 
-   return $ret;
+  return $ret;
 }
 
 =item chmod($mode, $file)
@@ -406,41 +418,41 @@ sub chgrp {
 Change the permissions of a file or a directory.
 
  chmod 755, "/var/www/html";
-    
+   
  chmod 755, "/var/www/html",
-               recursive => 1;
+          recursive => 1;
 
 =cut
 
 sub chmod {
-   my ($mode, $file, @opts) = @_;
-   $file = resolv_path($file);
-
-   my $fs = Rex::Interface::Fs->create;
-   my %stat;
-   if(Rex::Config->get_do_reporting) {
-      %stat = $fs->stat($file);
-   }
-
-   my $ret = $fs->chmod($mode, $file, @opts) or die("Can't chmod $file");
-
-   if(Rex::Config->get_do_reporting) {
-      my %new_stat = $fs->stat($file);
-      if($stat{mode} eq $new_stat{mode}) {
-         return {
-            changed => 0,
-            ret     => $ret,
-         };
-      }
-      else {
-         return {
-            changed => 1,
-            ret     => $ret,
-         };
-      }
-   }
+  my ($mode, $file, @opts) = @_;
+  $file = resolv_path($file);
+
+  my $fs = Rex::Interface::Fs->create;
+  my %stat;
+  if(Rex::Config->get_do_reporting) {
+    %stat = $fs->stat($file);
+  }
+
+  my $ret = $fs->chmod($mode, $file, @opts) or die("Can't chmod $file");
+
+  if(Rex::Config->get_do_reporting) {
+    my %new_stat = $fs->stat($file);
+    if($stat{mode} eq $new_stat{mode}) {
+      return {
+        changed => 0,
+        ret    => $ret,
+      };
+    }
+    else {
+      return {
+        changed => 1,
+        ret    => $ret,
+      };
+    }
+  }
 
-   return $ret;
+  return $ret;
 }
 
 
@@ -465,23 +477,23 @@ This function will return a hash with the following information about a file or
 =back
 
  task "stat", "server01", sub {
-    my %file_stat = stat("/etc/passwd");
+   my %file_stat = stat("/etc/passwd");
  };
 
 
 =cut
 
 sub stat {
-   my ($file) = @_;
-   $file = resolv_path($file);
-   my %ret;
+  my ($file) = @_;
+  $file = resolv_path($file);
+  my %ret;
 
-   Rex::Logger::debug("Getting fs stat from $file");
+  Rex::Logger::debug("Getting fs stat from $file");
 
-   my $fs = Rex::Interface::Fs->create;
-   %ret = $fs->stat($file) or die("Can't stat $file");
+  my $fs = Rex::Interface::Fs->create;
+  %ret = $fs->stat($file) or die("Can't stat $file");
 
-   return %ret;
+  return %ret;
 }
 
 =item is_file($file)
@@ -489,22 +501,22 @@ sub stat {
 This function tests if $file is a file. Returns 1 if true. 0 if false.
 
  task "isfile", "server01", sub {
-    if( is_file("/etc/passwd") ) {
-       say "it is a file.";
-    }
-    else {
-       say "hm, this is not a file.";
-    }
+   if( is_file("/etc/passwd") ) {
+     say "it is a file.";
+   }
+   else {
+     say "hm, this is not a file.";
+   }
  };
 
 =cut
 
 sub is_file {
-   my ($file) = @_;
-   $file = resolv_path($file);
-   
-   my $fs = Rex::Interface::Fs->create;
-   return $fs->is_file($file);
+  my ($file) = @_;
+  $file = resolv_path($file);
+  
+  my $fs = Rex::Interface::Fs->create;
+  return $fs->is_file($file);
 }
 
 =item is_dir($dir)
@@ -512,22 +524,22 @@ sub is_file {
 This function tests if $dir is a directory. Returns 1 if true. 0 if false.
 
  task "isdir", "server01", sub {
-    if( is_dir("/etc") ) {
-       say "it is a directory.";
-    }
-    else {
-       say "hm, this is not a directory.";
-    }
+   if( is_dir("/etc") ) {
+     say "it is a directory.";
+   }
+   else {
+     say "hm, this is not a directory.";
+   }
  };
 
 =cut
 
 sub is_dir {
-   my ($path) = @_;
-   $path = resolv_path($path);
+  my ($path) = @_;
+  $path = resolv_path($path);
 
-   my $fs = Rex::Interface::Fs->create;
-   return $fs->is_dir($path);
+  my $fs = Rex::Interface::Fs->create;
+  return $fs->is_dir($path);
 
 }
 
@@ -536,24 +548,24 @@ sub is_dir {
 This function tests if $file is readable. It returns 1 if true. 0 if false.
 
  task "readable", "server01", sub {
-    if( is_readable("/etc/passwd") ) {
-       say "passwd is readable";
-    }
-    else {
-       say "not readable.";
-    }
+   if( is_readable("/etc/passwd") ) {
+     say "passwd is readable";
+   }
+   else {
+     say "not readable.";
+   }
  };
 
 =cut
 
 
 sub is_readable {
-   my ($file) = @_;
-   $file = resolv_path($file);
-   Rex::Logger::debug("Checking if $file is readable");
+  my ($file) = @_;
+  $file = resolv_path($file);
+  Rex::Logger::debug("Checking if $file is readable");
 
-   my $fs = Rex::Interface::Fs->create;
-   return $fs->is_readable($file);
+  my $fs = Rex::Interface::Fs->create;
+  return $fs->is_readable($file);
 }
 
 =item is_writable($file)
@@ -561,24 +573,24 @@ sub is_readable {
 This function tests if $file is writable. It returns 1 if true. 0 if false.
 
  task "writable", "server01", sub {
-    if( is_writable("/etc/passwd") ) {
-       say "passwd is writable";
-    }
-    else {
-       say "not writable.";
-    }
+   if( is_writable("/etc/passwd") ) {
+     say "passwd is writable";
+   }
+   else {
+     say "not writable.";
+   }
  };
 
 =cut
 
 
 sub is_writable {
-   my ($file) = @_;
-   $file = resolv_path($file);
-   Rex::Logger::debug("Checking if $file is writable");
+  my ($file) = @_;
+  $file = resolv_path($file);
+  Rex::Logger::debug("Checking if $file is writable");
 
-   my $fs = Rex::Interface::Fs->create;
-   return $fs->is_writable($file);
+  my $fs = Rex::Interface::Fs->create;
+  return $fs->is_writable($file);
 }
 
 =item is_writeable($file)
@@ -588,7 +600,7 @@ This is only an alias for I<is_writable>.
 =cut
 
 sub is_writeable {
-   is_writable(@_);
+  is_writable(@_);
 }
 
 =item readlink($link)
@@ -597,30 +609,30 @@ This function returns the link endpoint if $link is a symlink. If $link is not a
 
 
  task "islink", "server01", sub {
-    my $link;
-    eval {
-       $link = readlink("/tmp/testlink");
-    };
-    
-    say "this is a link" if($link);
+   my $link;
+   eval {
+     $link = readlink("/tmp/testlink");
+   };
+   
+   say "this is a link" if($link);
  };
 
 =cut
 
 sub readlink {
-   my ($file) = @_;
-   $file = resolv_path($file);
-   Rex::Logger::debug("Reading link of $file");
+  my ($file) = @_;
+  $file = resolv_path($file);
+  Rex::Logger::debug("Reading link of $file");
 
-   my $fs = Rex::Interface::Fs->create;
-   my $link = $fs->readlink($file);
+  my $fs = Rex::Interface::Fs->create;
+  my $link = $fs->readlink($file);
 
-   unless($link) {
-      Rex::Logger::debug("readlink: $file is not a link.");
-      die("readlink: $file is not a link.");
-   }
+  unless($link) {
+    Rex::Logger::debug("readlink: $file is not a link.");
+    die("readlink: $file is not a link.");
+  }
 
-   return $link;
+  return $link;
 }
 
 =item rename($old, $new)
@@ -628,23 +640,23 @@ sub readlink {
 This function will rename $old to $new. Will return 1 on success and 0 on failure.
 
  task "rename", "server01", sub {
-    rename("/tmp/old", "/tmp/new");
+   rename("/tmp/old", "/tmp/new");
  }; 
 
 =cut
 
 sub rename {
-   my ($old, $new) = @_;
-   $old = resolv_path($old);
-   $new = resolv_path($new);
+  my ($old, $new) = @_;
+  $old = resolv_path($old);
+  $new = resolv_path($new);
 
-   Rex::Logger::debug("Renaming $old to $new");
+  Rex::Logger::debug("Renaming $old to $new");
 
-   my $fs = Rex::Interface::Fs->create;
-   if(! $fs->rename($old, $new)) {
-      Rex::Logger::info("Rename failed ($old -> $new)");
-      die("Rename failed $old -> $new");
-   }
+  my $fs = Rex::Interface::Fs->create;
+  if(! $fs->rename($old, $new)) {
+    Rex::Logger::info("Rename failed ($old -> $new)");
+    die("Rename failed $old -> $new");
+  }
 
 }
 
@@ -655,7 +667,7 @@ mv is an alias for I<rename>.
 =cut
 
 sub mv {
-   return &rename(@_);
+  return &rename(@_);
 }
 
 =item chdir($newdir)
@@ -663,14 +675,14 @@ sub mv {
 This function will change the current workdirectory to $newdir. This function currently only works local.
 
  task "chdir", "server01", sub {
-    chdir("/tmp");
+   chdir("/tmp");
  };
 
 =cut
 
 sub chdir {
-   Rex::Logger::debug("chdir behaviour will be changed in the future.");
-   CORE::chdir($_[0]);
+  Rex::Logger::debug("chdir behaviour will be changed in the future.");
+  CORE::chdir($_[0]);
 }
 
 =item cd($newdir)
@@ -680,7 +692,7 @@ This is an alias of I<chdir>.
 =cut
 
 sub cd {
-   &chdir($_[0]);
+  &chdir($_[0]);
 }
 
 =item df([$device])
@@ -688,61 +700,61 @@ sub cd {
 This function returns a hashRef reflecting the output of I<df>
 
  task "df", "server01", sub {
-     my $df = df();
-     my $df_on_sda1 = df("/dev/sda1");
+    my $df = df();
+    my $df_on_sda1 = df("/dev/sda1");
  };
 
 
 =cut
 
 sub df {
-   my ($dev) = @_;
+  my ($dev) = @_;
 
-   my $ret = {};
+  my $ret = {};
 
-   $dev ||= "";
+  $dev ||= "";
 
-   my $exec = Rex::Interface::Exec->create;
-   my ($out, $err) = $exec->exec("df $dev 2>/dev/null");
+  my $exec = Rex::Interface::Exec->create;
+  my ($out, $err) = $exec->exec("df $dev 2>/dev/null");
 
-   my @lines = split(/\r?\n/, $out);
+  my @lines = split(/\r?\n/, $out);
 
-   $ret = _parse_df(@lines);
+  $ret = _parse_df(@lines);
 
-   if($dev) {
-      return $ret->{$dev};
-   }
+  if($dev) {
+    return $ret->{$dev};
+  }
 
-   return $ret;
+  return $ret;
 }
 
 sub _parse_df {
-   my @lines = @_;
-   chomp @lines;
+  my @lines = @_;
+  chomp @lines;
 
-   my $ret = {};
+  my $ret = {};
 
-   shift @lines;
-   my $current_fs = "";
+  shift @lines;
+  my $current_fs = "";
 
-   for my $line (@lines) {
-      my ($fs, $size, $used, $free, $use_per, $mounted_on) = split(/\s+/, $line, 6);
-      $current_fs = $fs if $fs;
+  for my $line (@lines) {
+    my ($fs, $size, $used, $free, $use_per, $mounted_on) = split(/\s+/, $line, 6);
+    $current_fs = $fs if $fs;
 
-      if(! $size) {
-         next;
-      }
+    if(! $size) {
+      next;
+    }
 
-      $ret->{$current_fs} = {
-         size => $size,
-         used => $used,
-         free => $free,
-         used_perc => $use_per,
-         mounted_on => $mounted_on
-      };
-   }
+    $ret->{$current_fs} = {
+      size => $size,
+      used => $used,
+      free => $free,
+      used_perc => $use_per,
+      mounted_on => $mounted_on
+    };
+  }
 
-   return $ret;
+  return $ret;
 }
 
 =item du($path)
@@ -750,20 +762,20 @@ sub _parse_df {
 Returns the disk usage of $path.
 
  task "du", "server01", sub {
-    say "size of /var/www: " . du("/var/www");
+   say "size of /var/www: " . du("/var/www");
  };
 
 =cut
 
 sub du {
-   my ($path) = @_;
-   $path = resolv_path($path);
+  my ($path) = @_;
+  $path = resolv_path($path);
 
-   my $exec = Rex::Interface::Exec->create;
-   my @lines = $exec->exec("du -s $path");
-   my ($du) = ($lines[0] =~ m/^(\d+)/);
+  my $exec = Rex::Interface::Exec->create;
+  my @lines = $exec->exec("du -s $path");
+  my ($du) = ($lines[0] =~ m/^(\d+)/);
 
-   return $du;
+  return $du;
 }
 
 =item cp($source, $destination)
@@ -771,20 +783,20 @@ sub du {
 cp will copy $source to $destination (it is recursive)
 
  task "cp", "server01", sub {
-     cp("/var/www", "/var/www.old");
+    cp("/var/www", "/var/www.old");
  };
 
 =cut
 
 sub cp {
-   my ($source, $dest) = @_;
-   $source = resolv_path($source);
-   $dest = resolv_path($dest);
-
-   my $fs = Rex::Interface::Fs->create;
-   if( ! $fs->cp($source, $dest)) {
-      die("Copy failed from $source to $dest");
-   }
+  my ($source, $dest) = @_;
+  $source = resolv_path($source);
+  $dest = resolv_path($dest);
+
+  my $fs = Rex::Interface::Fs->create;
+  if( ! $fs->cp($source, $dest)) {
+    die("Copy failed from $source to $dest");
+  }
 }
 
 =item mount($device, $mount_point, @options)
@@ -792,94 +804,92 @@ sub cp {
 Mount devices.
 
  task "mount", "server01", sub {
-    mount "/dev/sda5", "/tmp";
-    mount "/dev/sda6", "/mnt/sda6",
-               fs => "ext3",
-               options => [qw/noatime async/];
-    #
-    # mount persistent with entry in /etc/fstab
-      
-    mount "/dev/sda6", "/mnt/sda6",
-               fs => "ext3",
-               options => [qw/noatime async/],
-               persistent => TRUE;
- 
-
+   mount "/dev/sda5", "/tmp";
+   mount "/dev/sda6", "/mnt/sda6",
+          fs => "ext3",
+          options => [qw/noatime async/];
+   #
+   # mount persistent with entry in /etc/fstab
+    
+   mount "/dev/sda6", "/mnt/sda6",
+          fs => "ext3",
+          options => [qw/noatime async/],
+          persistent => TRUE;
  };
 
 =cut
 sub mount {
-   my ($device, $mount_point, @options) = @_;
-   my $option = { @options };
-
-   my $cmd = sprintf("mount %s %s %s %s", 
-                           $option->{"fs"}?"-t " . $option->{"fs"}:"",   # file system
-                           $option->{"options"}?" -o " . join(",", @{$option->{"options"}}):"",
-                           $device,
-                           $mount_point);
-
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec($cmd);
-   if($? != 0) { die("Mount failed of $mount_point"); }
-
-   if(exists $option->{persistent}) {
-      if(! exists $option->{fs}) {
-         # no fs given, so get it from mount output
-         my ($out, $err) = $exec->exec("mount");
-         my @output = split(/\r?\n/, $out);
-         my ($line) = grep { /^$device/ } @output;
-         my ($_d, $_o, $_p, $_t, $fs_type) = split(/\s+/, $line);
-         $option->{fs} = $fs_type;
-
-         my ($_options) = ($line =~ m/\((.+?)\)/);
-         $option->{options} = $_options;
-      }
+  my ($device, $mount_point, @options) = @_;
+  my $option = { @options };
+
+  my $cmd = sprintf("mount %s %s %s %s", 
+                  $option->{"fs"}?"-t " . $option->{"fs"}:"",  # file system
+                  $option->{"options"}?" -o " . join(",", @{$option->{"options"}}):"",
+                  $device,
+                  $mount_point);
+
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec($cmd);
+  if($? != 0) { die("Mount failed of $mount_point"); }
+
+  if(exists $option->{persistent}) {
+    if(! exists $option->{fs}) {
+      # no fs given, so get it from mount output
+      my ($out, $err) = $exec->exec("mount");
+      my @output = split(/\r?\n/, $out);
+      my ($line) = grep { /^$device/ } @output;
+      my ($_d, $_o, $_p, $_t, $fs_type) = split(/\s+/, $line);
+      $option->{fs} = $fs_type;
+
+      my ($_options) = ($line =~ m/\((.+?)\)/);
+      $option->{options} = $_options;
+    }
 
-      my $fh = Rex::Interface::File->create;
+    my $fh = Rex::Interface::File->create;
 
-      if( ! $fh->open("<", "/etc/fstab")) {
-         Rex::Logger::debug("Can't open /etc/fstab for reading.");
-         die("Can't open /etc/fstab for reading.");
-      }
+    if( ! $fh->open("<", "/etc/fstab")) {
+      Rex::Logger::debug("Can't open /etc/fstab for reading.");
+      die("Can't open /etc/fstab for reading.");
+    }
 
-      my $f = Rex::FS::File->new(fh => $fh);
-      my @content = $f->read_all;
-      $f->close;
+    my $f = Rex::FS::File->new(fh => $fh);
+    my @content = $f->read_all;
+    $f->close;
 
-      my @new_content = grep { ! /^$device\s/ } @content;
+    my @new_content = grep { ! /^$device\s/ } @content;
 
-      $option->{options} ||= "defaults";
+    $option->{options} ||= "defaults";
 
-      if(ref($option->{options}) eq "ARRAY") {
-         my $mountops = join(",", @{$option->{"options"}});
-         if($option->{label}) {
-            push(@new_content, "LABEL=" . $option->{label} . "\t$mount_point\t$option->{fs}\t$mountops\t0 0\n");
-         }
-         else {
-            push(@new_content, "$device\t$mount_point\t$option->{fs}\t$mountops\t0 0\n");
-         }
+    if(ref($option->{options}) eq "ARRAY") {
+      my $mountops = join(",", @{$option->{"options"}});
+      if($option->{label}) {
+        push(@new_content, "LABEL=" . $option->{label} . "\t$mount_point\t$option->{fs}\t$mountops\t0 0\n");
+      }
+      else {
+        push(@new_content, "$device\t$mount_point\t$option->{fs}\t$mountops\t0 0\n");
+      }
+    }
+    else {
+      if($option->{label}) {
+        push(@new_content, "LABEL=" . $option->{label} . "\t$mount_point\t$option->{fs}\t$option->{options}\t0 0\n");
       }
       else {
-         if($option->{label}) {
-            push(@new_content, "LABEL=" . $option->{label} . "\t$mount_point\t$option->{fs}\t$option->{options}\t0 0\n");
-         }
-         else {
-            push(@new_content, "$device\t$mount_point\t$option->{fs}\t$option->{options}\t0 0\n");
-         }
+        push(@new_content, "$device\t$mount_point\t$option->{fs}\t$option->{options}\t0 0\n");
       }
+    }
 
-      $fh = Rex::Interface::File->create;
+    $fh = Rex::Interface::File->create;
 
-      if( ! $fh->open(">", "/etc/fstab")) {
-         Rex::Logger::debug("Can't open /etc/fstab for writing.");
-         die("Can't open /etc/fstab for writing.");
-      }
+    if( ! $fh->open(">", "/etc/fstab")) {
+      Rex::Logger::debug("Can't open /etc/fstab for writing.");
+      die("Can't open /etc/fstab for writing.");
+    }
 
-      $f = Rex::FS::File->new(fh => $fh);
-      $f->write(join("\n", @new_content));
-      $f->close;
+    $f = Rex::FS::File->new(fh => $fh);
+    $f->write(join("\n", @new_content));
+    $f->close;
 
-   }
+  }
 }
 
 =item umount($mount_point)
@@ -887,31 +897,31 @@ sub mount {
 Unmount device.
 
  task "umount", "server01", sub {
-    umount "/tmp";
+   umount "/tmp";
  };
 
 =cut
 sub umount {
-   my ($mount_point) = @_;
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("umount $mount_point");
+  my ($mount_point) = @_;
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("umount $mount_point");
 
-   if($? != 0) { die("Umount failed of $mount_point"); }
+  if($? != 0) { die("Umount failed of $mount_point"); }
 }
 
 =item glob($glob)
 
  task "glob", "server1", sub {
-    my @files_with_p = grep { is_file($_) } glob("/etc/p*");
+   my @files_with_p = grep { is_file($_) } glob("/etc/p*");
  };
 
 =cut
 sub glob {
-   my ($glob) = @_;
-   $glob = resolv_path($glob);
+  my ($glob) = @_;
+  $glob = resolv_path($glob);
 
-   my $fs = Rex::Interface::Fs->create;
-   return $fs->glob($glob);
+  my $fs = Rex::Interface::Fs->create;
+  return $fs->glob($glob);
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -43,30 +43,30 @@ use base qw(Rex::Exporter);
 use vars qw(@EXPORT);
 
 @EXPORT = qw(operating_system_is network_interfaces memory
-               get_operating_system operating_system operating_system_version operating_system_release
-               is_freebsd is_netbsd is_openbsd is_redhat is_linux is_bsd is_solaris is_suse is_debian is_mageia is_windows is_alt is_openwrt is_gentoo is_fedora
-               get_system_information dump_system_information);
+          get_operating_system operating_system operating_system_version operating_system_release
+          is_freebsd is_netbsd is_openbsd is_redhat is_linux is_bsd is_solaris is_suse is_debian is_mageia is_windows is_alt is_openwrt is_gentoo is_fedora
+          get_system_information dump_system_information);
 
 =item get_operating_system
 
 Will return the current operating system name.
  
  task "get-os", "server01", sub {
-    say get_operating_system();
+   say get_operating_system();
  };
 
 =cut
 
 sub get_operating_system {
 
-   my $operatingsystem = Rex::Hardware::Host->get_operating_system();
+  my $operatingsystem = Rex::Hardware::Host->get_operating_system();
 
-   return $operatingsystem || "unknown";
+  return $operatingsystem || "unknown";
 
 }
 
 sub operating_system {
-   return get_operating_system();
+  return get_operating_system();
 }
 
 =item get_system_information
@@ -75,7 +75,7 @@ Will return a hash of all system information. These Information will be also use
 
 =cut
 sub get_system_information {
-   return Rex::Helper::System::info();
+  return Rex::Helper::System::info();
 }
 
 =item dump_system_information 
@@ -84,10 +84,10 @@ This function dumps all known system information on stdout.
 
 =cut
 sub dump_system_information {
-   my ($info) = @_;
-   my %sys_info = get_system_information();
+  my ($info) = @_;
+  my %sys_info = get_system_information();
 
-   inspect(\%sys_info, { prepend_key => '$', key_value_sep => " = ", no_root => 1 });
+  inspect(\%sys_info, { prepend_key => '$', key_value_sep => " = ", no_root => 1 });
 }
 
 
@@ -97,24 +97,24 @@ sub dump_system_information {
 Will return 1 if the operating system is $string.
  
  task "is_it_suse", "server01", sub {
-    if( operating_system_is("SuSE") ) {
-       say "This is a SuSE system.";
-    }
+   if( operating_system_is("SuSE") ) {
+     say "This is a SuSE system.";
+   }
  };
 
 =cut
 
 sub operating_system_is {
 
-   my ($os) = @_;
+  my ($os) = @_;
 
-   my $operatingsystem = Rex::Hardware::Host->get_operating_system();
+  my $operatingsystem = Rex::Hardware::Host->get_operating_system();
 
-   if($operatingsystem eq $os) {
-      return 1;
-   }
+  if($operatingsystem eq $os) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 
 }
 
@@ -123,22 +123,22 @@ sub operating_system_is {
 Will return the os release number as an integer. For example, it will convert 5.10 to 510, 10.04 to 1004 or 6.0.3 to 603.
  
  task "prepare", "server01", sub {
-    if( operating_system_version() >= 510 ) {
-       say "OS Release is higher or equal to 510";
-    }
+   if( operating_system_version() >= 510 ) {
+     say "OS Release is higher or equal to 510";
+   }
  };
 
 =cut
 
 sub operating_system_version {
 
-   my ($os) = @_;
+  my ($os) = @_;
 
-   my $operatingsystemrelease = operating_system_release();
+  my $operatingsystemrelease = operating_system_release();
 
-   $operatingsystemrelease =~ s/[\.,]//g;
+  $operatingsystemrelease =~ s/[\.,]//g;
 
-   return $operatingsystemrelease;
+  return $operatingsystemrelease;
 
 }
 
@@ -149,8 +149,8 @@ Will return the os release number as is.
 =cut
 
 sub operating_system_release {
-   my ($os) = @_;
-   return Rex::Hardware::Host->get_operating_system_version();
+  my ($os) = @_;
+  return Rex::Hardware::Host->get_operating_system_version();
 }
 
 =item network_interfaces
@@ -158,23 +158,23 @@ sub operating_system_release {
 Return an HashRef of all the networkinterfaces and their configuration.
 
  task "get_network_information", "server01", sub {
-    my $net_info = network_interfaces();
+   my $net_info = network_interfaces();
  };
 
 You can iterate over the devices as follow
 
  my $net_info = network_interfaces();
  for my $dev ( keys %{ $net_info } ) {
-    say "$dev has the ip: " . $net_info->{$dev}->{"ip"} . " and the netmask: " . $net_info->{$dev}->{"netmask"};
+   say "$dev has the ip: " . $net_info->{$dev}->{"ip"} . " and the netmask: " . $net_info->{$dev}->{"netmask"};
  }
 
 =cut
 
 sub network_interfaces {
-   
-   my $net = Rex::Hardware::Network->get();
+  
+  my $net = Rex::Hardware::Network->get();
 
-   return $net->{"networkconfiguration"};
+  return $net->{"networkconfiguration"};
 
 }
 
@@ -183,22 +183,22 @@ sub network_interfaces {
 Return an HashRef of all memory information.
 
  task "get_memory_information", "server01", sub {
-    my $memory = memory();
-     
-    say "Total:   " . $memory->{"total"};
-    say "Free:    " . $memory->{"free"};
-    say "Used:    " . $memory->{"used"};
-    say "Cached:  " . $memory->{"cached"};
-    say "Buffers: " . $memory->{"buffers"};
+   my $memory = memory();
+    
+   say "Total:  " . $memory->{"total"};
+   say "Free:   " . $memory->{"free"};
+   say "Used:   " . $memory->{"used"};
+   say "Cached:  " . $memory->{"cached"};
+   say "Buffers: " . $memory->{"buffers"};
  };
 
 =cut
 
 sub memory {
 
-   my $mem = Rex::Hardware::Memory->get();
+  my $mem = Rex::Hardware::Memory->get();
 
-   return $mem;
+  return $mem;
 
 }
 
@@ -207,133 +207,133 @@ sub memory {
 Returns true if the target system is a FreeBSD.
 
  task "foo", "server1", "server2", sub {
-    if(is_freebsd) {
-       say "This is a freebsd system...";
-    }
-    else {
-       say "This is not a freebsd system...";
-    }
+   if(is_freebsd) {
+     say "This is a freebsd system...";
+   }
+   else {
+     say "This is not a freebsd system...";
+   }
  };
 
 =cut
 sub is_freebsd {
-   my $os = @_ ? shift : get_operating_system();
-   if($os =~ m/FreeBSD/i) {
-      return 1;
-   }
+  my $os = @_ ? shift : get_operating_system();
+  if($os =~ m/FreeBSD/i) {
+    return 1;
+  }
 }
 
 =item is_redhat
 
  task "foo", "server1", sub {
-    if(is_redhat) {
-       # do something on a redhat system (like RHEL, Fedora, CentOS, Scientific Linux
-    }
+   if(is_redhat) {
+     # do something on a redhat system (like RHEL, Fedora, CentOS, Scientific Linux
+   }
  };
 
 =cut
 sub is_redhat {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   my @redhat_clones = ("Fedora", "Redhat", "CentOS", "Scientific", "RedHatEnterpriseServer" ,"RedHatEnterpriseES", "RedHatEnterpriseWorkstation");
+  my @redhat_clones = ("Fedora", "Redhat", "CentOS", "Scientific", "RedHatEnterpriseServer" ,"RedHatEnterpriseES", "RedHatEnterpriseWorkstation");
 
-   if(grep { /$os/i } @redhat_clones) {
-      return 1;
-   }
+  if(grep { /$os/i } @redhat_clones) {
+    return 1;
+  }
 }
 
 =item is_fedora
 
  task "foo", "server1", sub {
-    if(is_fedora) {
-       # do something on a fedora system
-    }
+   if(is_fedora) {
+     # do something on a fedora system
+   }
  };
 
 =cut
 sub is_fedora {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   my @fedora_clones = ("Fedora");
+  my @fedora_clones = ("Fedora");
 
-   if(grep { /$os/i } @fedora_clones) {
-      return 1;
-   }
+  if(grep { /$os/i } @fedora_clones) {
+    return 1;
+  }
 }
 
 =item is_suse
 
  task "foo", "server1", sub {
-    if(is_suse) {
-       # do something on a suse system
-    }
+   if(is_suse) {
+     # do something on a suse system
+   }
  };
 
 =cut
 sub is_suse {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   my @suse_clones = ("OpenSuSE", "SuSE", "openSUSE project");
+  my @suse_clones = ("OpenSuSE", "SuSE", "openSUSE project");
 
-   if(grep { /$os/i } @suse_clones) {
-      return 1;
-   }
+  if(grep { /$os/i } @suse_clones) {
+    return 1;
+  }
 }
 
 =item is_mageia
 
  task "foo", "server1", sub {
-    if(is_mageia) {
-       # do something on a mageia system
-    }
+   if(is_mageia) {
+     # do something on a mageia system
+   }
  };
 
 =cut
 sub is_mageia {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   if($os =~ m/mageia/i) {
-      return 1;
-   }
+  if($os =~ m/mageia/i) {
+    return 1;
+  }
 }
 
 
 =item is_debian
 
  task "foo", "server1", sub {
-    if(is_debian) {
-       # do something on a debian system
-    }
+   if(is_debian) {
+     # do something on a debian system
+   }
  };
 
 =cut
 sub is_debian {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   my @debian_clones = ("Debian", "Ubuntu");
+  my @debian_clones = ("Debian", "Ubuntu");
 
-   if(grep { /$os/i } @debian_clones) {
-      return 1;
-   }
+  if(grep { /$os/i } @debian_clones) {
+    return 1;
+  }
 }
 
 =item is_alt
 
  task "foo", "server1", sub {
-    if(is_alt) {
-       # do something on a ALT Linux system
-    }
+   if(is_alt) {
+     # do something on a ALT Linux system
+   }
  };
 
 =cut
 sub is_alt {
-   my $os = @_ ? shift : get_operating_system();
+  my $os = @_ ? shift : get_operating_system();
 
-   my @alt_clones = ("ALT");
+  my @alt_clones = ("ALT");
 
-   if(grep { /$os/i } @alt_clones) {
-      return 1;
-   }
+  if(grep { /$os/i } @alt_clones) {
+    return 1;
+  }
 }
 
 
@@ -342,20 +342,20 @@ sub is_alt {
 Returns true if the target system is a NetBSD.
 
  task "foo", "server1", "server2", sub {
-    if(is_netbsd) {
-       say "This is a netbsd system...";
-    }
-    else {
-       say "This is not a netbsd system...";
-    }
+   if(is_netbsd) {
+     say "This is a netbsd system...";
+   }
+   else {
+     say "This is not a netbsd system...";
+   }
  };
 
 =cut
 sub is_netbsd {
-   my $os = @_ ? shift : get_operating_system();
-   if($os =~ m/NetBSD/i) {
-      return 1;
-   }
+  my $os = @_ ? shift : get_operating_system();
+  if($os =~ m/NetBSD/i) {
+    return 1;
+  }
 }
 
 =item is_openbsd
@@ -363,20 +363,20 @@ sub is_netbsd {
 Returns true if the target system is an OpenBSD.
 
  task "foo", "server1", "server2", sub {
-    if(is_openbsd) {
-       say "This is an openbsd system...";
-    }
-    else {
-       say "This is not an openbsd system...";
-    }
+   if(is_openbsd) {
+     say "This is an openbsd system...";
+   }
+   else {
+     say "This is not an openbsd system...";
+   }
  };
 
 =cut
 sub is_openbsd {
-   my $os = @_ ? shift : get_operating_system();
-   if($os =~ m/OpenBSD/i) {
-      return 1;
-   }
+  my $os = @_ ? shift : get_operating_system();
+  if($os =~ m/OpenBSD/i) {
+    return 1;
+  }
 }
 
 =item is_linux
@@ -384,21 +384,21 @@ sub is_openbsd {
 Returns true if the target system is a Linux System.
 
  task "prepare", "server1", "server2", sub {
-    if(is_linux) {
-      say "This is a linux system...";
-    }
-    else {
-      say "This is not a linux system...";
-    }
+   if(is_linux) {
+    say "This is a linux system...";
+   }
+   else {
+    say "This is not a linux system...";
+   }
  };
 
 =cut
 sub is_linux {
 
-   my $host = Rex::Hardware::Host->get();
-   if(exists $host->{kernelname} && $host->{kernelname} && $host->{kernelname} =~ m/Linux/) {
-      return 1;
-   }
+  my $host = Rex::Hardware::Host->get();
+  if(exists $host->{kernelname} && $host->{kernelname} && $host->{kernelname} =~ m/Linux/) {
+    return 1;
+  }
 }
 
 =item is_bsd
@@ -406,21 +406,21 @@ sub is_linux {
 Returns true if the target system is a BSD System.
 
  task "prepare", "server1", "server2", sub {
-    if(is_bsd) {
-      say "This is a BSD system...";
-    }
-    else {
-      say "This is not a BSD system...";
-    }
+   if(is_bsd) {
+    say "This is a BSD system...";
+   }
+   else {
+    say "This is not a BSD system...";
+   }
  };
 
 =cut
 sub is_bsd {
 
-   my $host = Rex::Hardware::Host->get();
-   if($host->{"kernelname"} =~ m/BSD/) {
-      return 1;
-   }
+  my $host = Rex::Hardware::Host->get();
+  if($host->{"kernelname"} =~ m/BSD/) {
+    return 1;
+  }
 }
 
 =item is_solaris
@@ -428,21 +428,21 @@ sub is_bsd {
 Returns true if the target system is a Solaris System.
 
  task "prepare", "server1", "server2", sub {
-    if(is_solaris) {
-      say "This is a Solaris system...";
-    }
-    else {
-      say "This is not a Solaris system...";
-    }
+   if(is_solaris) {
+    say "This is a Solaris system...";
+   }
+   else {
+    say "This is not a Solaris system...";
+   }
  };
 
 =cut
 sub is_solaris {
 
-   my $host = Rex::Hardware::Host->get();
-   if(exists $host->{kernelname} && $host->{kernelname} && $host->{"kernelname"} =~ m/SunOS/) {
-      return 1;
-   }
+  my $host = Rex::Hardware::Host->get();
+  if(exists $host->{kernelname} && $host->{kernelname} && $host->{"kernelname"} =~ m/SunOS/) {
+    return 1;
+  }
 }
 
 =item is_windows
@@ -452,10 +452,10 @@ Returns true if the target system is a Windows System.
 =cut
 sub is_windows {
 
-   my $host = Rex::Hardware::Host->get();
-   if($host->{"operatingsystem"} =~ m/^MSWin/ || $host->{operatingsystem} eq "Windows") {
-      return 1;
-   }
+  my $host = Rex::Hardware::Host->get();
+  if($host->{"operatingsystem"} =~ m/^MSWin/ || $host->{operatingsystem} eq "Windows") {
+    return 1;
+  }
 
 }
 
@@ -465,10 +465,10 @@ Returns true if the target system is an OpenWrt System.
 
 =cut
 sub is_openwrt {
-   my $os = get_operating_system();
-   if($os =~ m/OpenWrt/i) {
-      return 1;
-   }
+  my $os = get_operating_system();
+  if($os =~ m/OpenWrt/i) {
+    return 1;
+  }
 
 }
 
@@ -478,10 +478,10 @@ Returns true if the target system is a Gentoo System.
 
 =cut
 sub is_gentoo {
-   my $os = get_operating_system();
-   if($os =~ m/Gentoo/i) {
-      return 1;
-   }
+  my $os = get_operating_system();
+  if($os =~ m/Gentoo/i) {
+    return 1;
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,10 +15,10 @@ With this module you can manage the host entries in /etc/hosts.
 =head1 SYNOPSIS
 
  task "create-host", "remoteserver", sub {
-    create_host "rexify.org" => {
-      ip      => "88.198.93.110",
-      aliases => ["www.rexify.org"],
-    };
+   create_host "rexify.org" => {
+    ip    => "88.198.93.110",
+    aliases => ["www.rexify.org"],
+   };
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -49,46 +49,46 @@ use base qw(Rex::Exporter);
 Update or create a /etc/hosts entry.
 
  create_host "rexify.org", {
-    ip      => "88.198.93.110",
-    aliases => ["www.rexify.org", ...]
+   ip    => "88.198.93.110",
+   aliases => ["www.rexify.org", ...]
  };
 
 =cut
 
 sub create_host {
-   my ($host, $data) = @_;
-
-   if(! defined $data->{"ip"}) {
-      Rex::Logger::info("You need to set an ip for $host");
-      die("You need to set an ip for $host");
-   }
-
-   Rex::Logger::debug("Creating host $host");
-
-   my @cur_host = get_host($host);
-   if(! @cur_host) {
-      my $fh = file_append "/etc/hosts";
-      $fh->write($data->{"ip"} . "\t" . $host);
-      if(exists $data->{"aliases"}) {
-         $fh->write(" " . join(" ", @{$data->{"aliases"}}));
-      }
-      $fh->write("\n");
-      $fh->close;
-   }
-   else {
-      my @host = get_host($host);
-      if($data->{"ip"} eq $host[0]->{"ip"} 
-         && join(" ", @{$data->{"aliases"}}) eq join(" ", @{$host[0]->{"aliases"}})) {
-
-         Rex::Logger::debug("Nothing to update for host $host");
-         return;
-
-      }
-      Rex::Logger::debug("Host already exists. Updating...");
-
-      delete_host($host);
-      return create_host(@_);
-   }
+  my ($host, $data) = @_;
+
+  if(! defined $data->{"ip"}) {
+    Rex::Logger::info("You need to set an ip for $host");
+    die("You need to set an ip for $host");
+  }
+
+  Rex::Logger::debug("Creating host $host");
+
+  my @cur_host = get_host($host);
+  if(! @cur_host) {
+    my $fh = file_append "/etc/hosts";
+    $fh->write($data->{"ip"} . "\t" . $host);
+    if(exists $data->{"aliases"}) {
+      $fh->write(" " . join(" ", @{$data->{"aliases"}}));
+    }
+    $fh->write("\n");
+    $fh->close;
+  }
+  else {
+    my @host = get_host($host);
+    if($data->{"ip"} eq $host[0]->{"ip"} 
+      && join(" ", @{$data->{"aliases"}}) eq join(" ", @{$host[0]->{"aliases"}})) {
+
+      Rex::Logger::debug("Nothing to update for host $host");
+      return;
+
+    }
+    Rex::Logger::debug("Host already exists. Updating...");
+
+    delete_host($host);
+    return create_host(@_);
+  }
 }
 
 =item delete_host($host)
@@ -100,29 +100,29 @@ Delete a host from /etc/hosts.
 =cut
 
 sub delete_host {
-   my ($host) = @_;
+  my ($host) = @_;
 
-   Rex::Logger::debug("Deleting host $host");
+  Rex::Logger::debug("Deleting host $host");
 
-   if(get_host($host)) {
-      my $fh = file_read "/etc/hosts";
-      my @content = $fh->read_all;
-      $fh->close;
+  if(get_host($host)) {
+    my $fh = file_read "/etc/hosts";
+    my @content = $fh->read_all;
+    $fh->close;
 
-      my @new_content = grep { ! /\s$host\s?/ } @content;
+    my @new_content = grep { ! /\s$host\s?/ } @content;
 
-      $fh = file_write "/etc/hosts";
-      $fh->write(@new_content);
-      $fh->close;
-   }
-   else {
-      Rex::Logger::debug("Host does not exists.");
-   }
+    $fh = file_write "/etc/hosts";
+    $fh->write(@new_content);
+    $fh->close;
+  }
+  else {
+    Rex::Logger::debug("Host does not exists.");
+  }
 }
 
 =item get_host($host)
 
-Returns the information of $host in /etc/resolv.conf.
+Returns the information of $host in /etc/hosts.
 
  my @host_info = get_host "localhost";
  say "Host-IP: " . $host_info[0]->{"ip"};
@@ -130,55 +130,55 @@ Returns the information of $host in /etc/resolv.conf.
 =cut
 
 sub get_host {
-   my ($hostname, @lines) = @_;
-
-   Rex::Logger::debug("Getting host ($hostname) information");
-
-   my @content;
-   if(@lines) {
-      @content = @lines;
-   }
-   else {
-      my $fh = file_read "/etc/hosts";
-      @content = $fh->read_all;
-      $fh->close;
-   }
-
-   my @hosts = _parse_hosts(@content);
-   my @ret;
-   for my $item (@hosts) {
-      if($item->{host} eq $hostname) {
-         push @ret, $item;
-      }
-      else {
-         push @ret, $item if(grep { $_ eq $hostname } @{$item->{aliases}});
-      }
-   }
-
-   return @ret;
+  my ($hostname, @lines) = @_;
+
+  Rex::Logger::debug("Getting host ($hostname) information");
+
+  my @content;
+  if(@lines) {
+    @content = @lines;
+  }
+  else {
+    my $fh = file_read "/etc/hosts";
+    @content = $fh->read_all;
+    $fh->close;
+  }
+
+  my @hosts = _parse_hosts(@content);
+  my @ret;
+  for my $item (@hosts) {
+    if($item->{host} eq $hostname) {
+      push @ret, $item;
+    }
+    else {
+      push @ret, $item if(grep { $_ eq $hostname } @{$item->{aliases}});
+    }
+  }
+
+  return @ret;
 }
 
 sub _parse_hosts {
-   my (@lines) = @_;
-   
-   my @ret;
+  my (@lines) = @_;
+  
+  my @ret;
 
-   for my $line (@lines) {
-      chomp $line;
-      next if($line =~ m/^#/);
-      next if(! $line);
-      next if($line =~ m/^\s*$/);
+  for my $line (@lines) {
+    chomp $line;
+    next if($line =~ m/^#/);
+    next if(! $line);
+    next if($line =~ m/^\s*$/);
 
-      my ($ip, $_host, @aliases) = split(/\s+/, $line);
+    my ($ip, $_host, @aliases) = split(/\s+/, $line);
 
-      push @ret, { ip => $ip,
-         host => $_host,
-         aliases => \@aliases,
-      };
+    push @ret, { ip => $ip,
+      host => $_host,
+      aliases => \@aliases,
+    };
 
-   }
+  }
 
-   return @ret;
+  return @ret;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -16,8 +16,8 @@ With this module you can get an inventory of your system.
 
  use Data::Dumper;
  task "inventory", "remoteserver", sub {
-    my $inventory = inventor();
-    print Dumper($inventory);
+   my $inventory = inventor();
+   print Dumper($inventory);
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -45,21 +45,20 @@ use base qw(Rex::Exporter);
 This function returns an hashRef of all gathered hardware. Use the Data::Dumper module to see its structure.
 
  task "get-inventory", sub {
-    my $inventory = inventory();
-    print Dumper($inventory);
+   my $inventory = inventory();
+   print Dumper($inventory);
  };
 
 =cut
 
 sub inventory {
-   my $inv = Rex::Inventory->new;
+  my $inv = Rex::Inventory->new;
 
-   return $inv->get;
+  return $inv->get;
 }
 
-
 sub inventor {
-   return inventory();
+  return inventory();
 }
 
 =back
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 =head1 NAME
 
 Rex::Commands::Iptables - Iptable Management Commands
@@ -15,36 +15,36 @@ With this Module you can manage basic Iptables rules.
 =head1 SYNOPSIS
 
  use Rex::Commands::Iptables;
-     
+ 
  task "firewall", sub {
-    iptables_clear;
-     
-    open_port 22;
-    open_port [22, 80] => {
-       dev => "eth0",
-    };
-        
-    close_port 22 => {
-       dev => "eth0",
-    };
-    close_port "all";
-        
-    redirect_port 80 => 10080;
-    redirect_port 80 => {
-       dev => "eth0",
-       to  => 10080,
-    };
-      
-    default_state_rule;
-    default_state_rule dev => "eth0";
-        
-    is_nat_gateway;
-       
-    iptables t => "nat",
-             A => "POSTROUTING",
-             o => "eth0",
-             j => "MASQUERADE";
-    
+   iptables_clear;
+ 
+   open_port 22;
+   open_port [22, 80] => {
+     dev => "eth0",
+   };
+ 
+   close_port 22 => {
+     dev => "eth0",
+   };
+   close_port "all";
+ 
+   redirect_port 80 => 10080;
+   redirect_port 80 => {
+     dev => "eth0",
+     to  => 10080,
+   };
+ 
+   default_state_rule;
+   default_state_rule dev => "eth0";
+ 
+   is_nat_gateway;
+ 
+   iptables t => "nat",
+         A => "POSTROUTING",
+         o => "eth0",
+         j => "MASQUERADE";
+ 
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -71,9 +71,9 @@ use Rex::Commands::Gather;
 
 use Rex::Logger;
 
-@EXPORT = qw(iptables is_nat_gateway iptables_list iptables_clear 
-               open_port close_port redirect_port
-               default_state_rule);
+@EXPORT = qw(iptables is_nat_gateway iptables_list iptables_clear
+          open_port close_port redirect_port
+          default_state_rule);
 
 sub iptables;
 
@@ -82,16 +82,39 @@ sub iptables;
 Open a port for inbound connections.
 
  task "firewall", sub {
-    open_port 22;
-    open_port [22, 80];
-    open_port [22, 80] => { dev => "eth1", };
+   open_port 22;
+   open_port [22, 80];
+   open_port [22, 80],
+     dev => "eth1";
  };
+ 
+ task "firewall", sub {
+  open_port 22,
+    dev    => "eth1",
+    only_if => "test -f /etc/firewall.managed";
+} ;
+
 
 =cut
 sub open_port {
 
-   my ($port, $option) = @_;
-   _open_or_close_port("i", "I", "INPUT", "ACCEPT", $port, $option);
+  my ($port, $option) = @_;
+
+  my %option_h;
+  if(ref $option ne "HASH") {
+    ($port, %option_h) = @_;
+
+    if(exists $option_h{only_if}) {
+      run($option_h{only_if});
+      if($? != 0) {
+        return;
+      }
+    }
+
+    delete $option_h{only_if};
+    $option = { %option_h };
+  }
+  _open_or_close_port("i", "I", "INPUT", "ACCEPT", $port, $option);
 
 }
 
@@ -100,16 +123,34 @@ sub open_port {
 Close a port for inbound connections.
 
  task "firewall", sub {
-    close_port 22;
-    close_port [22, 80];
-    close_port [22, 80] => { dev => "eth0", };
+   close_port 22;
+   close_port [22, 80];
+   close_port [22, 80],
+     dev    => "eth0",
+     only_if => "test -f /etc/firewall.managed";
  };
 
 =cut
 sub close_port {
 
-   my ($port, $option) = @_;
-   _open_or_close_port("i", "A", "INPUT", "DROP", $port, $option);
+  my ($port, $option) = @_;
+
+  my %option_h;
+  if(ref $option ne "HASH") {
+    ($port, %option_h) = @_;
+
+    if(exists $option_h{only_if}) {
+      run($option_h{only_if});
+      if($? != 0) {
+        return;
+      }
+    }
+
+    delete $option_h{only_if};
+    $option = { %option_h };
+  }
+
+  _open_or_close_port("i", "A", "INPUT", "DROP", $port, $option);
 
 }
 
@@ -118,59 +159,59 @@ sub close_port {
 Redirect $in_port to an other local port.
 
  task "redirects", sub {
-    redirect_port 80 => 10080;
-    redirect_port 80 => {
-       to  => 10080,
-       dev => "eth0",
-    };
+   redirect_port 80 => 10080;
+   redirect_port 80 => {
+     to  => 10080,
+     dev => "eth0",
+   };
  };
 
 =cut
 sub redirect_port {
-   my ($in_port, $option) = @_;
+  my ($in_port, $option) = @_;
 
-   my @opts;
+  my @opts;
 
-   push (@opts, "t", "nat");
+  push (@opts, "t", "nat");
 
-   if(! ref($option)) {
-      my $net_info = network_interfaces();
-      my @devs = keys %{$net_info};
+  if(! ref($option)) {
+    my $net_info = network_interfaces();
+    my @devs = keys %{$net_info};
 
-      for my $dev (@devs) {
-         redirect_port($in_port, {
-            dev => $dev,
-            to  => $option,
-         });
-      }
-      
-      return;
-   }
+    for my $dev (@devs) {
+      redirect_port($in_port, {
+        dev => $dev,
+        to  => $option,
+      });
+    }
 
-   unless(exists $option->{"dev"}) {
-      my $net_info = network_interfaces();
-      my @devs = keys %{$net_info};
+    return;
+  }
 
-      for my $dev (@devs) {
-         $option->{"dev"} = $dev;
-         redirect_port($in_port, $option);
-      }
+  unless(exists $option->{"dev"}) {
+    my $net_info = network_interfaces();
+    my @devs = keys %{$net_info};
 
-      return;
-   }
+    for my $dev (@devs) {
+      $option->{"dev"} = $dev;
+      redirect_port($in_port, $option);
+    }
+
+    return;
+  }
 
-   if($option->{"to"} =~ m/^\d+$/) {
-      $option->{"proto"} ||= "tcp";
+  if($option->{"to"} =~ m/^\d+$/) {
+    $option->{"proto"} ||= "tcp";
 
-      push(@opts, "I", "PREROUTING", "i", $option->{"dev"}, "p", $option->{"proto"}, "m", $option->{"proto"});
-      push(@opts, "dport", $in_port, "j", "REDIRECT", "to-ports", $option->{"to"});
+    push(@opts, "I", "PREROUTING", "i", $option->{"dev"}, "p", $option->{"proto"}, "m", $option->{"proto"});
+    push(@opts, "dport", $in_port, "j", "REDIRECT", "to-ports", $option->{"to"});
 
-   }
-   else {
-      Rex::Logger::info("Redirect to other hosts isn't supported right now. Please do it by hand.");
-   }
+  }
+  else {
+    Rex::Logger::info("Redirect to other hosts isn't supported right now. Please do it by hand.");
+  }
 
-   iptables @opts;
+  iptables @opts;
 }
 
 =item iptables(@params)
@@ -178,60 +219,60 @@ sub redirect_port {
 Write standard iptable comands.
 
  task "firewall", sub {
-    iptables t => "nat", A => "POSTROUTING", o => "eth0", j => "MASQUERADE";
-    iptables t => "filter", i => "eth0", m => "state", state => "RELATED,ESTABLISHED", j => "ACCEPT";
-        
-    iptables "flush";
-    iptables -F;
-    iptables flush => "filter";
-    iptables -F => "filter";
+   iptables t => "nat", A => "POSTROUTING", o => "eth0", j => "MASQUERADE";
+   iptables t => "filter", i => "eth0", m => "state", state => "RELATED,ESTABLISHED", j => "ACCEPT";
+ 
+   iptables "flush";
+   iptables -F;
+   iptables flush => "filter";
+   iptables -F => "filter";
  };
 
 =cut
 sub iptables {
-   my (@params) = @_;
-
-   if($params[0] eq "flush" || $params[0] eq "-flush" || $params[0] eq "-F") {
-      if($params[1]) {
-         run "iptables -F -t $params[1]";
-      }
-      else {
-         run "iptables -F";
-      }
-
-      return;
-   }
-
-   my $cmd = "";
-   my $n = -1;
-   while( $params[++$n] ) {
-      my ($key, $val) = reverse @params[$n, $n++];
-
-      if(ref($key) eq "ARRAY") {
-         $cmd .= join(" ", @{$key});
-         last;
-      }
-
-      if(length($key) == 1) {
-         $cmd .= "-$key $val ";
-      }
-      else {
-         $cmd .= "--$key '$val' ";
-      }
-   }
-
-   if(can_run("iptables")) {
-      run "iptables $cmd";
-
-      if($? != 0) {
-         Rex::Logger::info("Error setting iptable rule: $cmd", "warn");
-         die("Error setting iptable rule: $cmd");
-      }
-   }
-   else {
-      Rex::Logger::info("IPTables not found.");
-      die("IPTables not found.");
-   }
+  my (@params) = @_;
+
+  if($params[0] eq "flush" || $params[0] eq "-flush" || $params[0] eq "-F") {
+    if($params[1]) {
+      run "iptables -F -t $params[1]";
+    }
+    else {
+      run "iptables -F";
+    }
+
+    return;
+  }
+
+  my $cmd = "";
+  my $n = -1;
+  while( $params[++$n] ) {
+    my ($key, $val) = reverse @params[$n, $n++];
+
+    if(ref($key) eq "ARRAY") {
+      $cmd .= join(" ", @{$key});
+      last;
+    }
+
+    if(length($key) == 1) {
+      $cmd .= "-$key $val ";
+    }
+    else {
+      $cmd .= "--$key '$val' ";
+    }
+  }
+
+  if(can_run("iptables")) {
+    run "iptables $cmd";
+
+    if($? != 0) {
+      Rex::Logger::info("Error setting iptable rule: $cmd", "warn");
+      die("Error setting iptable rule: $cmd");
+    }
+  }
+  else {
+    Rex::Logger::info("IPTables not found.");
+    die("IPTables not found.");
+  }
 }
 
 =item is_nat_gateway
@@ -239,31 +280,31 @@ sub iptables {
 This function create a nat gateway for the device the default route points to.
 
  task "make-gateway", sub {
-    is_nat_gateway;
+   is_nat_gateway;
  };
 
 =cut
 sub is_nat_gateway {
 
-   Rex::Logger::debug("Changing this system to a nat gateway.");
+  Rex::Logger::debug("Changing this system to a nat gateway.");
 
-   if(can_run("ip")) {
+  if(can_run("ip")) {
 
-      my @iptables_option = ();
+    my @iptables_option = ();
 
-      my ($default_line) = run "/sbin/ip r |grep ^default";
-      my ($dev) = ($default_line =~ m/dev ([a-z0-9]+)/i);
-      Rex::Logger::debug("Default GW Device is $dev");
+    my ($default_line) = run "/sbin/ip r |grep ^default";
+    my ($dev) = ($default_line =~ m/dev ([a-z0-9]+)/i);
+    Rex::Logger::debug("Default GW Device is $dev");
 
-      sysctl "net.ipv4.ip_forward" => 1;
-      iptables t => "nat", A => "POSTROUTING", o => $dev, j => "MASQUERADE";
+    sysctl "net.ipv4.ip_forward" => 1;
+    iptables t => "nat", A => "POSTROUTING", o => $dev, j => "MASQUERADE";
 
-   }
-   else {
+  }
+  else {
 
-      Rex::Logger::info("No /sbin/ip found.");
+    Rex::Logger::info("No /sbin/ip found.");
 
-   }
+  }
 
 }
 
@@ -272,25 +313,25 @@ sub is_nat_gateway {
 Set the default state rules for the given device.
 
  task "firewall", sub {
-    default_state_rule(dev => "eth0");
+   default_state_rule(dev => "eth0");
  };
 
 =cut
 sub default_state_rule {
-   my (%option) = @_;
+  my (%option) = @_;
 
-   unless(exists $option{"dev"}) {
-      my $net_info = network_interfaces();
-      my @devs = keys %{$net_info};
+  unless(exists $option{"dev"}) {
+    my $net_info = network_interfaces();
+    my @devs = keys %{$net_info};
 
-      for my $dev (@devs) {
-         default_state_rule(dev => $dev);
-      }
+    for my $dev (@devs) {
+      default_state_rule(dev => $dev);
+    }
 
-      return;
-   }
+    return;
+  }
 
-   iptables t => "filter", A => "INPUT", i => $option{"dev"}, m => "state", state => "RELATED,ESTABLISHED", j => "ACCEPT";
+  iptables t => "filter", A => "INPUT", i => $option{"dev"}, m => "state", state => "RELATED,ESTABLISHED", j => "ACCEPT";
 }
 
 =item iptables_list
@@ -298,48 +339,48 @@ sub default_state_rule {
 List all iptables rules.
 
  task "list-iptables", sub {
-    print Dumper iptables_list;
+   print Dumper iptables_list;
  };
 
 =cut
 sub iptables_list {
-   my @lines = run "/sbin/iptables-save";
-   _iptables_list(@lines);
+  my @lines = run "/sbin/iptables-save";
+  _iptables_list(@lines);
 }
-   
+
 sub _iptables_list {
-   my (%tables, $ret);
-   my (@lines) = @_;
+  my (%tables, $ret);
+  my (@lines) = @_;
 
-   my ($current_table);
-   for my $line (@lines) {
-      chomp $line;
+  my ($current_table);
+  for my $line (@lines) {
+    chomp $line;
 
-      next if($line eq "COMMIT");
-      next if($line =~ m/^#/);
-      next if($line =~ m/^:/);
+    next if($line eq "COMMIT");
+    next if($line =~ m/^#/);
+    next if($line =~ m/^:/);
 
-      if($line =~ m/^\*([a-z]+)$/) {
-         $current_table = $1;
-         $tables{$current_table} = [];
-         next;
-      }
+    if($line =~ m/^\*([a-z]+)$/) {
+      $current_table = $1;
+      $tables{$current_table} = [];
+      next;
+    }
 
-      #my @parts = grep { ! /^\s+$/ && ! /^$/ } split (/(\-\-?[^\s]+\s[^\s]+)/i, $line);
-      my @parts = grep { ! /^\s+$/ && ! /^$/ } split (/^\-\-?|\s+\-\-?/i, $line); 
+    #my @parts = grep { ! /^\s+$/ && ! /^$/ } split (/(\-\-?[^\s]+\s[^\s]+)/i, $line);
+    my @parts = grep { ! /^\s+$/ && ! /^$/ } split (/^\-\-?|\s+\-\-?/i, $line);
 
-      my @option = ();
-      for my $part (@parts) {
-         my ($key, $value) = split(/\s/, $part, 2);
-         #$key =~ s/^\-+//;
-         push(@option, $key => $value);
-      }
+    my @option = ();
+    for my $part (@parts) {
+      my ($key, $value) = split(/\s/, $part, 2);
+      #$key =~ s/^\-+//;
+      push(@option, $key => $value);
+    }
 
-      push (@{$ret->{$current_table}}, \@option);
+    push (@{$ret->{$current_table}}, \@option);
 
-   }
+  }
 
-   return $ret;
+  return $ret;
 }
 
 =item iptables_clear
@@ -347,76 +388,106 @@ sub _iptables_list {
 Remove all iptables rules.
 
  task "no-firewall", sub {
-    iptables_clear;
+   iptables_clear;
  };
 
 =cut
 sub iptables_clear {
 
-   for my $table (qw/nat mangle filter/) {
-      iptables t => $table, F => '';
-      iptables t => $table, X => '';
-   }
+  for my $table (qw/nat mangle filter/) {
+    iptables t => $table, F => '';
+    iptables t => $table, X => '';
+  }
 
-   for my $p (qw/INPUT FORWARD OUTPUT/) {
-      iptables P => $p, ["ACCEPT"];
-   }
+  for my $p (qw/INPUT FORWARD OUTPUT/) {
+    iptables P => $p, ["ACCEPT"];
+  }
 
 }
 
 sub _open_or_close_port {
-   my ($dev_type, $push_type, $chain, $jump, $port, $option) = @_;
+  my ($dev_type, $push_type, $chain, $jump, $port, $option) = @_;
+
+  my @opts;
+
+  push(@opts, "t", "filter", "$push_type", "$chain");
+
+  unless(exists $option->{"dev"}) {
+    my $net_info = network_interfaces();
+    my @dev = keys %{$net_info};
+    $option->{"dev"} = \@dev;
+  }
+
+  if(exists $option->{"dev"} && ! ref($option->{"dev"})) {
+    push(@opts, "$dev_type", $option->{"dev"});
+  }
+  elsif(ref($option->{"dev"}) eq "ARRAY") {
+    for my $dev (@{$option->{"dev"}}) {
+      my $new_option = $option;
+      $new_option->{"dev"} = $dev;
+
+      _open_or_close_port($dev_type, $push_type, $chain, $jump, $port, $new_option);
+    }
+
+    return;
+  }
+
+  if(exists $option->{"proto"}) {
+    push(@opts, "p", $option->{"proto"});
+    push(@opts, "m", $option->{"proto"});
+  }
+  else {
+    push(@opts, "p", "tcp");
+    push(@opts, "m", "tcp");
+  }
+
+  if($port eq "all") {
+    push(@opts, "j", "$jump");
+  }
+  else {
+    if(ref($port) eq "ARRAY") {
+      for my $port_num (@{$port}) {
+        _open_or_close_port($dev_type, $push_type, $chain, $jump, $port_num, $option);
+      }
+      return;
+    }
 
-   my @opts;
+    push(@opts, "dport", $port);
+    push(@opts, "j", $jump);
+  }
 
-   push(@opts, "t", "filter", "$push_type", "$chain");
+  if(_rule_exists(@opts)) {
+    Rex::Logger::debug("IPTables rule already exists. skipping...");
+    return;
+  }
 
-   unless(exists $option->{"dev"}) {
-      my $net_info = network_interfaces();
-      my @dev = keys %{$net_info};
-      $option->{"dev"} = \@dev;
-   }
+  iptables @opts;
 
-   if(exists $option->{"dev"} && ! ref($option->{"dev"})) {
-      push(@opts, "$dev_type", $option->{"dev"});
-   }
-   elsif(ref($option->{"dev"}) eq "ARRAY") {
-      for my $dev (@{$option->{"dev"}}) {
-         my $new_option = $option;
-         $new_option->{"dev"} = $dev;
+}
 
-         _open_or_close_port($dev_type, $push_type, $chain, $jump, $port, $new_option);
-      }
+sub _rule_exists {
+  my (@check_rule) = @_;
 
-      return;
-   }
-
-   if(exists $option->{"proto"}) {
-      push(@opts, "p", $option->{"proto"});
-      push(@opts, "m", $option->{"proto"});
-   }
-   else {
-      push(@opts, "p", "tcp");
-      push(@opts, "m", "tcp");
-   }
-
-   if($port eq "all") {
-      push(@opts, "j", "$jump");
-   }
-   else {
-      if(ref($port) eq "ARRAY") {
-         for my $port_num (@{$port}) {
-            _open_or_close_port($dev_type, $push_type, $chain, $jump, $port_num, $option);
-         }
-         return;
-      }
+  shift @check_rule;
+  shift @check_rule;
+  shift @check_rule;
+
+  my $str_check_rule = join(" ", "A", @check_rule);
 
-      push(@opts, "j", $jump);
-      push(@opts, "dport", $port);
-   }
+  my $current_tables = iptables_list();
+  if(exists $current_tables->{filter}) {
+    for my $rule (@{ $current_tables->{filter} }) {
+      my $str_rule = join(" ", @{ $rule });
+      $str_rule =~ s/\s$//;
 
-   iptables @opts;
+      Rex::Logger::debug("comparing: '$str_rule' == '$str_check_rule'");
+      if($str_rule eq $str_check_rule) {
+        return 1;
+      }
+    }
+  }
 
+  return 0;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -48,99 +48,99 @@ use vars qw(@EXPORT);
 This function load or unload a kernel module.
 
  task "load", sub {
-    kmod load => "ipmi_si";
+   kmod load => "ipmi_si";
  };
-
+ 
  task "unload", sub {
-    kmod unload => "ipmi_si";
+   kmod unload => "ipmi_si";
  };
 
 If you're using NetBSD or OpenBSD you have to specify the complete path and, if needed the entry function.
 
  task "load", sub {
-    kmod load => "/usr/lkm/ntfs.o";
-    kmod load => "/path/to/module.o", entry => "entry_function";
+   kmod load => "/usr/lkm/ntfs.o";
+   kmod load => "/path/to/module.o", entry => "entry_function";
  };
 
 =cut
 
 sub kmod {
-   my ($action, $module, @rest) = @_;
-
-   my $options = { @_ };
-   
-   my $os = get_operating_system();
-
-   my $load_command = "modprobe";
-   my $unload_command = "rmmod";
+  my ($action, $module, @rest) = @_;
+
+  my $options = { @_ };
+  
+  my $os = get_operating_system();
+
+  my $load_command = "modprobe";
+  my $unload_command = "rmmod";
+
+  if($os eq "FreeBSD") {
+    $load_command = "kldload";
+    $unload_command = "kldunload";
+  }
+  elsif($os eq "NetBSD" || $os eq "OpenBSD") {
+    $load_command = "modload";
+    $unload_command = "modunload";
+
+    if($options->{"entry"}) {
+      $load_command .= " -e " . $options->{"entry"};
+    }
+  } elsif($os eq "SunOS") {
+    $load_command = "modload -p ";
+    
+    if($options->{"exec_file"}) {
+      $load_command .= " -e " . $options->{"exec_file"} . " ";
+    }
+
+    $unload_command = sub {
+      my @mod_split = split(/\//, $module);
+      my $mod = $mod_split[-1];
+
+      my ($mod_id) = grep { $_=$1 if $_ =~ qr{(\d+).*$mod} } run "modinfo";
+      my $cmd = "modunload -i $mod_id";
 
-   if($os eq "FreeBSD") {
-      $load_command = "kldload";
-      $unload_command = "kldunload";
-   }
-   elsif($os eq "NetBSD" || $os eq "OpenBSD") {
-      $load_command = "modload";
-      $unload_command = "modunload";
-
-      if($options->{"entry"}) {
-         $load_command .= " -e " . $options->{"entry"};
-      }
-   } elsif($os eq "SunOS") {
-      $load_command = "modload -p ";
-      
       if($options->{"exec_file"}) {
-         $load_command .= " -e " . $options->{"exec_file"} . " ";
-      }
-
-      $unload_command = sub {
-         my @mod_split = split(/\//, $module);
-         my $mod = $mod_split[-1];
-
-         my ($mod_id) = grep { $_=$1 if $_ =~ qr{(\d+).*$mod} } run "modinfo";
-         my $cmd = "modunload -i $mod_id";
-
-         if($options->{"exec_file"}) {
-            $cmd .= " -e " . $options->{"exec_file"};
-         }
-
-         return $cmd;
-      };
-   } elsif($os eq "OpenWrt") {
-      $load_command = "insmod";
-   }
-
-
-   if($action eq "load") {
-      Rex::Logger::debug("Loading Kernel Module: $module");
-      run "$load_command $module";
-      unless($? == 0) {
-         Rex::Logger::info("Error loading Kernel Module: $module", "warn");
-         die("Error loading Kernel Module: $module");
-      }
-      else {
-         Rex::Logger::debug("Kernel Module $module loaded.");
-      }
-   }
-   elsif($action eq "unload") {
-      Rex::Logger::debug("Unloading Kernel Module: $module");
-      my $unload_command_str = $unload_command;
-      if(ref($unload_command) eq "CODE") {
-         $unload_command_str = &$unload_command();
+        $cmd .= " -e " . $options->{"exec_file"};
       }
 
-      run "$unload_command_str $module";
-      unless($? == 0) {
-         Rex::Logger::info("Error unloading Kernel Module: $module", "warn");
-         die("Error unloading Kernel Module: $module");
-      }
-      else {
-         Rex::Logger::debug("Kernel Module $module unloaded.");
-      } 
-   }
-   else {
-      Rex::Logger::info("Unknown action $action");
-      die("Unknown action $action");
-   }
+      return $cmd;
+    };
+  } elsif($os eq "OpenWrt") {
+    $load_command = "insmod";
+  }
+
+
+  if($action eq "load") {
+    Rex::Logger::debug("Loading Kernel Module: $module");
+    run "$load_command $module";
+    unless($? == 0) {
+      Rex::Logger::info("Error loading Kernel Module: $module", "warn");
+      die("Error loading Kernel Module: $module");
+    }
+    else {
+      Rex::Logger::debug("Kernel Module $module loaded.");
+    }
+  }
+  elsif($action eq "unload") {
+    Rex::Logger::debug("Unloading Kernel Module: $module");
+    my $unload_command_str = $unload_command;
+    if(ref($unload_command) eq "CODE") {
+      $unload_command_str = &$unload_command();
+    }
+
+    run "$unload_command_str $module";
+    unless($? == 0) {
+      Rex::Logger::info("Error unloading Kernel Module: $module", "warn");
+      die("Error unloading Kernel Module: $module");
+    }
+    else {
+      Rex::Logger::debug("Kernel Module $module unloaded.");
+    } 
+  }
+  else {
+    Rex::Logger::info("Unknown action $action");
+    die("Unknown action $action");
+  }
 }
 
 =back
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 
 =head1 NAME
 
@@ -16,7 +16,7 @@ With this module you can get information of your lvm setup.
 =head1 SYNOPSIS
 
  use Rex::Commands::LVM;
-    
+   
  my @physical_devices = pvs;
  my @volume_groups = vgs;
  my @logical_volumes = lvs;
@@ -31,14 +31,14 @@ With this module you can get information of your lvm setup.
 
 
 package Rex::Commands::LVM;
-   
+  
 use strict;
 use warnings;
-   
+  
 require Rex::Exporter;
 use base qw(Rex::Exporter);
 use vars qw(@EXPORT);
-    
+   
 @EXPORT = qw(pvs vgs lvs pvcreate vgcreate lvcreate vgextend);
 
 use Rex::Commands::Run;
@@ -49,43 +49,43 @@ Get Information of all your physical volumes.
 
  use Data::Dumper;
  use Rex::Commands::LVM;
-   
+  
  task "lvm", sub {
-    my @physical_volumes = pvs;
-      
-    for my $physical_volume (@physical_volumes) {
-       say Dumper($physical_volume);
-    }
+   my @physical_volumes = pvs;
+    
+   for my $physical_volume (@physical_volumes) {
+     say Dumper($physical_volume);
+   }
  };
 
 =cut
 
 sub pvs {
-   
-   my @lines = run 'pvdisplay --units b --columns --separator "|" --noheadings';
-   if($? != 0) {
-      die("Error running pvdisplay");
-   }
-
-   my @ret;
-   for my $line (@lines) {
-      chomp $line;
-      $line =~ s/^\s+//g;
-      my ($phy_vol, $vol_group, $format, $attr, $psize, $pfree) = split(/\|/, $line);
-      $pfree =~ s/B$//;
-      $psize =~ s/B$//;
-
-      push(@ret, {
-         physical_volume => $phy_vol,
-         volume_group => $vol_group,
-         format => $format,
-         attributes => $attr,
-         size => $psize,
-         free => $pfree,
-      });
-   }
-
-   return @ret;
+  
+  my @lines = run 'pvdisplay --units b --columns --separator "|" --noheadings';
+  if($? != 0) {
+    die("Error running pvdisplay");
+  }
+
+  my @ret;
+  for my $line (@lines) {
+    chomp $line;
+    $line =~ s/^\s+//g;
+    my ($phy_vol, $vol_group, $format, $attr, $psize, $pfree) = split(/\|/, $line);
+    $pfree =~ s/B$//;
+    $psize =~ s/B$//;
+
+    push(@ret, {
+      physical_volume => $phy_vol,
+      volume_group => $vol_group,
+      format => $format,
+      attributes => $attr,
+      size => $psize,
+      free => $pfree,
+    });
+  }
+
+  return @ret;
 
 }
 
@@ -95,50 +95,50 @@ Get Information of all your volume groups.
 
  use Data::Dumper;
  use Rex::Commands::LVM;
-    
+   
  task "lvm", sub {
-    my @volume_groups = vgs;
-      
-    for my $volume_group (@volume_groups) {
-       say Dumper($volume_group);
-    }
+   my @volume_groups = vgs;
+    
+   for my $volume_group (@volume_groups) {
+     say Dumper($volume_group);
+   }
  };
 
 =cut
 
 sub vgs {
 
-   my ($vg) = @_;
+  my ($vg) = @_;
 
 
-   my $cmd = 'vgdisplay --units b --columns --separator "|" --noheadings -o "pv_name,vg_name,vg_size,vg_free,vg_attr"';
-   if($vg) {
-      $cmd .= " $vg";
-   }
+  my $cmd = 'vgdisplay --units b --columns --separator "|" --noheadings -o "pv_name,vg_name,vg_size,vg_free,vg_attr"';
+  if($vg) {
+    $cmd .= " $vg";
+  }
 
-   my @lines = run $cmd;
-   if($? != 0) {
-      die("Error running vgdisplay");
-   }
+  my @lines = run $cmd;
+  if($? != 0) {
+    die("Error running vgdisplay");
+  }
 
-   my @ret;
-   for my $line (@lines) {
-      chomp $line;
-      $line =~ s/^\s+//g;
-      my ($pv_name, $vg_name, $vg_size, $vg_free, $vg_attr) = split(/\|/, $line);
-      $vg_free =~ s/B$//;
-      $vg_size =~ s/B$//;
-      
-      push(@ret, {
-         physical_volume => $pv_name,
-         volume_group => $vg_name,
-         size => $vg_size,
-         free => $vg_free,
-         attributes => $vg_attr,
-      });
-   }
+  my @ret;
+  for my $line (@lines) {
+    chomp $line;
+    $line =~ s/^\s+//g;
+    my ($pv_name, $vg_name, $vg_size, $vg_free, $vg_attr) = split(/\|/, $line);
+    $vg_free =~ s/B$//;
+    $vg_size =~ s/B$//;
+    
+    push(@ret, {
+      physical_volume => $pv_name,
+      volume_group => $vg_name,
+      size => $vg_size,
+      free => $vg_free,
+      attributes => $vg_attr,
+    });
+  }
 
-   return @ret;
+  return @ret;
 
 }
 
@@ -148,121 +148,121 @@ Get Information of all your logical volumes.
 
  use Data::Dumper;
  use Rex::Commands::LVM;
-    
+   
  task "lvm", sub {
-    my @logical_volumes = lvs;
-      
-    for my $logical_volume (@logical_volumes) {
-       say Dumper($logical_volume);
-    }
+   my @logical_volumes = lvs;
+    
+   for my $logical_volume (@logical_volumes) {
+     say Dumper($logical_volume);
+   }
  };
 
 =cut
 
 sub lvs {
 
-   my ($vg) = @_;
-
-   my $cmd = 'lvdisplay --units b --columns --separator "|" -o "lv_name,vg_name,lv_attr,lv_size" --noheading';
-   if($vg) {
-      $cmd .= " " . $vg;
-   }
-
-   my @lines = run $cmd;
-   if($? != 0) {
-      die("Error running lvdisplay");
-   }
-
-   my @ret;
-   for my $line (@lines) {
-      chomp $line;
-      $line =~ s/^\s+//g;
-
-      my($lv_name, $vg_name, $lv_attr, $lv_size) = split(/\|/, $line);
-      $lv_size =~ s/B$//;
-      push(@ret, {
-         name => $lv_name,
-         path => "/dev/$vg_name/$lv_name",
-         attributes => $lv_attr,
-         size => $lv_size,
-      });
-   }
-
-   return @ret;
+  my ($vg) = @_;
+
+  my $cmd = 'lvdisplay --units b --columns --separator "|" -o "lv_name,vg_name,lv_attr,lv_size" --noheading';
+  if($vg) {
+    $cmd .= " " . $vg;
+  }
+
+  my @lines = run $cmd;
+  if($? != 0) {
+    die("Error running lvdisplay");
+  }
+
+  my @ret;
+  for my $line (@lines) {
+    chomp $line;
+    $line =~ s/^\s+//g;
+
+    my($lv_name, $vg_name, $lv_attr, $lv_size) = split(/\|/, $line);
+    $lv_size =~ s/B$//;
+    push(@ret, {
+      name => $lv_name,
+      path => "/dev/$vg_name/$lv_name",
+      attributes => $lv_attr,
+      size => $lv_size,
+    });
+  }
+
+  return @ret;
 }
 
 
 sub pvcreate {
-   my ($dev) = @_;
-   my $s = run "pvcreate $dev";
-   if($? != 0) {
-      die("Error creating pv.\n$s\n");
-   }
+  my ($dev) = @_;
+  my $s = run "pvcreate $dev";
+  if($? != 0) {
+    die("Error creating pv.\n$s\n");
+  }
 
-   return 1;
+  return 1;
 }
 
 sub vgcreate {
-   my ($vgname, @devices) = @_;
+  my ($vgname, @devices) = @_;
 
-   my $s = run "vgcreate $vgname " . join(" ", @devices);
-   if($? != 0) {
-      die("Error creating vg.\n$s\n");
-   }
+  my $s = run "vgcreate $vgname " . join(" ", @devices);
+  if($? != 0) {
+    die("Error creating vg.\n$s\n");
+  }
 
-   return 1;
+  return 1;
 }
 
 sub lvcreate {
-   my ($lvname, %option) = @_;
+  my ($lvname, %option) = @_;
 
-   if(! exists $option{size} || ! exists $option{onvg}) {
-      die("Missing parameter size or onvg.");
-   }
+  if(! exists $option{size} || ! exists $option{onvg}) {
+    die("Missing parameter size or onvg.");
+  }
 
-   unless($lvname =~ m/^[a-z0-9\-_]+$/i) {
-      die("Error in lvname. Allowed characters a-z, 0-9 and _- .");
-   }
+  unless($lvname =~ m/^[a-z0-9\-_]+$/i) {
+    die("Error in lvname. Allowed characters a-z, 0-9 and _- .");
+  }
 
-   my $size = $option{size};
-   if($size =~ m/^[0-9]+$/) { $size .= "M"; }
-   my $onvg = $option{onvg};
-
-   my $s = run "lvcreate -n $lvname -L $size $onvg";
-
-   my $lv_path = $option{onvg} . "/" . $lvname;
-
-   if(exists $option{fstype}) {
-      if(can_run("mkfs.$option{fstype}")) {
-         Rex::Logger::info("Creating filesystem $option{fstype} on /dev/$lv_path"); 
-         run "mkfs.$option{fstype} /dev/$lv_path";
-      }
-      elsif($option{fstype} eq "swap") {
-         Rex::Logger::info("Creating swap space on /dev/$lv_path");
-         run "mkswap -f /dev/$lv_path";
-      }
-      else {
-         die("Can't format partition with $option{fstype}");
-      }
-   }
+  my $size = $option{size};
+  if($size =~ m/^[0-9]+$/) { $size .= "M"; }
+  my $onvg = $option{onvg};
 
-   if($? != 0) {
-      die("Error creating lv.\n$s\n");
-   }
+  my $s = run "lvcreate -n $lvname -L $size $onvg";
+
+  my $lv_path = $option{onvg} . "/" . $lvname;
 
-   return $lv_path;
+  if(exists $option{fstype}) {
+    if(can_run("mkfs.$option{fstype}")) {
+      Rex::Logger::info("Creating filesystem $option{fstype} on /dev/$lv_path"); 
+      run "mkfs.$option{fstype} /dev/$lv_path";
+    }
+    elsif($option{fstype} eq "swap") {
+      Rex::Logger::info("Creating swap space on /dev/$lv_path");
+      run "mkswap -f /dev/$lv_path";
+    }
+    else {
+      die("Can't format partition with $option{fstype}");
+    }
+  }
+
+  if($? != 0) {
+    die("Error creating lv.\n$s\n");
+  }
+
+  return $lv_path;
 }
 
 sub vgextend {
-   my ($vgname, @devices) = @_;
+  my ($vgname, @devices) = @_;
 
-   my $s = run "vgextend $vgname " . join(" ", @devices);
+  my $s = run "vgextend $vgname " . join(" ", @devices);
 
-   if($? != 0) {
-      die("Error extending vg.\n$s\n");
-   }
+  if($? != 0) {
+    die("Error extending vg.\n$s\n");
+  }
 
-   return 1;
+  return 1;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -48,63 +48,63 @@ use vars qw(@EXPORT);
 This function will return the md5 sum (hexadecimal) for the given file.
 
  task "md5", "server01", sub {
-    my $md5 = md5("/etc/passwd");
+   my $md5 = md5("/etc/passwd");
  };
 
 =cut
 
 sub md5 {
-   my ($file) = @_;
+  my ($file) = @_;
 
-   my $fs = Rex::Interface::Fs->create;
-   if($fs->is_file($file)) {
+  my $fs = Rex::Interface::Fs->create;
+  if($fs->is_file($file)) {
 
-      Rex::Logger::debug("Calculating Checksum (md5) of $file");
+    Rex::Logger::debug("Calculating Checksum (md5) of $file");
 
-      my $script = q|
-      use Digest::MD5;
-      print Digest::MD5::md5_hex(<>) . "\n";
-      |;
+    my $script = q|
+    use Digest::MD5;
+    print Digest::MD5::md5_hex(<>) . "\n";
+    |;
 
-      my $rnd_file = get_tmp_file;
+    my $rnd_file = get_tmp_file;
 
-      my $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write($script);
-      $fh->close;
+    my $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write($script);
+    $fh->close;
 
-      my $exec = Rex::Interface::Exec->create;
-      my $md5;
+    my $exec = Rex::Interface::Exec->create;
+    my $md5;
 
-      if(Rex::is_local() && $^O =~ m/^MSWin/) {
-         $md5 = $exec->exec("perl $rnd_file \"$file\"");
-      }
-      else {
-         $md5 = $exec->exec("perl $rnd_file '$file'");
-      }
+    if(Rex::is_local() && $^O =~ m/^MSWin/) {
+      $md5 = $exec->exec("perl $rnd_file \"$file\"");
+    }
+    else {
+      $md5 = $exec->exec("perl $rnd_file '$file'");
+    }
 
-      unless($? == 0) {
-         ($md5) = split(/\s/, $exec->exec("md5sum '$file'"));
-      }
+    unless($? == 0) {
+      ($md5) = split(/\s/, $exec->exec("md5sum '$file'"));
+    }
 
-      unless($? == 0) {
-         Rex::Logger::info("Unable to get md5 sum of $file");
-         die("Unable to get md5 sum of $file");
-      }
+    unless($? == 0) {
+      Rex::Logger::info("Unable to get md5 sum of $file");
+      die("Unable to get md5 sum of $file");
+    }
 
-      Rex::Interface::Fs->create->unlink($rnd_file);
+    Rex::Interface::Fs->create->unlink($rnd_file);
 
-      Rex::Logger::debug("MD5SUM ($file): $md5");
-      $md5 =~ s/[\r\n]//gms;
-      return $md5;
-   
-   }
-   else {
-      
-      Rex::Logger::debug("File $file not found.");
-      die("File $file not found");
+    Rex::Logger::debug("MD5SUM ($file): $md5");
+    $md5 =~ s/[\r\n]//gms;
+    return $md5;
+  
+  }
+  else {
+    
+    Rex::Logger::debug("File $file not found.");
+    die("File $file not found");
 
-   }
+  }
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,13 +15,13 @@ With this module you can get information of the routing table, current network c
 =head1 SYNOPSIS
 
  use Rex::Commands::Network;
-    
+   
  my @routes = route;
  print Dumper(\@routes);
-    
+   
  my $default_gw = default_gateway;
  default_gateway "192.168.2.1";
-     
+    
  my @netstat = netstat;
  my @tcp_connections = grep { $_->{"proto"} eq "tcp" } netstat;
 
@@ -53,7 +53,7 @@ Get routing information
 
 =cut
 sub route {
-   return Rex::Hardware::Network::route();
+  return Rex::Hardware::Network::route();
 }
 
 =item default_gateway([$default_gw])
@@ -62,7 +62,7 @@ Get or set the default gateway.
 
 =cut
 sub default_gateway {
-   return Rex::Hardware::Network::default_gateway();
+  return Rex::Hardware::Network::default_gateway();
 }
 
 =item netstat
@@ -71,7 +71,7 @@ Get network connection information
 
 =cut
 sub netstat {
-   return Rex::Hardware::Network::netstat();
+  return Rex::Hardware::Network::netstat();
 }
 
 =back
@@ -0,0 +1,58 @@
+#
+# (c) Jan Gehring <jan.gehring@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+=head1 NAME
+
+Rex::Commands::Notify - Notify a resource to execute.
+
+=head1 DESCRIPTION
+
+This module exports the notify() function.
+
+=head1 SYNOPSIS
+
+ notify "run", "extract-archive";
+ notify $type, $resource_name;
+
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=cut
+
+
+package Rex::Commands::Notify;
+
+use strict;
+use warnings;
+
+require Rex::Exporter;
+
+use vars qw(@EXPORT);
+use base qw(Rex::Exporter);
+
+@EXPORT = qw(notify);
+
+=item notify($resource_type, $resource_name)
+
+This function will notify the given $resource_name of the given $resource_type to execute.
+
+=cut
+
+sub notify {
+  my ($resource_type, $resource_name) = @_;
+  my $notify = Rex::get_current_connection()->{notify};
+  $notify->run(
+    type => $resource_type,
+    name => $resource_name,
+  );
+}
+
+=back
+
+=cut
+
+1;
@@ -1,10 +1,10 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
-   
+  
+  
 =head1 NAME
 
 Rex::Commands::Partition - Partition module
@@ -16,7 +16,7 @@ With this Module you can partition your harddrive.
 =head1 SYNOPSIS
 
  use Rex::Commands::Partition;
-     
+    
 
 
 =head1 EXPORTED FUNCTIONS
@@ -26,7 +26,7 @@ With this Module you can partition your harddrive.
 =cut
 
 package Rex::Commands::Partition;
-   
+  
 use strict;
 use warnings;
 
@@ -48,41 +48,41 @@ use Rex::Commands::Fs;
 Clear partitions on $drive.
 
  clearpart "sda";
-   
+  
  clearpart "sda",
-   initialize => "gpt";
+  initialize => "gpt";
 
 =cut
 sub clearpart {
-   my ($disk, %option) = @_;
-
-   if($option{initialize}) {
-      # will destroy partition table
-      run "parted -s /dev/$disk mklabel " . $option{initialize};
-      if($? != 0) {
-         die("Error setting disklabel from $disk to $option{initialize}");
-      }
-
-      if($option{initialize} eq "gpt") {
-         Rex::Logger::info("Creating bios boot partition");
-         partition("none",
-            fstype => "non-fs",
-            ondisk => $disk,
-            size   => "1");
-
-         run "parted /dev/$disk set 1 bios_grub on";
-
-      }
-   }
-   else {
-      my @partitions = grep { /$disk\d+$/ } split /\n/, cat "/proc/partitions";
-
-      for my $part_line (@partitions) {
-         my ($num, $part) = ($part_line =~ m/\d+\s+(\d+)\s+\d+\s(.*)$/);
-         Rex::Logger::info("Removing $part");
-         run "parted -s /dev/$disk rm $num";
-      }
-   }
+  my ($disk, %option) = @_;
+
+  if($option{initialize}) {
+    # will destroy partition table
+    run "parted -s /dev/$disk mklabel " . $option{initialize};
+    if($? != 0) {
+      die("Error setting disklabel from $disk to $option{initialize}");
+    }
+
+    if($option{initialize} eq "gpt") {
+      Rex::Logger::info("Creating bios boot partition");
+      partition("none",
+        fstype => "non-fs",
+        ondisk => $disk,
+        size  => "1");
+
+      run "parted /dev/$disk set 1 bios_grub on";
+
+    }
+  }
+  else {
+    my @partitions = grep { /$disk\d+$/ } split /\n/, cat "/proc/partitions";
+
+    for my $part_line (@partitions) {
+      my ($num, $part) = ($part_line =~ m/\d+\s+(\d+)\s+\d+\s(.*)$/);
+      Rex::Logger::info("Removing $part");
+      run "parted -s /dev/$disk rm $num";
+    }
+  }
 }
 
 =item partition($mountpoint, %option)
@@ -90,156 +90,156 @@ sub clearpart {
 Create a partition with mountpoint $mountpoint.
 
  partition "/",
-    fstype  => "ext3",
-    size    => 15000,
-    ondisk  => "sda",
-    type    => "primary";
-    
+   fstype  => "ext3",
+   size   => 15000,
+   ondisk  => "sda",
+   type   => "primary";
+   
  partition "none",
-    type   => "extended",
-    ondisk => "sda",
-    grow   => 1,
-    mount  => TRUE,
-    
+   type  => "extended",
+   ondisk => "sda",
+   grow  => 1,
+   mount  => TRUE,
+   
  partition "swap",
-    fstype => "swap",
-    type   => "logical",
-    ondisk => "sda",
-    size   => 8000;
-    
+   fstype => "swap",
+   type  => "logical",
+   ondisk => "sda",
+   size  => 8000;
+   
  partition "none",
-    lvm    => 1,
-    type   => "primary",
-    size   => 15000,
-    ondisk => "vda";
-    
+   lvm   => 1,
+   type  => "primary",
+   size  => 15000,
+   ondisk => "vda";
+   
  partition "/",
-    fstype => "ext3",
-    size   => 10000,
-    onvg   => "vg0";
+   fstype => "ext3",
+   size  => 10000,
+   onvg  => "vg0";
 
 
 =cut
 sub partition {
-   my ($mountpoint, %option) = @_;
+  my ($mountpoint, %option) = @_;
 
-   $option{type} ||= "primary"; # primary is default
-
-   # info:
-   # disk size, partition start, partition end is in MB
+  $option{type} ||= "primary"; # primary is default
+
+  # info:
+  # disk size, partition start, partition end is in MB
 
-   unless($option{ondisk}) {
-      die("You have to specify ,,ondisk''.");
-   }
+  unless($option{ondisk}) {
+    die("You have to specify ,,ondisk''.");
+  }
 
-   my $disk = $option{ondisk};
-
-   my @output_lines = grep { /^\s+\d+/ } run "parted /dev/$disk print";
-
-   my $last_partition_end = 1;
-   my $unit;
-   if(@output_lines) {
-      ($last_partition_end, $unit) = ($output_lines[-1] =~ m/\s+[\d\.]+[a-z]+\s+[\d\.]+[a-z]+\s+([\d\.]+)(kB|MB|GB)/i);
-      if($unit eq "GB") { $last_partition_end = sprintf("%i", (($last_partition_end * 1000)+1)); } # * 1000 because of parted, +1 to round up
-      if($unit eq "kB") { $last_partition_end = sprintf("%i", (($last_partition_end / 1000)+1)); } # / 1000 because of parted, +1 to round up
-   }
-
-   Rex::Logger::info("Last parition ending at $last_partition_end");
-   my $next_partition_start = $last_partition_end;
-   my $next_partition_end   = $option{size} + $last_partition_end;
-
-   if($option{grow}) {
-      $next_partition_end = "-- -1";
-   }
-
-   run "parted -s /dev/$disk mkpart $option{type} $next_partition_start $next_partition_end";
-
-   if($? != 0) {
-      die("Error creating partition.");
-   }
-
-   run "partprobe";
-
-   # get the partition id
-   my @partitions = grep { /$disk\d+$/ } split /\n/, cat "/proc/partitions";
-   my ($part_num) = ($partitions[-1] =~ m/$disk(\d+)/);
-
-   if(! $part_num) {
-      die("Error getting partition number.");
-   }
-
-   if($option{boot}) {
-      run "parted /dev/$disk set $part_num boot on";
-   }
-
-   if($option{vg}) {
-      run "parted /dev/$disk set $part_num lvm on";
-      pvcreate "/dev/$disk$part_num";
-      my @vgs = vgs();
-      if( grep { $_->{volume_group} eq $option{vg} } @vgs ) {
-         # vg exists, so extend it
-         vgextend $option{vg}, "/dev/$disk$part_num";
-      }
-      else {
-         # vg doesnt exist, create a new one
-         vgcreate $option{vg} => "/dev/$disk$part_num";
-      }
-   }
-
-   my $found_part=0;
-   while($found_part == 0) {
-      Rex::Logger::debug("Waiting on /dev/$disk$part_num to appear...");
-
-      run "ls -l /dev/$disk$part_num";
-      if($? == 0) { $found_part = 1; last; }
-
-      sleep 1;
-   }
-
-   if(! exists $option{fstype} || $option{fstype} eq "non-fs" || $option{fstype} eq "none" || $option{fstype} eq "") {
-      # nix
-   }
-   elsif(can_run("mkfs.$option{fstype}")) {
-      Rex::Logger::info("Creating filesystem $option{fstype} on /dev/$disk$part_num"); 
-
-      my $add_opts = "";
-
-      if(exists $option{label} || exists $option{lable}) {
-         my $label = $option{label} || $option{lable};
-         $add_opts .= " -L $label ";
-      }
-
-      run "mkfs.$option{fstype} $add_opts /dev/$disk$part_num";
-   }
-   elsif($option{fstype} eq "swap") {
-      Rex::Logger::info("Creating swap space on /dev/$disk$part_num");
-
-      my $add_opts = "";
-
-      if(exists $option{label} || exists $option{lable}) {
-         my $label = $option{label} || $option{lable};
-         $add_opts .= " -L $label ";
-      }
-
-      run "mkswap $add_opts /dev/$disk$part_num";
-   }
-   else {
-      die("Can't format partition with $option{fstype}");
-   }
-
-   if(exists $option{mount} && $option{mount}) {
-      mount "/dev/$disk$part_num", $mountpoint,
-                  fs => $option{fstype};
-   }
-
-   if(exists $option{mount_persistent} && $option{mount_persistent}) {
-      mount "/dev/$disk$part_num", $mountpoint,
-                  fs => $option{fstype},
-                  label => $option{label} || "",
-                  persistent => 1;
-   }
-
-   return "$disk$part_num";
+  my $disk = $option{ondisk};
+
+  my @output_lines = grep { /^\s+\d+/ } run "parted /dev/$disk print";
+
+  my $last_partition_end = 1;
+  my $unit;
+  if(@output_lines) {
+    ($last_partition_end, $unit) = ($output_lines[-1] =~ m/\s+[\d\.]+[a-z]+\s+[\d\.]+[a-z]+\s+([\d\.]+)(kB|MB|GB)/i);
+    if($unit eq "GB") { $last_partition_end = sprintf("%i", (($last_partition_end * 1000)+1)); } # * 1000 because of parted, +1 to round up
+    if($unit eq "kB") { $last_partition_end = sprintf("%i", (($last_partition_end / 1000)+1)); } # / 1000 because of parted, +1 to round up
+  }
+
+  Rex::Logger::info("Last parition ending at $last_partition_end");
+  my $next_partition_start = $last_partition_end;
+  my $next_partition_end  = $option{size} + $last_partition_end;
+
+  if($option{grow}) {
+    $next_partition_end = "-- -1";
+  }
+
+  run "parted -s /dev/$disk mkpart $option{type} $next_partition_start $next_partition_end";
+
+  if($? != 0) {
+    die("Error creating partition.");
+  }
+
+  run "partprobe";
+
+  # get the partition id
+  my @partitions = grep { /$disk\d+$/ } split /\n/, cat "/proc/partitions";
+  my ($part_num) = ($partitions[-1] =~ m/$disk(\d+)/);
+
+  if(! $part_num) {
+    die("Error getting partition number.");
+  }
+
+  if($option{boot}) {
+    run "parted /dev/$disk set $part_num boot on";
+  }
+
+  if($option{vg}) {
+    run "parted /dev/$disk set $part_num lvm on";
+    pvcreate "/dev/$disk$part_num";
+    my @vgs = vgs();
+    if( grep { $_->{volume_group} eq $option{vg} } @vgs ) {
+      # vg exists, so extend it
+      vgextend $option{vg}, "/dev/$disk$part_num";
+    }
+    else {
+      # vg doesnt exist, create a new one
+      vgcreate $option{vg} => "/dev/$disk$part_num";
+    }
+  }
+
+  my $found_part=0;
+  while($found_part == 0) {
+    Rex::Logger::debug("Waiting on /dev/$disk$part_num to appear...");
+
+    run "ls -l /dev/$disk$part_num";
+    if($? == 0) { $found_part = 1; last; }
+
+    sleep 1;
+  }
+
+  if(! exists $option{fstype} || $option{fstype} eq "non-fs" || $option{fstype} eq "none" || $option{fstype} eq "") {
+    # nix
+  }
+  elsif(can_run("mkfs.$option{fstype}")) {
+    Rex::Logger::info("Creating filesystem $option{fstype} on /dev/$disk$part_num"); 
+
+    my $add_opts = "";
+
+    if(exists $option{label} || exists $option{lable}) {
+      my $label = $option{label} || $option{lable};
+      $add_opts .= " -L $label ";
+    }
+
+    run "mkfs.$option{fstype} $add_opts /dev/$disk$part_num";
+  }
+  elsif($option{fstype} eq "swap") {
+    Rex::Logger::info("Creating swap space on /dev/$disk$part_num");
+
+    my $add_opts = "";
+
+    if(exists $option{label} || exists $option{lable}) {
+      my $label = $option{label} || $option{lable};
+      $add_opts .= " -L $label ";
+    }
+
+    run "mkswap $add_opts /dev/$disk$part_num";
+  }
+  else {
+    die("Can't format partition with $option{fstype}");
+  }
+
+  if(exists $option{mount} && $option{mount}) {
+    mount "/dev/$disk$part_num", $mountpoint,
+            fs => $option{fstype};
+  }
+
+  if(exists $option{mount_persistent} && $option{mount_persistent}) {
+    mount "/dev/$disk$part_num", $mountpoint,
+            fs => $option{fstype},
+            label => $option{label} || "",
+            persistent => 1;
+  }
+
+  return "$disk$part_num";
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,8 +15,8 @@ With this module you can install packages and files.
 =head1 SYNOPSIS
 
  install file => "/etc/passwd", {
-                     source => "/export/files/etc/passwd"
-                 };
+              source => "/export/files/etc/passwd"
+            };
  
  install package => "perl";
 
@@ -54,7 +54,47 @@ require Rex::Exporter;
 use base qw(Rex::Exporter);
 use vars qw(@EXPORT);
 
-@EXPORT = qw(install update remove update_system installed_packages is_installed update_package_db repository package_provider_for);
+@EXPORT = qw(install update remove update_system installed_packages is_installed update_package_db repository package_provider_for pkg);
+
+=item pkg($package, %options)
+
+Since: 0.45
+
+Use this function to install or update a package.
+
+ pkg "httpd",
+   ensure => "latest";    # ensure that the newest version is installed (auto-update)
+ pkg "httpd",
+   ensure => "absent";    # remove the package
+ pkg "httpd",
+   ensure => "present";   # ensure that some version is installed (no auto-update)
+ pkg "httpd",
+   ensure => "2.4.6";    # ensure that version 2.4.6 is installed
+
+=cut
+
+sub pkg {
+  my ($package, %option) = @_;
+
+  $option{ensure} ||= "present";
+
+  if($option{ensure} eq "latest") {
+    return update(package => $package, \%option);
+  }
+  elsif($option{ensure} eq "present") {
+    return install(package => $package, \%option);
+  }
+  elsif($option{ensure} eq "absent") {
+    return remove(package => $package);
+  }
+  elsif($option{ensure} =~ m/^\d/) {
+    # looks like a version
+    return install(package => $package, {version => $option{ensure}});
+  }
+  else {
+    die("Unknown ensure parameter: $option{ensure}.");
+  }
+}
 
 =item install($type, $data, $options)
 
@@ -65,58 +105,58 @@ The install function can install packages (for CentOS, OpenSuSE and Debian) and
 =item installing a package (This is only supported on CentOS, OpenSuSE and Debian systems.)
 
  task "prepare", "server01", sub {
-    install package => "perl";
-    
-    # or if you have to install more packages.
-    install package => [ 
-                           "perl",
-                           "ntp",
-                           "dbus",
-                           "hal",
-                           "sudo",
-                           "vim",
-                       ];
+   install package => "perl";
+ 
+   # or if you have to install more packages.
+   install package => [
+                  "perl",
+                  "ntp",
+                  "dbus",
+                  "hal",
+                  "sudo",
+                  "vim",
+                ];
  };
 
 =item installing a file
- 
+
 This is deprecated since 0.9. Please use L<File> I<file> instead.
 
  task "prepare", "server01", sub {
-    install file => "/etc/passwd", {
-                        source => "/export/files/etc/passwd",
-                        owner  => "root",
-                        group  => "root",
-                        mode   => 644,
-                    };
+   install file => "/etc/passwd", {
+                source => "/export/files/etc/passwd",
+                owner  => "root",
+                group  => "root",
+                mode  => 644,
+              };
  };
 
 =item installing a file and do somthing if the file was changed.
 
  task "prepare", "server01", sub {
-    install file => "/etc/httpd/apache2.conf", {
-                        source    => "/export/files/etc/httpd/apache2.conf",
-                        owner     => "root",
-                        group     => "root",
-                        mode      => 644,
-                        on_change => sub { say "File was modified!"; }
-                    };
+   install file => "/etc/httpd/apache2.conf", {
+                source   => "/export/files/etc/httpd/apache2.conf",
+                owner    => "root",
+                group    => "root",
+                mode    => 644,
+                on_change => sub { say "File was modified!"; }
+              };
  };
 
 =item installing a file from a template.
 
  task "prepare", "server01", sub {
-    install file => "/etc/httpd/apache2.tpl", {
-                        source    => "/export/files/etc/httpd/apache2.conf",
-                        owner     => "root",
-                        group     => "root",
-                        mode      => 644,
-                        on_change => sub { say "File was modified!"; },
-                        template  => {
-                                        greeting => "hello",
-                                        name     => "Ben",
-                                     },
-                    };
+   install file => "/etc/httpd/apache2.tpl", {
+                source   => "/export/files/etc/httpd/apache2.conf",
+                owner    => "root",
+                group    => "root",
+                mode    => 644,
+                on_change => sub { say "File was modified!"; },
+                template  => {
+                           greeting => "hello",
+                           name    => "Ben",
+                         },
+              };
  };
 
 
@@ -124,7 +164,7 @@ This is deprecated since 0.9. Please use L<File> I<file> instead.
 
 This function supports the following hooks:
 
-=over 8 
+=over 8
 
 =item before
 
@@ -148,300 +188,300 @@ This gets executed right before the install() function returns.
 
 sub install {
 
-   if(! @_) {
-      return "install";
-   }
+  if(! @_) {
+    return "install";
+  }
 
-   #### check and run before hook
-   my @orig_params = @_;
-   eval {
-      my @new_args = Rex::Hook::run_hook(install => "before", @_);
-      if(@new_args) {
-         @_ = @new_args;
-      }
-      1;
-   } or do {
-      die("Before-Hook failed. Canceling install() action: $@");
-   };
-   ##############################
+  #### check and run before hook
+  my @orig_params = @_;
+  eval {
+    my @new_args = Rex::Hook::run_hook(install => "before", @_);
+    if(@new_args) {
+      @_ = @new_args;
+    }
+    1;
+  } or do {
+    die("Before-Hook failed. Canceling install() action: $@");
+  };
+  ##############################
 
 
-   my $type = shift;
-   my $package = shift;
-   my $option;
-   my $__ret;
+  my $type = shift;
+  my $package = shift;
+  my $option;
+  my $__ret;
 
-   if($type eq "file") {
+  if($type eq "file") {
 
-      if(ref($_[0]) eq "HASH") {
-         $option = shift;
-      }
-      else {
-         $option = { @_ };
-      }
+    if(ref($_[0]) eq "HASH") {
+      $option = shift;
+    }
+    else {
+      $option = { @_ };
+    }
 
-      Rex::Logger::debug("The install file => ... call is deprecated. Please use 'file' instead.");
-      Rex::Logger::debug("This directive will be removed with (R)?ex 2.0");
-      Rex::Logger::debug("See http://rexify.org/api/Rex/Commands/File.pm for more information.");
-   
-      my $source    = $option->{"source"};
-      my $need_md5  = ($option->{"on_change"} ? 1 : 0);
-      my $on_change = $option->{"on_change"} || sub {};
-      my $__ret;
-
-      my ($new_md5, $old_md5) = ("", "");
-      
-      if($source =~ m/\.tpl$/) {
-         # das ist ein template
-
-         my $content = eval { local(@ARGV, $/) = ($source); <>; };
-
-         my $vars = $option->{"template"};
-         my %merge1 = %{$vars || {}};
-         my %merge2 = Rex::Hardware->get(qw/ All /);
-         my %template_vars = (%merge1, %merge2);
-
-         if($need_md5) {
-            eval {
-               $old_md5 = md5($package);
-            };
-         }
+    Rex::Logger::debug("The install file => ... call is deprecated. Please use 'file' instead.");
+    Rex::Logger::debug("This directive will be removed with (R)?ex 2.0");
+    Rex::Logger::debug("See http://rexify.org/api/Rex/Commands/File.pm for more information.");
 
-         my $fh = file_write($package);
-         $fh->write(Rex::Config->get_template_function()->($content, \%template_vars));
-         $fh->close;
+    my $source   = $option->{"source"};
+    my $need_md5  = ($option->{"on_change"} ? 1 : 0);
+    my $on_change = $option->{"on_change"} || sub {};
+    my $__ret;
 
-         if($need_md5) {
-            eval {
-               $new_md5 = md5($package);
-            };
-         }
+    my ($new_md5, $old_md5) = ("", "");
 
-      }
-      else {
-         
-         my $source = Rex::Helper::Path::get_file_path($source, caller());
-         my $content = eval { local(@ARGV, $/) = ($source); <>; };
-
-         my $local_md5 = "";
-         if($option->{force}) {
-            upload $source, $package;
-         }
-         else {
-            eval {
-               $old_md5 = md5($package);
-               chomp $old_md5;
-            };
+    if($source =~ m/\.tpl$/) {
+      # das ist ein template
 
-            LOCAL {
-               $local_md5 = md5($source);
-            };
+      my $content = eval { local(@ARGV, $/) = ($source); <>; };
 
-            unless($local_md5 eq $old_md5) {
-               Rex::Logger::debug("MD5 is different $local_md5 -> $old_md5 (uploading)");
-               upload $source, $package;
-            }
-            else {
-               Rex::Logger::debug("MD5 is equal. Not uploading $source -> $package");
-            }
+      my $vars = $option->{"template"};
+      my %merge1 = %{$vars || {}};
+      my %merge2 = Rex::Hardware->get(qw/ All /);
+      my %template_vars = (%merge1, %merge2);
 
-            eval {
-               $new_md5 = md5($package);
-            };
-         }
+      if($need_md5) {
+        eval {
+          $old_md5 = md5($package);
+        };
       }
 
-      if(exists $option->{"owner"}) {
-         chown $option->{"owner"}, $package;
-      }
+      my $fh = file_write($package);
+      $fh->write(Rex::Config->get_template_function()->($content, \%template_vars));
+      $fh->close;
 
-      if(exists $option->{"group"}) {
-         chgrp $option->{"group"}, $package;
+      if($need_md5) {
+        eval {
+          $new_md5 = md5($package);
+        };
       }
 
-      if(exists $option->{"mode"}) {
-         chmod $option->{"mode"}, $package;
+    }
+    else {
+
+      my $source = Rex::Helper::Path::get_file_path($source, caller());
+      my $content = eval { local(@ARGV, $/) = ($source); <>; };
+
+      my $local_md5 = "";
+      if($option->{force}) {
+        upload $source, $package;
       }
+      else {
+        eval {
+          $old_md5 = md5($package);
+          chomp $old_md5;
+        };
+
+        LOCAL {
+          $local_md5 = md5($source);
+        };
+
+        unless($local_md5 eq $old_md5) {
+          Rex::Logger::debug("MD5 is different $local_md5 -> $old_md5 (uploading)");
+          upload $source, $package;
+        }
+        else {
+          Rex::Logger::debug("MD5 is equal. Not uploading $source -> $package");
+        }
+
+        eval {
+          $new_md5 = md5($package);
+        };
+      }
+    }
 
-      if($need_md5) {
-         unless($old_md5 && $new_md5 && $old_md5 eq $new_md5) {
-            $old_md5 ||= "";
-            $new_md5 ||= "";
+    if(exists $option->{"owner"}) {
+      chown $option->{"owner"}, $package;
+    }
 
-            Rex::Logger::debug("File $package has been changed... Running on_change");
-            Rex::Logger::debug("old: $old_md5");
-            Rex::Logger::debug("new: $new_md5");
+    if(exists $option->{"group"}) {
+      chgrp $option->{"group"}, $package;
+    }
 
-            &$on_change;
-         }
-      }
-   
-   }
+    if(exists $option->{"mode"}) {
+      chmod $option->{"mode"}, $package;
+    }
 
-   elsif($type eq "package") {
-      
+    if($need_md5) {
+      unless($old_md5 && $new_md5 && $old_md5 eq $new_md5) {
+        $old_md5 ||= "";
+        $new_md5 ||= "";
 
-      if(ref($_[0]) eq "HASH") {
-         $option = shift;
-      }
-      elsif($_[0]) {
-         $option = { @_ };
+        Rex::Logger::debug("File $package has been changed... Running on_change");
+        Rex::Logger::debug("old: $old_md5");
+        Rex::Logger::debug("new: $new_md5");
+
+        &$on_change;
       }
+    }
 
-      my $pkg;
-      
-      $pkg = Rex::Pkg->get;
+  }
 
-      if(!ref($package)) {
-         $package = [$package];
-      }
-      
-      my $changed = 0;
-      
-      # if we're being asked to install a single package
-      if(@{$package} == 1) {
-         my $pkg_to_install = shift @{$package};
-         unless($pkg->is_installed($pkg_to_install)) {
-            Rex::Logger::info("Installing $pkg_to_install.");
-
-            #### check and run before_change hook
-            Rex::Hook::run_hook(install => "before_change", @orig_params);
-            ##############################
-
-            $pkg->install($pkg_to_install, $option);
-            $changed = 1;
-
-            #### check and run after_change hook
-            Rex::Hook::run_hook(install => "after_change", @orig_params, {changed => $changed});
-            ##############################
-         }
-      } else {
-         my @pkgCandidates;
-         for my $pkg_to_install (@{$package}) {
-            unless($pkg->is_installed($pkg_to_install)) {
-               push @pkgCandidates, $pkg_to_install;
-            }
-         }
-         
-         if(@pkgCandidates) {
-            Rex::Logger::info("Installing @pkgCandidates");
-            $pkg->bulk_install(\@pkgCandidates, $option); # here, i think $option is useless in its current form.
-            $changed = 1;
-         } 
+  elsif($type eq "package") {
+
+
+    if(ref($_[0]) eq "HASH") {
+      $option = shift;
+    }
+    elsif($_[0]) {
+      $option = { @_ };
+    }
+
+    my $pkg;
+
+    $pkg = Rex::Pkg->get;
+
+    if(!ref($package)) {
+      $package = [$package];
+    }
+
+    my $changed = 0;
+
+    # if we're being asked to install a single package
+    if(@{$package} == 1) {
+      my $pkg_to_install = shift @{$package};
+      unless($pkg->is_installed($pkg_to_install)) {
+        Rex::Logger::info("Installing $pkg_to_install.");
+
+        #### check and run before_change hook
+        Rex::Hook::run_hook(install => "before_change", @orig_params);
+        ##############################
+
+        $pkg->install($pkg_to_install, $option);
+        $changed = 1;
+
+        #### check and run after_change hook
+        Rex::Hook::run_hook(install => "after_change", @orig_params, {changed => $changed});
+        ##############################
       }
-         
-     
-      if(Rex::Config->get_do_reporting) {
-         $__ret = {changed => $changed};
+    } else {
+      my @pkgCandidates;
+      for my $pkg_to_install (@{$package}) {
+        unless($pkg->is_installed($pkg_to_install)) {
+          push @pkgCandidates, $pkg_to_install;
+        }
       }
- 
-   }
-   else {
-      # unknown type, be a package
-      install("package", $type, $package, @_); 
 
-      if(Rex::Config->get_do_reporting) {
-         $__ret = {skip => 1};
+      if(@pkgCandidates) {
+        Rex::Logger::info("Installing @pkgCandidates");
+        $pkg->bulk_install(\@pkgCandidates, $option); # here, i think $option is useless in its current form.
+        $changed = 1;
       }
-   }
+    }
+
+
+    if(Rex::Config->get_do_reporting) {
+      $__ret = {changed => $changed};
+    }
+
+  }
+  else {
+    # unknown type, be a package
+    install("package", $type, $package, @_);
+
+    if(Rex::Config->get_do_reporting) {
+      $__ret = {skip => 1};
+    }
+  }
 
-   #### check and run after hook
-   Rex::Hook::run_hook(install => "after", @orig_params, $__ret);
-   ##############################
+  #### check and run after hook
+  Rex::Hook::run_hook(install => "after", @orig_params, $__ret);
+  ##############################
 
-   return $__ret;
+  return $__ret;
 
 }
 
 sub update {
-   
-   my ($type, $package, $option) = @_;
 
-   if($type eq "package") {
-      my $pkg;
-      
-      $pkg = Rex::Pkg->get;
+  my ($type, $package, $option) = @_;
 
-      if(!ref($package)) {
-         $package = [$package];
-      }
+  if($type eq "package") {
+    my $pkg;
 
-      for my $pkg_to_install (@{$package}) {
-         Rex::Logger::info("Updating $pkg_to_install.");
-         $pkg->update($pkg_to_install, $option);
-      }
- 
-   }
-   else {
-      update("package", @_);
-   }
+    $pkg = Rex::Pkg->get;
+
+    if(!ref($package)) {
+      $package = [$package];
+    }
+
+    for my $pkg_to_install (@{$package}) {
+      Rex::Logger::info("Updating $pkg_to_install.");
+      $pkg->update($pkg_to_install, $option);
+    }
+
+  }
+  else {
+    update("package", @_);
+  }
 
 }
 
-=item remove($type, $package, $options) 
+=item remove($type, $package, $options)
 
 This function will remove the given package from a system.
 
  task "cleanup", "server01", sub {
-    remove package => "vim";
+   remove package => "vim";
  };
 
 =cut
 
 sub remove {
 
-   my ($type, $package, $option) = @_;
+  my ($type, $package, $option) = @_;
 
 
-   if($type eq "package") {
+  if($type eq "package") {
 
-      my $pkg = Rex::Pkg->get;
-      unless(ref($package) eq "ARRAY") {
-         $package = ["$package"];
-      }
+    my $pkg = Rex::Pkg->get;
+    unless(ref($package) eq "ARRAY") {
+      $package = ["$package"];
+    }
 
-      for my $_pkg (@{$package}) {
-         if($pkg->is_installed($_pkg)) {
-            Rex::Logger::info("Removing $_pkg.");
-            $pkg->remove($_pkg, $option);
-         }
-         else {
-            Rex::Logger::info("$_pkg is not installed.");
-         }
+    for my $_pkg (@{$package}) {
+      if($pkg->is_installed($_pkg)) {
+        Rex::Logger::info("Removing $_pkg.");
+        $pkg->remove($_pkg, $option);
       }
+      else {
+        Rex::Logger::info("$_pkg is not installed.");
+      }
+    }
 
-   }
+  }
 
-   else {
-      
-      #Rex::Logger::info("$type not supported.");
-      #die("remove $type not supported");
-      # no type given, assume package
-      remove("package", $type, $option);
+  else {
 
-   }
+    #Rex::Logger::info("$type not supported.");
+    #die("remove $type not supported");
+    # no type given, assume package
+    remove("package", $type, $option);
+
+  }
 
 }
 
 =item update_system
 
-This function do a complete system update. 
+This function do a complete system update.
 
 For example I<apt-get upgrade> or I<yum update>.
 
  task "update-system", "server1", sub {
-    update_system;
+   update_system;
  };
 
 =cut
 
 sub update_system {
-   my $pkg = Rex::Pkg->get;
-   eval {
-      $pkg->update_system;
-   } or do {
-      Rex::Logger::info("There is no update_system function for your system.");
-   };
+  my $pkg = Rex::Pkg->get;
+  eval {
+    $pkg->update_system;
+  } or do {
+    Rex::Logger::info("There is no update_system function for your system.");
+  };
 }
 
 =item installed_packages
@@ -449,40 +489,40 @@ sub update_system {
 This function returns all installed packages and their version.
 
  task "get-installed", "server1", sub {
-    
-     for my $pkg (installed_packages()) {
-        say "name     : " . $pkg->{"name"};
-        say "  version: " . $pkg->{"version"};
-     }
-     
+ 
+    for my $pkg (installed_packages()) {
+      say "name    : " . $pkg->{"name"};
+      say "  version: " . $pkg->{"version"};
+    }
+ 
  };
 
 =cut
 
 sub installed_packages {
-   my $pkg = Rex::Pkg->get;
-   return $pkg->get_installed;
+  my $pkg = Rex::Pkg->get;
+  return $pkg->get_installed;
 }
 
 =item is_installed
 
-This function tests if $package is installed. Returns 1 if true. 0 if false. 
+This function tests if $package is installed. Returns 1 if true. 0 if false.
 
  task "isinstalled", "server01", sub {
-    if( is_installed("rex") ) {
-       say "Rex is installed";
-    }
-    else {
-       say "Rex is not installed";
-    }
+   if( is_installed("rex") ) {
+     say "Rex is installed";
+   }
+   else {
+     say "Rex is not installed";
+   }
  };
 
 =cut
 
 sub is_installed {
-   my $package = shift;
-   my $pkg = Rex::Pkg->get;
-   return $pkg->is_installed($package);
+  my $package = shift;
+  my $pkg = Rex::Pkg->get;
+  return $pkg->is_installed($package);
 }
 
 =item update_package_db
@@ -490,14 +530,14 @@ sub is_installed {
 This function updates the local package database. For example, on CentOS it will execute I<yum makecache>.
 
  task "update-pkg-db", "server1", "server2", sub {
-    update_package_db;
-    install package => "apache2";
+   update_package_db;
+   install package => "apache2";
  };
 
 =cut
 sub update_package_db {
-   my $pkg = Rex::Pkg->get;
-   $pkg->update_pkg_db();
+  my $pkg = Rex::Pkg->get;
+  $pkg->update_pkg_db();
 }
 
 
@@ -508,99 +548,99 @@ Add or remove a repository from the package manager.
 For Debian: If you have no source repository, or if you don't want to add it, just remove the I<source> parameter.
 
  task "add-repo", "server1", "server2", sub {
-    repository "add" => "repository-name",
-         url        => "http://rex.linux-files.org/debian/squeeze",
-         distro     => "squeeze",
-         repository => "rex",
-         source     => 1;
+   repository "add" => "repository-name",
+      url      => "http://rex.linux-files.org/debian/squeeze",
+      distro    => "squeeze",
+      repository => "rex",
+      source    => 1;
  };
 
 For ALT Linux: If repository is unsigned, just remove the I<sign_key> parameter.
 
  task "add-repo", "server1", "server2", sub {
-    repository "add" => "altlinux-sisyphus",
-         url        => "ftp://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus",
-         sign_key   => "alt",
-         arch       => "noarch, x86_64",
-         repository => "classic";
+   repository "add" => "altlinux-sisyphus",
+      url      => "ftp://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus",
+      sign_key  => "alt",
+      arch     => "noarch, x86_64",
+      repository => "classic";
  };
 
 For CentOS, Mageia and SuSE only the name and the url are needed.
 
  task "add-repo", "server1", "server2", sub {
-    repository add => "repository-name",
-         url => 'http://rex.linux-files.org/CentOS/$releasever/rex/$basearch/';
-     
+   repository add => "repository-name",
+      url => 'http://rex.linux-files.org/CentOS/$releasever/rex/$basearch/';
+ 
  };
 
 To remove a repository just delete it with its name.
 
  task "rm-repo", "server1", sub {
-    repository remove => "repository-name";
+   repository remove => "repository-name";
  };
 
 You can also use one call to repository to add repositories on multiple platforms:
 
  task "add-repo", "server1", "server2", sub {
-   repository add => myrepo => {
-      Ubuntu => {
-         url => "http://foo.bar/repo",
-         distro => "precise",
-         repository => "foo",
-      },
-      Debian => {
-         url => "http://foo.bar/repo",
-         distro => "squeeze",
-         repository => "foo",
-      },
-      CentOS => {
-         url => "http://foo.bar/repo",
-      },
-   };
+  repository add => myrepo => {
+    Ubuntu => {
+      url => "http://foo.bar/repo",
+      distro => "precise",
+      repository => "foo",
+    },
+    Debian => {
+      url => "http://foo.bar/repo",
+      distro => "squeeze",
+      repository => "foo",
+    },
+    CentOS => {
+      url => "http://foo.bar/repo",
+    },
+  };
  };
 
 
 =cut
 
 sub repository {
-   my ($action, $name, @__data) = @_;
-
-   my %data;
-
-   if(ref($__data[0])) {
-      if(! exists $__data[0]->{get_operating_system()}) {
-         if(exists $__data[0]->{default}) {
-            %data = $__data[0]->{default};
-         }
-         else {
-            die("No repository information found for os: " . get_operating_system());
-         }
+  my ($action, $name, @__data) = @_;
+
+  my %data;
+
+  if(ref($__data[0])) {
+    if(! exists $__data[0]->{get_operating_system()}) {
+      if(exists $__data[0]->{default}) {
+        %data = $__data[0]->{default};
       }
       else {
-         %data = %{ $__data[0]->{get_operating_system()} };
+        die("No repository information found for os: " . get_operating_system());
       }
-   }
-   else {
-      %data = @__data;
-   }
+    }
+    else {
+      %data = %{ $__data[0]->{get_operating_system()} };
+    }
+  }
+  else {
+    %data = @__data;
+  }
 
-   my $pkg = Rex::Pkg->get;
+  my $pkg = Rex::Pkg->get;
 
-   $data{"name"} = $name;
+  $data{"name"} = $name;
 
-   my $ret;
-   if($action eq "add") {
-      $ret = $pkg->add_repository(%data);
-   }
-   elsif($action eq "remove" || $action eq "delete") {
-      $ret = $pkg->rm_repository($name);
-   }
+  my $ret;
+  if($action eq "add") {
+    $ret = $pkg->add_repository(%data);
+  }
+  elsif($action eq "remove" || $action eq "delete") {
+    $ret = $pkg->rm_repository($name);
+  }
 
-   if(exists $data{after}) {
-      $data{after}->();
-   }
+  if(exists $data{after}) {
+    $data{after}->();
+  }
 
-   return $ret;
+  return $ret;
 }
 
 =item package_provider_for $os => $type;
@@ -608,20 +648,20 @@ sub repository {
 To set an other package provider as the default, use this function.
 
  user "root";
-     
+ 
  group "db" => "db[01..10]";
  package_provider_for SunOS => "blastwave";
-    
+ 
  task "prepare", group => "db", sub {
-     install package => "vim";
+    install package => "vim";
  };
 
 This example will install I<vim> on every db server. If the server is a Solaris (SunOS) it will use the I<blastwave> Repositories.
 
 =cut
 sub package_provider_for {
-   my ($os, $provider) = @_;
-   Rex::Config->set("package_provider", {$os => $provider});
+  my ($os, $provider) = @_;
+  Rex::Config->set("package_provider", {$os => $provider});
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -40,8 +40,8 @@ use vars qw(@EXPORT);
 use base qw(Rex::Exporter);
 
 @EXPORT = qw(kill killall
-               ps
-               nice);
+          ps
+          nice);
 
 
 =item kill($pid, $sig)
@@ -49,20 +49,20 @@ use base qw(Rex::Exporter);
 Will kill the given process id. If $sig is specified it will kill with this.
 
  task "kill", "server01", sub {
-    kill 9931;
-    kill 9931, -9;
+   kill 9931;
+   kill 9931, -9;
  };
 
 =cut
 
 sub kill {
-   my ($process, $sig) = @_;
-   $sig ||= "";
+  my ($process, $sig) = @_;
+  $sig ||= "";
 
-   run ("kill $sig " . $process);
-   if($? != 0) {
-      die("Error killing $process");
-   }
+  run ("kill $sig " . $process);
+  if($? != 0) {
+    die("Error killing $process");
+  }
 }
 
 =item killall($name, $sig)
@@ -70,25 +70,25 @@ sub kill {
 Will kill the given process. If $sig is specified it will kill with this.
 
  task "kill-apaches", "server01", sub {
-    killall "apache2";
-    killall "apache2", -9;
+   killall "apache2";
+   killall "apache2", -9;
  };
 
 =cut
 
 sub killall {
-   my ($process, $sig) = @_;
-   $sig ||= "";
-
-   if(can_run("killall")) {
-      run ("killall $sig $process");
-      if($? != 0) {
-         die("Error killing $process");
-      }
-   }
-   else {
-      die("Can't execute killall.");
-   }
+  my ($process, $sig) = @_;
+  $sig ||= "";
+
+  if(can_run("killall")) {
+    run ("killall $sig $process");
+    if($? != 0) {
+      die("Error killing $process");
+    }
+  }
+  else {
+    die("Can't execute killall.");
+  }
 }
 
 =item ps
@@ -96,18 +96,18 @@ sub killall {
 List all processes on a system. Will return all fields of a I<ps aux>.
 
  task "ps", "server01", sub {
-    for my $process (ps()) {
-      say "command  > " . $process->{"command"};
-      say "pid      > " . $process->{"pid"};
-      say "cpu-usage> " . $process->{"cpu"};
-    }
+   for my $process (ps()) {
+    say "command  > " . $process->{"command"};
+    say "pid    > " . $process->{"pid"};
+    say "cpu-usage> " . $process->{"cpu"};
+   }
  };
 
 
 On most operating systems it is also possible to define custom parameters for ps() function.
 
  task "ps", "server01", sub {
-    my @list = grep { $_->{"ni"} == -5 } ps("command","ni");
+   my @list = grep { $_->{"ni"} == -5 } ps("command","ni");
  };
 
 This example would contain all processes with a nice of -5.
@@ -116,102 +116,102 @@ This example would contain all processes with a nice of -5.
 =cut
 
 sub ps {
-   my (@custom) = @_;
-   my @list;
-
-   if(is_openwrt) {
-      # openwrt doesn't have ps aux
-      @list = run("ps");
-
-      my @ret = ();
-      for my $line (@list) {
-         $line =~ s/^\s*|\s*$//g;
-         my ($pid, $user, $vsz, $stat, $command) = split(/\s+/, $line, 5);
-
-         push( @ret, {
-            user     => $user,
-            pid      => $pid,
-            vsz      => $vsz,
-            stat     => $stat,
-            command  => $command,
-         });
-      }
-
-      return @ret;
-   }
-   
-   elsif(operating_system_is("SunOS") && operating_system_version() <= 510) {
-      if(@custom) {
-         @list = run("/usr/ucb/ps awwx -o" . join(",", @custom));
-      }
-      else {
-         @list = run("/usr/ucb/ps auwwx");
-      }
-   }
-   else {
-      if(@custom) {
-         @list = run("ps awwx -o" . join(",", @custom));
-      }
-      else {
-         @list = run("ps auwwx");
-      }
-   }
+  my (@custom) = @_;
+  my @list;
+
+  if(is_openwrt) {
+    # openwrt doesn't have ps aux
+    @list = run("ps");
+
+    my @ret = ();
+    for my $line (@list) {
+      $line =~ s/^\s*|\s*$//g;
+      my ($pid, $user, $vsz, $stat, $command) = split(/\s+/, $line, 5);
+
+      push( @ret, {
+        user    => $user,
+        pid    => $pid,
+        vsz    => $vsz,
+        stat    => $stat,
+        command  => $command,
+      });
+    }
 
-   if($? != 0) {
-      if(@custom) {
-         die("Error running ps ax -o" . join(",", @custom));
-      }
-      else {
-         die("Error running ps aux");
-      }
-   }
-   shift @list;
-
-   my @ret = ();
-   if(@custom) {
-      for my $line (@list) {
-         $line =~ s/^\s+//;
-         my @col_vals = split(/\s+/, $line, scalar(@custom));
-         my %vals;
-         @vals{@custom} = @col_vals;
-         push @ret, { %vals };
-      }
-   }
-   else {
-      for my $line (@list) {
-         my ($user, $pid, $cpu, $mem, $vsz, $rss, $tty, $stat, $start, $time, $command) = split(/\s+/, $line, 11);
-
-         push( @ret, {
-            user     => $user,
-            pid      => $pid,
-            cpu      => $cpu,
-            mem      => $mem,
-            vsz      => $vsz,
-            rss      => $rss,
-            tty      => $tty,
-            stat     => $stat,
-            start    => $start,
-            time     => $time,
-            command  => $command,
-         });
-      }
-   }
+    return @ret;
+  }
+  
+  elsif(operating_system_is("SunOS") && operating_system_version() <= 510) {
+    if(@custom) {
+      @list = run("/usr/ucb/ps awwx -o" . join(",", @custom));
+    }
+    else {
+      @list = run("/usr/ucb/ps auwwx");
+    }
+  }
+  else {
+    if(@custom) {
+      @list = run("ps awwx -o" . join(",", @custom));
+    }
+    else {
+      @list = run("ps auwwx");
+    }
+  }
 
-   return @ret;
+  if($? != 0) {
+    if(@custom) {
+      die("Error running ps ax -o" . join(",", @custom));
+    }
+    else {
+      die("Error running ps aux");
+    }
+  }
+  shift @list;
+
+  my @ret = ();
+  if(@custom) {
+    for my $line (@list) {
+      $line =~ s/^\s+//;
+      my @col_vals = split(/\s+/, $line, scalar(@custom));
+      my %vals;
+      @vals{@custom} = @col_vals;
+      push @ret, { %vals };
+    }
+  }
+  else {
+    for my $line (@list) {
+      my ($user, $pid, $cpu, $mem, $vsz, $rss, $tty, $stat, $start, $time, $command) = split(/\s+/, $line, 11);
+
+      push( @ret, {
+        user    => $user,
+        pid    => $pid,
+        cpu    => $cpu,
+        mem    => $mem,
+        vsz    => $vsz,
+        rss    => $rss,
+        tty    => $tty,
+        stat    => $stat,
+        start   => $start,
+        time    => $time,
+        command  => $command,
+      });
+    }
+  }
+
+  return @ret;
 }
 
 
 #Will try to start a process with nohup in the background.
 #
 # task "start_in_bg", "server01", sub {
-#    nohup "/opt/srv/myserver";
+#   nohup "/opt/srv/myserver";
 # };
 
 
 #sub nohup {
-#   my ($cmd) = @_;
+#  my ($cmd) = @_;
 #
-#   run "nohup $cmd &";
+#  run "nohup $cmd &";
 #}
 
 =item nice($pid, $level)
@@ -219,17 +219,17 @@ sub ps {
 Renice a process identified by $pid with the priority $level.
 
  task "renice", "server01", sub {
-    nice (153, -5);
+   nice (153, -5);
  };
 
 =cut
 
 sub nice {
-   my ($pid, $level) = @_;
-   run "renice $level $pid";
-   if($? != 0) {
-      die("Error renicing $pid");
-   }
+  my ($pid, $level) = @_;
+  run "renice $level $pid";
+  if($? != 0) {
+    die("Error renicing $pid");
+  }
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -57,26 +57,26 @@ This function executes rsync to sync $source and $dest.
 =item UPLOAD - Will upload all from the local directory I<html> to the remote directory I</var/www/html>.
 
  task "sync", "server01", sub {
-    sync "html/*", "/var/www/html", {
-      exclude => "*.sw*",
-      parameters => '--backup --delete',
-    };
+   sync "html/*", "/var/www/html", {
+    exclude => "*.sw*",
+    parameters => '--backup --delete',
+   };
  };
-
+ 
  task "sync", "server01", sub {
-    sync "html/*", "/var/www/html", {
-      exclude => ["*.sw*", "*.tmp"],
-      parameters => '--backup --delete',
-    };
+   sync "html/*", "/var/www/html", {
+    exclude => ["*.sw*", "*.tmp"],
+    parameters => '--backup --delete',
+   };
  };
 
 =item DOWNLOAD - Will download all from the remote directory I</var/www/html> to the local directory I<html>.
 
  task "sync", "server01", sub {
-    sync "/var/www/html/*", "html/", {
-      download => 1,
-      parameters => '--backup',
-    };
+   sync "/var/www/html/*", "html/", {
+    download => 1,
+    parameters => '--backup',
+   };
  };
 
 =back
@@ -84,164 +84,179 @@ This function executes rsync to sync $source and $dest.
 =cut
 
 sub sync {
-   my ($source, $dest, $opt) = @_;
-
-   my $current_connection = Rex::get_current_connection();
-   my $server = $current_connection->{server};
-   my $cmd;
-
-   my $auth = $current_connection->{conn}->get_auth;
-
-
-   if(! exists $opt->{download} && $source !~ m/^\//) {
-      # relative path, calculate from module root
-      $source = Rex::Helper::Path::get_file_path($source, caller());
-   }
-
-   Rex::Logger::debug("Syning $source -> $dest with rsync.");
-   if($Rex::Logger::debug) {
-      $Expect::Log_Stdout = 1;
-   }
-
-   my $params = "";
-   if($opt && exists $opt->{'exclude'}) {
-      my $excludes = $opt->{'exclude'};
-      $excludes = [$excludes] unless ref($excludes) eq "ARRAY";
-      for my $exclude (@$excludes) {
-         $params .= " --exclude=" . $exclude;
-      }
-   }
-
-   if($opt && exists $opt->{parameters}) {
-      $params .= " " . $opt->{parameters};
-   }
-
-   if($opt && exists $opt->{'download'} && $opt->{'download'} == 1) {
-      Rex::Logger::debug("Downloading $source -> $dest");
-      $cmd = "rsync -a -e '\%s' --verbose --stats $params " . $auth->{user} . "\@" . $server . ":"
-                     . $source . " " . $dest;
-   }
-   else {
-      Rex::Logger::debug("Uploading $source -> $dest");
-      $cmd = "rsync -a -e '\%s' --verbose --stats $params $source " . $auth->{user} . "\@" . $server . ":"
-                     . $dest;
-   }
-
-   my $pass = $auth->{password};
-   my @expect_options = ();
-
-   if($auth->{auth_type} eq "pass") {
-      $cmd = sprintf($cmd, 'ssh -o StrictHostKeyChecking=no ');
-      push(@expect_options, [
-                              qr{Are you sure you want to continue connecting},
-                              sub {
-                                 Rex::Logger::debug("Accepting key..");
-                                 my $fh = shift;
-                                 $fh->send("yes\n");
-                                 exp_continue;
-                              }
-                            ],
-                            [
-                              qr{password: ?$}i,
-                              sub {
-                                 Rex::Logger::debug("Want Password");
-                                 my $fh = shift;
-                                 $fh->send($pass . "\n");
-                                 exp_continue;
-                              }
-                           ],
-                           [
-                                 qr{rsync error: error in rsync protocol},
-                                 sub {
-                                    Rex::Logger::debug("Error in rsync");
-                                    die;
-                                 }
-                           ],
-
-      
-      );
-   }
-   else {
-      $cmd = sprintf($cmd, 'ssh -i ' . $server->get_private_key . " -o StrictHostKeyChecking=no ");
-      push(@expect_options, [
-                              qr{Are you sure you want to continue connecting},
-                              sub {
-                                 Rex::Logger::debug("Accepting key..");
-                                 my $fh = shift;
-                                 $fh->send("yes\n");
-                                 exp_continue;
-                              }
-                            ],
-                            [
-                              qr{password: ?$}i,
-                              sub {
-                                 Rex::Logger::debug("Want Password");
-                                 my $fh = shift;
-                                 $fh->send($pass . "\n");
-                                 exp_continue;
-                              }
-                           ],
-                           [
-                              qr{Enter passphrase for key.*: $},
-                              sub {
-                                 Rex::Logger::debug("Want Passphrase");
-                                 my $fh = shift;
-                                 $fh->send($pass . "\n");
-                                 exp_continue;
-                              }
-                           ],
-                           [
-                                 qr{rsync error: error in rsync protocol},
-                                 sub {
-                                    Rex::Logger::debug("Error in rsync");
-                                    die;
-                                 }
-                           ],
-
-      );
-   }
-
-   Rex::Logger::debug("cmd: $cmd");
-
-   eval {
-      my $exp = Expect->spawn($cmd) or die($!);
-
-      eval {
-         $exp->expect(Rex::Config->get_timeout, @expect_options, [
-                                 qr{total size is \d+\s+speedup is },
-                                 sub {
-                                    Rex::Logger::debug("Finished transfer very fast");
-                                    die;
-                                 }
-                             
-                              ]);
-
-         $exp->expect(undef, [
-                           qr{total size is \d+\s+speedup is },
-                           sub {
-                              Rex::Logger::debug("Finished transfer");
-                              exp_continue;
-                           }
-                        ],
-                        [
-                              qr{rsync error: error in rsync protocol},
-                              sub {
-                                 Rex::Logger::debug("Error in rsync");
-                                 die;
-                              }
-                        ],
-                        );
-
-      };
-
-      $exp->soft_close;
-      $? = $exp->exitstatus;
-   };
+  my ($source, $dest, $opt) = @_;
+
+  my $current_connection = Rex::get_current_connection();
+  my $server = $current_connection->{server};
+  my $cmd;
+
+  my $auth = $current_connection->{conn}->get_auth;
+
+
+  if(! exists $opt->{download} && $source !~ m/^\//) {
+    # relative path, calculate from module root
+    $source = Rex::Helper::Path::get_file_path($source, caller());
+  }
+
+  Rex::Logger::debug("Syning $source -> $dest with rsync.");
+  if($Rex::Logger::debug) {
+    $Expect::Log_Stdout = 1;
+  }
+
+  my $params = "";
+  if($opt && exists $opt->{'exclude'}) {
+    my $excludes = $opt->{'exclude'};
+    $excludes = [$excludes] unless ref($excludes) eq "ARRAY";
+    for my $exclude (@$excludes) {
+      $params .= " --exclude=" . $exclude;
+    }
+  }
+
+  if($opt && exists $opt->{parameters}) {
+    $params .= " " . $opt->{parameters};
+  }
+
+  if($opt && exists $opt->{'download'} && $opt->{'download'} == 1) {
+    Rex::Logger::debug("Downloading $source -> $dest");
+    $cmd = "rsync -a -e '\%s' --verbose --stats $params " . $auth->{user} . "\@" . $server . ":"
+              . $source . " " . $dest;
+  }
+  else {
+    Rex::Logger::debug("Uploading $source -> $dest");
+    $cmd = "rsync -a -e '\%s' --verbose --stats $params $source " . $auth->{user} . "\@" . $server . ":"
+              . $dest;
+  }
+
+  my $pass = $auth->{password};
+  my @expect_options = ();
+
+  if($auth->{auth_type} eq "pass") {
+    $cmd = sprintf($cmd, 'ssh -o StrictHostKeyChecking=no ');
+    push(@expect_options, [
+                    qr{Are you sure you want to continue connecting},
+                    sub {
+                      Rex::Logger::debug("Accepting key..");
+                      my $fh = shift;
+                      $fh->send("yes\n");
+                      exp_continue;
+                    }
+                   ],
+                   [
+                    qr{password: ?$}i,
+                    sub {
+                      Rex::Logger::debug("Want Password");
+                      my $fh = shift;
+                      $fh->send($pass . "\n");
+                      exp_continue;
+                    }
+                  ],
+                  [
+                      qr{rsync error: error in rsync protocol},
+                      sub {
+                        Rex::Logger::debug("Error in rsync");
+                        die;
+                      }
+                  ],
+                  [
+                        qr{rsync error: remote command not found},
+                        sub {
+                           Rex::Logger::info("Remote rsync command not found");
+                           Rex::Logger::info("Please install rsync, or use Rex::Commands::Sync sync_up/sync_down");
+                           die;
+                        }
+                  ],
+
+    );
+  }
+  else {
+    $cmd = sprintf($cmd, 'ssh -i ' . $server->get_private_key . " -o StrictHostKeyChecking=no ");
+    push(@expect_options, [
+                    qr{Are you sure you want to continue connecting},
+                    sub {
+                      Rex::Logger::debug("Accepting key..");
+                      my $fh = shift;
+                      $fh->send("yes\n");
+                      exp_continue;
+                    }
+                   ],
+                   [
+                    qr{password: ?$}i,
+                    sub {
+                      Rex::Logger::debug("Want Password");
+                      my $fh = shift;
+                      $fh->send($pass . "\n");
+                      exp_continue;
+                    }
+                  ],
+                  [
+                    qr{Enter passphrase for key.*: $},
+                    sub {
+                      Rex::Logger::debug("Want Passphrase");
+                      my $fh = shift;
+                      $fh->send($pass . "\n");
+                      exp_continue;
+                    }
+                  ],
+                  [
+                      qr{rsync error: error in rsync protocol},
+                      sub {
+                        Rex::Logger::debug("Error in rsync");
+                        die;
+                      }
+                  ],
+                  [
+                        qr{rsync error: remote command not found},
+                        sub {
+                           Rex::Logger::info("Remote rsync command not found");
+                           Rex::Logger::info("Please install rsync, or use Rex::Commands::Sync sync_up/sync_down");
+                           die;
+                        }
+                  ],
+
+    );
+  }
+
+  Rex::Logger::debug("cmd: $cmd");
+
+  eval {
+    my $exp = Expect->spawn($cmd) or die($!);
+
+    eval {
+      $exp->expect(Rex::Config->get_timeout, @expect_options, [
+                      qr{total size is \d+\s+speedup is },
+                      sub {
+                        Rex::Logger::debug("Finished transfer very fast");
+                        die;
+                      }
+                    
+                    ]);
+
+      $exp->expect(undef, [
+                  qr{total size is \d+\s+speedup is },
+                  sub {
+                    Rex::Logger::debug("Finished transfer");
+                    exp_continue;
+                  }
+                ],
+                [
+                    qr{rsync error: error in rsync protocol},
+                    sub {
+                      Rex::Logger::debug("Error in rsync");
+                      die;
+                    }
+                ],
+                );
+
+    };
+
+    $exp->soft_close;
+    $? = $exp->exitstatus;
+  };
 
 
-   if($@) {
-      Rex::Logger::info($@);
-   }
+  if($@) {
+    Rex::Logger::info($@);
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -24,7 +24,6 @@ With this module you can run a command.
 
 =cut
 
-
 package Rex::Commands::Run;
 
 use strict;
@@ -40,17 +39,17 @@ use Rex::Helper::Run;
 use Rex::Helper::SSH2::Expect;
 use Rex::Config;
 use Rex::Interface::Exec;
+use Rex::Interface::Fs;
 
 BEGIN {
-   if($^O !~ m/^MSWin/) {
-      eval "use Expect";
-   }
-   else {
-      # this fails sometimes on windows...
-      eval {
-         Rex::Logger::debug("Running under windows, Expect not supported.");
-      };
-   }
+  if ( $^O !~ m/^MSWin/ ) {
+    eval "use Expect";
+  }
+  else {
+    # this fails sometimes on windows...
+    eval {
+      Rex::Logger::debug("Running under windows, Expect not supported."); };
+  }
 }
 
 use vars qw(@EXPORT);
@@ -63,93 +62,183 @@ use base qw(Rex::Exporter);
 This function will execute the given command and returns the output.
 
  task "uptime", "server01", sub {
-    say run "uptime";
-    run "uptime", sub {
-       my ($stdout, $stderr) = @_;
-       my $server = Rex::get_current_connection()->{server};
-       say "[$server] $stdout\n";
-    };
+   say run "uptime";
+   run "uptime", sub {
+     my ($stdout, $stderr) = @_;
+     my $server = Rex::get_current_connection()->{server};
+     say "[$server] $stdout\n";
+   };
  };
 
+If you only want to run a command in special cases, you can queue the command
+and notify it when you want to run it.
+
+ task "prepare", sub {
+   run "extract-something",
+     command     => "tar -C /foo -xzf /tmp/foo.tgz",
+     only_notified => TRUE;
+ 
+   # some code ...
+ 
+   notify "run", "extract-something";  # now the command gets executed
+ };
+
+If you only want to run a command if an other command succeed or fail, you can use
+I<only_if> or I<unless> option.
+
+ run "some-command",
+   only_if => "ps -ef | grep -q httpd";   # only run if httpd is running
+ 
+ run "some-other-command",
+   unless => "ps -ef | grep -q httpd";    # only run if httpd is not running
+
+If you want to set custom environment variables you can do this like this:
+
+ run "my_command",
+   env => {
+     env_var_1 => "the value for 1",
+     env_var_2 => "the value for 2",
+   };
+
 =cut
 
-our $LAST_OUTPUT;   # this variable stores the last output of a run.
-                    # so that it is possible to get for example the output of an apt-get update
-                    # that is called through >> install "foo" <<
+our $LAST_OUTPUT;    # this variable stores the last output of a run.
+    # so that it is possible to get for example the output of an apt-get update
+    # that is called through >> install "foo" <<
+
 sub run {
-   my $cmd = shift;
-   my ($code, $option);
-   if(ref $_[0] eq "CODE") {
-      $code = shift;
-   }
-   elsif(scalar @_ > 0) {
-      $option = { @_ };
-   }
+  my $cmd = shift;
+  my ( $code, $option );
+  if ( ref $_[0] eq "CODE" ) {
+    $code = shift;
+  }
+  elsif ( scalar @_ > 0 ) {
+    $option = {@_};
+  }
+
+  if ( exists $option->{only_notified} && $option->{only_notified} ) {
+    Rex::Logger::debug(
+      "This command runs only if notified. Passing by. ($cmd, $option->{command})"
+    );
+    my $notify = Rex::get_current_connection()->{notify};
+    $notify->add(
+      type    => "run",
+      name    => $cmd,
+      options => $option,
+      cb      => sub {
+        my ($option) = shift;
+        Rex::Logger::debug(
+          "Running notified command: $cmd ($option->{command})");
+        run( $option->{command} );
+      }
+    );
 
-   my $path;
+    return;
+  }
 
-   if(! Rex::Config->get_no_path_cleanup()) {
-      $path = join(":", Rex::Config->get_path());
-   }
+  if ( exists $option->{command} ) {
+    $cmd = $option->{command};
+  }
 
-   my $exec = Rex::Interface::Exec->create;
-   my ($out, $err) = $exec->exec($cmd, $path, $option);
-   chomp $out if $out;
-   chomp $err if $err;
+  if ( exists $option->{creates} ) {
+    my $fs = Rex::Interface::Fs->create();
+    if ( $fs->is_file( $option->{creates} ) ) {
+      Rex::Logger::debug(
+        "File $option->{creates} already exists. Not executing $cmd.");
+      return;
+    }
+  }
 
-   $LAST_OUTPUT = [$out, $err];
+  if ( exists $option->{only_if} ) {
+    run( $option->{only_if} );
+    if ( $? != 0 ) {
+      Rex::Logger::debug(
+        "Don't executing $cmd because $option->{only_if} return $?.");
+      return;
+    }
+  }
 
-   if(! defined $out) {
-      $out = "";
-   }
+  if ( exists $option->{unless} ) {
+    run( $option->{unless} );
+    if ( $? == 0 ) {
+      Rex::Logger::debug(
+        "Don't executing $cmd because $option->{unless} return $?.");
+      return;
+    }
+  }
 
-   if(! defined $err) {
-      $err = "";
-   }
+  my $path;
 
-   if(Rex::Config->get_exec_autodie() && Rex::Config->get_exec_autodie() == 1) {
-      if($? != 0) {
-         die("Error executing: $cmd.\nOutput:\n$out");
-      }
-   }
+  if ( !Rex::Config->get_no_path_cleanup() ) {
+    $path = join( ":", Rex::Config->get_path() );
+  }
 
-   if($code) {
-      return &$code($out, $err);
-   }
+  my $exec = Rex::Interface::Exec->create;
+  my ( $out, $err ) = $exec->exec( $cmd, $path, $option );
+  chomp $out if $out;
+  chomp $err if $err;
 
-   if(wantarray) {
-      return split(/\r?\n/, $out);
-   }
+  $LAST_OUTPUT = [ $out, $err ];
+
+  if ( !defined $out ) {
+    $out = "";
+  }
 
-   return $out;
+  if ( !defined $err ) {
+    $err = "";
+  }
+
+  if ( Rex::Config->get_exec_autodie() && Rex::Config->get_exec_autodie() == 1 )
+  {
+    if ( $? != 0 ) {
+      die("Error executing: $cmd.\nOutput:\n$out");
+    }
+  }
+
+  if ($code) {
+    return &$code( $out, $err );
+  }
+
+  if (wantarray) {
+    return split( /\r?\n/, $out );
+  }
+
+  return $out;
 }
 
 =item can_run($command)
 
-This function checks if a command is in the path or is available.
+This function checks if a command is in the path or is available. You can
+specify multiple commands, the first command found will be returned.
 
  task "uptime", sub {
-    if(can_run "uptime") {
-       say run "uptime";
-    }
+   if( my $cmd = can_run("uptime", "downtime") ) {
+     say run $cmd;
+   }
  };
 
 =cut
+
 sub can_run {
-   my $cmd = shift;
+  my @cmds = @_;
 
-   if(! Rex::is_ssh() && $^O =~ m/^MSWin/) {
-      return 1;
-   }
+  if ( !Rex::is_ssh() && $^O =~ m/^MSWin/ ) {
+    return 1;
+  }
 
-   my @ret = i_run "which $cmd";
-   if($? != 0) { return 0; }
+  for my $cmd (@cmds) {
+    my @ret = i_run "which $cmd";
+    next if ( $? != 0 );
 
-   if( grep { /^no.*in/ } @ret ) {
-      return 0;
-   }
+    if ( grep { /^no.*in/ } @ret ) {
+      next;
+    }
+    else {
+      return $ret[0];
+    }
+  }
 
-   return $ret[0];
+  return 0;
 }
 
 =item sudo
@@ -160,76 +249,77 @@ You can use this function to run one command with sudo privileges or to turn on
 
  user "unprivuser";
  sudo_password "f00b4r";
- sudo -on;   # turn sudo globaly on
-     
+ sudo -on;  # turn sudo globaly on
+ 
  task prepare => sub {
-    install "apache2";
-    file "/etc/ntp.conf",
-       source => "files/etc/ntp.conf",
-       owner  => "root",
-       mode   => 640;
+   install "apache2";
+   file "/etc/ntp.conf",
+     source => "files/etc/ntp.conf",
+     owner  => "root",
+     mode  => 640;
  };
 
 Or, if you don't turning sudo globaly on.
 
  task prepare => sub {
-    file "/tmp/foo.txt",
-       content => "this file was written without sudo privileges\n";
-        
-    # everything in this section will be executed with sudo privileges
-    sudo sub {
-       install "apache2";
-       file "/tmp/foo2.txt",
-          content => "this file was written with sudo privileges\n";
-    };
+   file "/tmp/foo.txt",
+     content => "this file was written without sudo privileges\n";
+ 
+   # everything in this section will be executed with sudo privileges
+   sudo sub {
+     install "apache2";
+     file "/tmp/foo2.txt",
+       content => "this file was written with sudo privileges\n";
+   };
  };
 
 Run only one command within sudo.
 
  task "eth1-down", sub {
-   sudo "ifconfig eth1 down";
+  sudo "ifconfig eth1 down";
  };
 
 =cut
-sub sudo {
-   my ($cmd) = @_;
 
-   my $options;
-   if(ref $cmd eq "HASH") {
-      $options = $cmd;
-      $cmd = $options->{command};
-   }
-
-   if($cmd eq "on" || $cmd eq "-on" || $cmd eq "1") {
-      Rex::Logger::debug("Turning sudo globaly on");
-      Rex::global_sudo(1);
-      return;
-   }
-   elsif($cmd eq "0") {
-      Rex::Logger::debug("Turning sudo globaly off");
-      Rex::global_sudo(0);
-      return;
-   }
-
-   my $old_sudo = Rex::get_current_connection()->{use_sudo} || 0;
-   my $old_options = Rex::get_current_connection()->{sudo_options} || {};
-   Rex::get_current_connection()->{use_sudo} = 1;
-   Rex::get_current_connection()->{sudo_options} = $options;
-
-   my $ret;
-
-   # if sudo is used with a code block
-   if(ref($cmd) eq "CODE") {
-      $ret = &$cmd();
-   }
-   else {
-      $ret = i_run($cmd);
-   }
-
-   Rex::get_current_connection()->{use_sudo} = $old_sudo;
-   Rex::get_current_connection()->{sudo_options} = $old_options;
-
-   return $ret;
+sub sudo {
+  my ($cmd) = @_;
+
+  my $options;
+  if ( ref $cmd eq "HASH" ) {
+    $options = $cmd;
+    $cmd     = $options->{command};
+  }
+
+  if ( $cmd eq "on" || $cmd eq "-on" || $cmd eq "1" ) {
+    Rex::Logger::debug("Turning sudo globaly on");
+    Rex::global_sudo(1);
+    return;
+  }
+  elsif ( $cmd eq "0" ) {
+    Rex::Logger::debug("Turning sudo globaly off");
+    Rex::global_sudo(0);
+    return;
+  }
+
+  my $old_sudo    = Rex::get_current_connection()->{use_sudo}     || 0;
+  my $old_options = Rex::get_current_connection()->{sudo_options} || {};
+  Rex::get_current_connection()->{use_sudo}     = 1;
+  Rex::get_current_connection()->{sudo_options} = $options;
+
+  my $ret;
+
+  # if sudo is used with a code block
+  if ( ref($cmd) eq "CODE" ) {
+    $ret = &$cmd();
+  }
+  else {
+    $ret = i_run($cmd);
+  }
+
+  Rex::get_current_connection()->{use_sudo}     = $old_sudo;
+  Rex::get_current_connection()->{sudo_options} = $old_options;
+
+  return $ret;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,29 +15,29 @@ With this module you can checkout subversion and git repositories.
 =head1 SYNOPSIS
 
  use Rex::Commands::SCM;
-     
+    
  set repository => "myrepo",
-      url => "git@foo.bar:myrepo.git";
-        
+    url => "git@foo.bar:myrepo.git";
+      
  set repository => "myrepo2",
-      url => "https://foo.bar/myrepo",
-      type => "subversion",
-      username => "myuser",
-      password => "mypass";
-           
+    url => "https://foo.bar/myrepo",
+    type => "subversion",
+    username => "myuser",
+    password => "mypass";
+        
  task "checkout", sub {
-    checkout "myrepo";
+   checkout "myrepo";
+      
+   checkout "myrepo",
+     path => "webapp";
+        
+   checkout "myrepo",
+     path => "webapp",
+     branch => 1.6;    # branch only for git
         
-    checkout "myrepo",
-       path => "webapp";
-           
-    checkout "myrepo",
-       path => "webapp",
-       branch => 1.6;      # branch only for git
-           
-    checkout "myrepo2";
+   checkout "myrepo2";
  };
-     
+    
 
 =head1 EXPORTED FUNCTIONS
 
@@ -60,8 +60,8 @@ use vars qw(@EXPORT %REPOS);
 @EXPORT = qw(checkout);
 
 Rex::Config->register_set_handler("repository" => sub {
-   my ($name, %option) = @_;
-   $REPOS{$name} = \%option;
+  my ($name, %option) = @_;
+  $REPOS{$name} = \%option;
 });
 
 
@@ -71,29 +71,29 @@ With this function you can checkout a repository defined with I<set repository>.
 
 =cut
 sub checkout {
-   my ($name, %data) = @_;
+  my ($name, %data) = @_;
 
-   my $type = $REPOS{"$name"}->{"type"} ? $REPOS{$name}->{"type"} : "git";
-   my $class = "Rex::SCM::\u$type";
+  my $type = $REPOS{"$name"}->{"type"} ? $REPOS{$name}->{"type"} : "git";
+  my $class = "Rex::SCM::\u$type";
 
-   my $co_to = exists $data{"path"} ? $data{"path"} : "";
+  my $co_to = exists $data{"path"} ? $data{"path"} : "";
 
-   if($data{"path"}) {
-      $data{"path"} = undef;
-      delete $data{"path"};
-   }
+  if($data{"path"}) {
+    $data{"path"} = undef;
+    delete $data{"path"};
+  }
 
-   eval "use $class;";
-   if($@) {
-      Rex::Logger::info("Error loading SCM: $@\n", "warn");
-      die("Error loading SCM: $@");
-   }
+  eval "use $class;";
+  if($@) {
+    Rex::Logger::info("Error loading SCM: $@\n", "warn");
+    die("Error loading SCM: $@");
+  }
 
-   my $scm = $class->new;
+  my $scm = $class->new;
 
-   my $repo = Rex::Config->get("repository");
-   Rex::Logger::debug("Checking out $repo -> $co_to");
-   $scm->checkout($REPOS{$name}, $co_to, \%data);
+  my $repo = Rex::Config->get("repository");
+  Rex::Logger::debug("Checking out $repo -> $co_to");
+  $scm->checkout($REPOS{$name}, $co_to, \%data);
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,19 +15,19 @@ With this module you can manage Linux services.
 =head1 SYNOPSIS
 
  use Rex::Commands::Service
-     
+ 
  service apache2 => "start";
-     
+ 
  service apache2 => "stop";
-     
+ 
  service apache2 => "restart";
-     
+ 
  service apache2 => "status";
-    
+ 
  service apache2 => "reload";
-    
+ 
  service apache2 => "ensure", "started";
-   
+ 
  service apache2 => "ensure", "stopped";
 
 =head1 EXPORTED FUNCTIONS
@@ -36,8 +36,6 @@ With this module you can manage Linux services.
 
 =cut
 
-
-
 package Rex::Commands::Service;
 
 use strict;
@@ -64,50 +62,50 @@ The service function accepts 2 parameters. The first is the service name and the
 =item starting a service
 
  task "start-service", "server01", sub {
-    service apache2 => "start";
+   service apache2 => "start";
  };
 
 =item stopping a service
 
  task "stop-service", "server01", sub {
-    service apache2 => "stop";
+   service apache2 => "stop";
  };
 
 =item restarting a service
 
  task "restart-service", "server01", sub {
-    service apache2 => "restart";
+   service apache2 => "restart";
  };
 
 
 =item checking status of a service
 
  task "status-service", "server01", sub {
-    if( service apache2 => "status" ) {
-       say "Apache2 is running";
-    }
-    else {
-       say "Apache2 is not running";
-    }
+   if( service apache2 => "status" ) {
+     say "Apache2 is running";
+   }
+   else {
+     say "Apache2 is not running";
+   }
  };
 
 =item reloading a service
 
  task "reload-service", "server01", sub {
-    service apache2 => "reload";
+   service apache2 => "reload";
  };
 
 
 =item ensure that a service will started at boot time
 
  task "prepare", sub {
-    service apache2 => "ensure", "started";
+   service apache2 => "ensure", "started";
  };
 
 =item ensure that a service will NOT be started.
 
  task "prepare", sub {
-    service apache2 => "ensure", "stopped";
+   service apache2 => "ensure", "stopped";
  };
 
 
@@ -135,145 +133,160 @@ This gets executed right after the service action.
 =cut
 
 sub service {
-   my ($services, $action, $options) = @_;
-
-   if(wantarray) {
-   
-      # func-ref zurueckgeben
-      return sub {
-         service($services, $action);
-      };
-
-   }
-
-   my $is_multiple = 1;
-   unless(ref($services)) {
-      $services = [$services];
-      $is_multiple = 0;
-   }
-
-   my $srvc = Rex::Service->get;
-
-   my $changed = 0;
-   my $return = 1;
-   for my $service (@$services) {
-
-      #### check and run before_$action hook
-      Rex::Hook::run_hook(service => "before_$action", @_);
-      ##############################
-
-
-      if($action eq "start") {
-
-         unless($srvc->status($service)) {
-            $changed = 1;
-            if($srvc->start($service)) {
-               Rex::Logger::info("Service $service started.");
-               $return = 1 if ! $is_multiple;
-            }
-            else {
-               Rex::Logger::info("Error starting $service.", "warn");
-               $return = 0 if ! $is_multiple;
-            }
-         }
-
+  my ( $services, $action, $options ) = @_;
+
+  if (wantarray) {
+
+    # func-ref zurueckgeben
+    return sub {
+      service( $services, $action );
+    };
+
+  }
+
+  my $is_multiple = 1;
+  unless ( ref($services) ) {
+    $services    = [$services];
+    $is_multiple = 0;
+  }
+
+  my $srvc = Rex::Service->get;
+
+  my $changed = 0;
+  my $return  = 1;
+  for my $service (@$services) {
+
+    my $notify = Rex::get_current_connection()->{notify};
+    $notify->add(
+      type     => "service",
+      name     => $service,
+      postpone => 1,
+      options  => {},
+      cb       => sub {
+        my ($option) = shift;
+        Rex::Logger::debug("Restarting notified service: $service");
+        service( $service => "restart" );
+      }
+    );
+
+    #### check and run before_$action hook
+    Rex::Hook::run_hook( service => "before_$action", @_ );
+    ##############################
+
+    if ( $action eq "start" ) {
+
+      unless ( $srvc->status($service) ) {
+        $changed = 1;
+        if ( $srvc->start($service) ) {
+          Rex::Logger::info("Service $service started.");
+          $return = 1 if !$is_multiple;
+        }
+        else {
+          Rex::Logger::info( "Error starting $service.", "warn" );
+          $return = 0 if !$is_multiple;
+        }
       }
 
-      elsif($action eq "restart") {
-         $changed = 1;
+    }
 
-         if($srvc->restart($service)) {
-            Rex::Logger::info("Service $service restarted.");
-            $return = 1 if ! $is_multiple;
-         }
-         else {
-            Rex::Logger::info("Error restarting $service.", "warn");
-            $return = 0 if ! $is_multiple;
-         }
+    elsif ( $action eq "restart" ) {
+      $changed = 1;
 
+      if ( $srvc->restart($service) ) {
+        Rex::Logger::info("Service $service restarted.");
+        $return = 1 if !$is_multiple;
+      }
+      else {
+        Rex::Logger::info( "Error restarting $service.", "warn" );
+        $return = 0 if !$is_multiple;
       }
 
-      elsif($action eq "stop") {
-
-         if($srvc->status($service)) { # it runs
-            $changed = 1;
-            if($srvc->stop($service)) {
-               Rex::Logger::info("Service $service stopped.");
-               $return = 1 if ! $is_multiple;
-            }
-            else {
-               Rex::Logger::info("Error stopping $service.", "warn");
-               $return = 0 if ! $is_multiple;
-            }
-         }
+    }
 
+    elsif ( $action eq "stop" ) {
+
+      if ( $srvc->status($service) ) {    # it runs
+        $changed = 1;
+        if ( $srvc->stop($service) ) {
+          Rex::Logger::info("Service $service stopped.");
+          $return = 1 if !$is_multiple;
+        }
+        else {
+          Rex::Logger::info( "Error stopping $service.", "warn" );
+          $return = 0 if !$is_multiple;
+        }
       }
 
-      elsif($action eq "reload") {
-         $changed = 1;
-         if($srvc->reload($service)) {
-            Rex::Logger::info("Service $service is reloaded.");
-            $return = 1 if ! $is_multiple;
-         }
-         else {
-            Rex::Logger::info("Error $service does not support reload", "warn");
-            $return = 0 if ! $is_multiple;
-         }
+    }
 
+    elsif ( $action eq "reload" ) {
+      $changed = 1;
+      if ( $srvc->reload($service) ) {
+        Rex::Logger::info("Service $service is reloaded.");
+        $return = 1 if !$is_multiple;
+      }
+      else {
+        Rex::Logger::info( "Error $service does not support reload", "warn" );
+        $return = 0 if !$is_multiple;
       }
 
-      elsif($action eq "status") {
+    }
 
-         $changed = 100;
-         if($srvc->status($service)) {
-            Rex::Logger::info("Service $service is running.");
-            $return = 1 if ! $is_multiple;
-         }
-         else {
-            Rex::Logger::info("$service is stopped");
-            $return = 0 if ! $is_multiple;
-         }
+    elsif ( $action eq "status" ) {
 
+      $changed = 100;
+      if ( $srvc->status($service) ) {
+        Rex::Logger::info("Service $service is running.");
+        $return = 1 if !$is_multiple;
+      }
+      else {
+        Rex::Logger::info("$service is stopped");
+        $return = 0 if !$is_multiple;
       }
 
-      elsif($action eq "ensure") {
+    }
 
-         if($srvc->ensure($service, $options)) {
-            $changed = 0;
-            $return = 1 if ! $is_multiple;
-         }
-         else {
-            $return = 0 if ! $is_multiple;
-            Rex::Logger::info("Error ensuring $service to $options");
-         }
-      }
+    elsif ( $action eq "ensure" ) {
 
+      if ( $srvc->ensure( $service, $options ) ) {
+        $changed = 0;
+        $return = 1 if !$is_multiple;
+      }
       else {
-         Rex::Logger::info("Execution action $action on $service.");
-         $srvc->action($service, $action);
-         $changed = 100;
+        $return = 0 if !$is_multiple;
+        Rex::Logger::info("Error ensuring $service to $options");
       }
+    }
+
+    else {
+      Rex::Logger::info("Execution action $action on $service.");
+      $srvc->action( $service, $action );
+      $changed = 100;
+    }
 
-      #### check and run after_$action hook
-      Rex::Hook::run_hook(service => "after_$action", @_, {changed => $changed, ret => $return});
-      ##############################
+    #### check and run after_$action hook
+    Rex::Hook::run_hook(
+      service => "after_$action",
+      @_, { changed => $changed, ret => $return }
+    );
+    ##############################
 
-   }
+  }
 
-   if(Rex::Config->get_do_reporting) {
-      if($changed == 100) {
-         return {
-            skip => 1,
-            ret  => $return,
-         };
-      }
+  if ( Rex::Config->get_do_reporting ) {
+    if ( $changed == 100 ) {
       return {
-         changed => $changed,
-         ret     => $return,
+        skip => 1,
+        ret  => $return,
       };
-   }
+    }
+    return {
+      changed => $changed,
+      ret     => $return,
+    };
+  }
 
-   return $return;
+  return $return;
 }
 
 =item service_provider_for $os => $type;
@@ -281,25 +294,24 @@ sub service {
 To set an other service provider as the default, use this function.
 
  user "root";
-     
+ 
  group "db" => "db[01..10]";
  service_provider_for SunOS => "svcadm";
-    
+ 
  task "start", group => "db", sub {
-     service ssh => "restart";
+    service ssh => "restart";
  };
 
 This example will restart the I<ssh> service via svcadm (but only on SunOS, on other operating systems it will use the default).
 
 =cut
+
 sub service_provider_for {
-   my ($os, $provider) = @_;
-   Rex::Logger::debug("setting service provider for $os to $provider");
-   Rex::Config->set("service_provider", {$os => $provider});
+  my ( $os, $provider ) = @_;
+  Rex::Logger::debug("setting service provider for $os to $provider");
+  Rex::Config->set( "service_provider", { $os => $provider } );
 }
 
-
-
 =back
 
 =cut
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 =head1 NAME
 
 Rex::Commands::SimpleCheck - Simple tcp/alive checks
@@ -15,7 +15,7 @@ With this module you can do simple tcp/alive checks.
 =head1 SYNOPSIS
 
  if(is_port_open($remote_host, $port)) {
-    print "Port $port is open\n";
+   print "Port $port is open\n";
  }
 
 =head1 EXPORTED FUNCTIONS
@@ -26,16 +26,16 @@ With this module you can do simple tcp/alive checks.
 
 
 package Rex::Commands::SimpleCheck;
-   
+  
 use strict;
 use warnings;
 
 use IO::Socket;
-   
+  
 require Rex::Exporter;
 use base qw(Rex::Exporter);
 use vars qw(@EXPORT);
-    
+   
 @EXPORT = qw(is_port_open);
 
 =item is_port_open($ip, $port)
@@ -45,22 +45,22 @@ Check if something is listening on port $port of $ip.
 =cut
 sub is_port_open {
 
-   my ($ip, $port, $type) = @_;
+  my ($ip, $port, $type) = @_;
 
-   $type ||= "tcp";
+  $type ||= "tcp";
 
-   my $socket = IO::Socket::INET->new(PeerAddr => $ip,
-                                PeerPort => $port,
-                                Proto    => $type,
-                                Timeout  => 2,
-                                Type     => SOCK_STREAM);
+  my $socket = IO::Socket::INET->new(PeerAddr => $ip,
+                      PeerPort => $port,
+                      Proto   => $type,
+                      Timeout  => 2,
+                      Type    => SOCK_STREAM);
 
-   if($socket) {
-      close $socket;
-      return 1;
-   }
+  if($socket) {
+    close $socket;
+    return 1;
+  }
 
-   return 0;
+  return 0;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,31 +15,31 @@ This module can sync directories between your Rex system and your servers withou
 =head1 SYNOPSIS
 
  use Rex::Commands::Sync;
-    
+   
  task "prepare", "mysystem01", sub {
-    # upload directory recursively to remote system. 
-    sync_up "/local/directory", "/remote/directory";
+   # upload directory recursively to remote system. 
+   sync_up "/local/directory", "/remote/directory";
+   
+   sync_up "/local/directory", "/remote/directory", {
+     # setting custom file permissions for every file
+     files => {
+       owner => "foo",
+       group => "bar",
+       mode  => 600,
+     },
+     # setting custom directory permissions for every directory
+     directories => {
+       owner => "foo",
+       group => "bar",
+       mode  => 700,
+     },
+     on_change => sub {
+      my (@files_changed) = @_;
+     },
+   };
     
-    sync_up "/local/directory", "/remote/directory", {
-       # setting custom file permissions for every file
-       files => {
-          owner => "foo",
-          group => "bar",
-          mode  => 600,
-       },
-       # setting custom directory permissions for every directory
-       directories => {
-          owner => "foo",
-          group => "bar",
-          mode  => 700,
-       },
-       on_change => sub {
-         my (@files_changed) = @_;
-       },
-    };
-     
-    # download a directory recursively from the remote system to the local machine
-    sync_down "/remote/directory", "/local/directory";
+   # download a directory recursively from the remote system to the local machine
+   sync_down "/remote/directory", "/local/directory";
  }; 
 
 =cut
@@ -66,358 +66,358 @@ use JSON::XS;
 @EXPORT = qw(sync_up sync_down);
 
 sub sync_up {
-   my ($source, $dest, @option) = @_;
-
-   my $options = {};
-
-   if(ref($option[0])) {
-      $options = $option[0];
-   }
-   else {
-      $options = { @option };
-   }
-
-   $source = resolv_path($source);
-   $dest   = resolv_path($dest);
-
-   #
-   # 0. normalize local path
-   #
-   $source = get_file_path($source, caller);
-
-   #
-   # first, get all files on source side
-   #
-   my @local_files = _get_local_files($source);
-
-   #print Dumper(\@local_files);
-
-   #
-   # second, get all files from destination side
-   #
-
-   my @remote_files = _get_remote_files($dest);
+  my ($source, $dest, @option) = @_;
 
-   #print Dumper(\@remote_files);
+  my $options = {};
 
-   #
-   # third, get the difference
-   #
+  if(ref($option[0])) {
+    $options = $option[0];
+  }
+  else {
+    $options = { @option };
+  }
 
-   my @diff = _diff_files(\@local_files, \@remote_files);
+  $source = resolv_path($source);
+  $dest  = resolv_path($dest);
 
-   #print Dumper(\@diff);
+  #
+  # 0. normalize local path
+  #
+  $source = get_file_path($source, caller);
 
-   #
-   # fourth, upload the different files
-   #
+  #
+  # first, get all files on source side
+  #
+  my @local_files = _get_local_files($source);
 
-   for my $file (@diff) {
-      my ($dir)        = ($file->{path} =~ m/(.*)\/[^\/]+$/);
-      my ($remote_dir) = ($file->{name} =~ m/\/(.*)\/[^\/]+$/);
+  #print Dumper(\@local_files);
 
-      my (%dir_stat, %file_stat);
-      LOCAL {
-         %dir_stat  = stat($dir);
-         %file_stat = stat($file->{path});
-      };
+  #
+  # second, get all files from destination side
+  #
 
-      # check for overwrites
-      my %file_perm = (mode => $file_stat{mode});
-      if(exists $options->{files} && exists $options->{files}->{mode}) {
-         $file_perm{mode} = $options->{files}->{mode};
-      }
+  my @remote_files = _get_remote_files($dest);
 
-      if(exists $options->{files} && exists $options->{files}->{owner}) {
-         $file_perm{owner} = $options->{files}->{owner};
-      }
+  #print Dumper(\@remote_files);
 
-      if(exists $options->{files} && exists $options->{files}->{group}) {
-         $file_perm{group} = $options->{files}->{group};
-      }
+  #
+  # third, get the difference
+  #
 
-      my %dir_perm = (mode => $dir_stat{mode});
-      if(exists $options->{directories} && exists $options->{directories}->{mode}) {
-         $dir_perm{mode} = $options->{directories}->{mode};
-      }
+  my @diff = _diff_files(\@local_files, \@remote_files);
 
-      if(exists $options->{directories} && exists $options->{directories}->{owner}) {
-         $dir_perm{owner} = $options->{directories}->{owner};
-      }
+  #print Dumper(\@diff);
 
-      if(exists $options->{directories} && exists $options->{directories}->{group}) {
-         $dir_perm{group} = $options->{directories}->{group};
-      }
-      ## /check for overwrites
+  #
+  # fourth, upload the different files
+  #
 
-      if($remote_dir) {
-         mkdir "$dest/$remote_dir",
-            %dir_perm;
-      }
-
-      Rex::Logger::debug("(sync_up) Uploading $file->{path} to $dest/$file->{name}");
-      if($file->{path} =~ m/\.tpl$/) {
-         my $file_name = $file->{name};
-         $file_name =~ s/\.tpl$//;
+  for my $file (@diff) {
+    my ($dir)      = ($file->{path} =~ m/(.*)\/[^\/]+$/);
+    my ($remote_dir) = ($file->{name} =~ m/\/(.*)\/[^\/]+$/);
 
-         file "$dest/" . $file_name,
-            content => template($file->{path}),
-            %file_perm;
-      }
-      else {
-         file "$dest/" . $file->{name},
-            source => $file->{path},
-            %file_perm;
-      }
-   }
+    my (%dir_stat, %file_stat);
+    LOCAL {
+      %dir_stat  = stat($dir);
+      %file_stat = stat($file->{path});
+    };
 
-   if(exists $options->{on_change} && ref $options->{on_change} eq "CODE" && scalar(@diff) > 0) {
-      Rex::Logger::debug("Calling on_change hook of sync_up");
-      $options->{on_change}->(map { $dest . $_->{name} } @diff);
-   }
+    # check for overwrites
+    my %file_perm = (mode => $file_stat{mode});
+    if(exists $options->{files} && exists $options->{files}->{mode}) {
+      $file_perm{mode} = $options->{files}->{mode};
+    }
+
+    if(exists $options->{files} && exists $options->{files}->{owner}) {
+      $file_perm{owner} = $options->{files}->{owner};
+    }
+
+    if(exists $options->{files} && exists $options->{files}->{group}) {
+      $file_perm{group} = $options->{files}->{group};
+    }
+
+    my %dir_perm = (mode => $dir_stat{mode});
+    if(exists $options->{directories} && exists $options->{directories}->{mode}) {
+      $dir_perm{mode} = $options->{directories}->{mode};
+    }
+
+    if(exists $options->{directories} && exists $options->{directories}->{owner}) {
+      $dir_perm{owner} = $options->{directories}->{owner};
+    }
+
+    if(exists $options->{directories} && exists $options->{directories}->{group}) {
+      $dir_perm{group} = $options->{directories}->{group};
+    }
+    ## /check for overwrites
+
+    if($remote_dir) {
+      mkdir "$dest/$remote_dir",
+        %dir_perm;
+    }
+
+    Rex::Logger::debug("(sync_up) Uploading $file->{path} to $dest/$file->{name}");
+    if($file->{path} =~ m/\.tpl$/) {
+      my $file_name = $file->{name};
+      $file_name =~ s/\.tpl$//;
+
+      file "$dest/" . $file_name,
+        content => template($file->{path}),
+        %file_perm;
+    }
+    else {
+      file "$dest/" . $file->{name},
+        source => $file->{path},
+        %file_perm;
+    }
+  }
+
+  if(exists $options->{on_change} && ref $options->{on_change} eq "CODE" && scalar(@diff) > 0) {
+    Rex::Logger::debug("Calling on_change hook of sync_up");
+    $options->{on_change}->(map { $dest . $_->{name} } @diff);
+  }
 
 }
 
 sub sync_down {
-   my ($source, $dest, @option) = @_;
+  my ($source, $dest, @option) = @_;
 
-   my $options = {};
+  my $options = {};
 
-   if(ref($option[0])) {
-      $options = $option[0];
-   }
-   else {
-      $options = { @option };
-   }
+  if(ref($option[0])) {
+    $options = $option[0];
+  }
+  else {
+    $options = { @option };
+  }
 
-   $source = resolv_path($source);
-   $dest   = resolv_path($dest);
+  $source = resolv_path($source);
+  $dest  = resolv_path($dest);
 
-   #
-   # first, get all files on dest side
-   #
-   my @local_files = _get_local_files($dest);
+  #
+  # first, get all files on dest side
+  #
+  my @local_files = _get_local_files($dest);
 
-   #print Dumper(\@local_files);
+  #print Dumper(\@local_files);
 
-   #
-   # second, get all files from source side
-   #
+  #
+  # second, get all files from source side
+  #
 
-   my @remote_files = _get_remote_files($source);
+  my @remote_files = _get_remote_files($source);
 
-   #print Dumper(\@remote_files);
+  #print Dumper(\@remote_files);
 
-   #
-   # third, get the difference
-   #
+  #
+  # third, get the difference
+  #
 
-   my @diff = _diff_files(\@remote_files, \@local_files);
+  my @diff = _diff_files(\@remote_files, \@local_files);
 
-   #print Dumper(\@diff);
+  #print Dumper(\@diff);
 
-   #
-   # fourth, upload the different files
-   #
+  #
+  # fourth, upload the different files
+  #
 
-   for my $file (@diff) {
-      my ($dir)        = ($file->{path} =~ m/(.*)\/[^\/]+$/);
-      my ($remote_dir) = ($file->{name} =~ m/\/(.*)\/[^\/]+$/);
+  for my $file (@diff) {
+    my ($dir)      = ($file->{path} =~ m/(.*)\/[^\/]+$/);
+    my ($remote_dir) = ($file->{name} =~ m/\/(.*)\/[^\/]+$/);
 
-      my (%dir_stat, %file_stat);
-      %dir_stat  = stat($dir);
-      %file_stat = stat($file->{path});
+    my (%dir_stat, %file_stat);
+    %dir_stat  = stat($dir);
+    %file_stat = stat($file->{path});
 
-      LOCAL {
-         if($remote_dir) {
-            mkdir "$dest/$remote_dir",
-               mode  => $dir_stat{mode};
-         }
-      };
-
-      Rex::Logger::debug("(sync_down) Downloading $file->{path} to $dest/$file->{name}");
-      download($file->{path}, "$dest/$file->{name}");
-
-      LOCAL {
-         chmod $file_stat{mode}, "$dest/$file->{name}";
-      };
-   }
-
-   if(exists $options->{on_change} && ref $options->{on_change} eq "CODE" && scalar(@diff) > 0) {
-      Rex::Logger::debug("Calling on_change hook of sync_down");
-      if(substr($dest, -1) eq "/") {
-         $dest = substr($dest, 0, -1);
+    LOCAL {
+      if($remote_dir) {
+        mkdir "$dest/$remote_dir",
+          mode  => $dir_stat{mode};
       }
-      $options->{on_change}->(map { $dest . $_->{name} } @diff);
-   }
+    };
+
+    Rex::Logger::debug("(sync_down) Downloading $file->{path} to $dest/$file->{name}");
+    download($file->{path}, "$dest/$file->{name}");
+
+    LOCAL {
+      chmod $file_stat{mode}, "$dest/$file->{name}";
+    };
+  }
+
+  if(exists $options->{on_change} && ref $options->{on_change} eq "CODE" && scalar(@diff) > 0) {
+    Rex::Logger::debug("Calling on_change hook of sync_down");
+    if(substr($dest, -1) eq "/") {
+      $dest = substr($dest, 0, -1);
+    }
+    $options->{on_change}->(map { $dest . $_->{name} } @diff);
+  }
 
 }
 
 
 sub _get_local_files {
-   my ($source) = @_;
-
-   if(! -d $source) { die("$source : no such directory."); }
-
-   my @dirs = ($source);
-   my @local_files;
-   LOCAL {
-      for my $dir (@dirs) {
-         for my $entry (list_files($dir)) {
-            next if($entry eq ".");
-            next if($entry eq "..");
-            if(is_dir("$dir/$entry")) {
-               push(@dirs, "$dir/$entry");
-               next;
-            }
-
-            my $name = "$dir/$entry";
-            $name =~ s/^\Q$source\E//;
-            push(@local_files, {
-               name => $name,
-               path => "$dir/$entry",
-               md5  => md5("$dir/$entry"),
-            });
-
-         }
+  my ($source) = @_;
+
+  if(! -d $source) { die("$source : no such directory."); }
+
+  my @dirs = ($source);
+  my @local_files;
+  LOCAL {
+    for my $dir (@dirs) {
+      for my $entry (list_files($dir)) {
+        next if($entry eq ".");
+        next if($entry eq "..");
+        if(is_dir("$dir/$entry")) {
+          push(@dirs, "$dir/$entry");
+          next;
+        }
+
+        my $name = "$dir/$entry";
+        $name =~ s/^\Q$source\E//;
+        push(@local_files, {
+          name => $name,
+          path => "$dir/$entry",
+          md5  => md5("$dir/$entry"),
+        });
+
       }
-   };
+    }
+  };
 
-   return @local_files;
+  return @local_files;
 }
 
 sub _get_remote_files {
-   my ($dest) = @_;
+  my ($dest) = @_;
 
-   if(! is_dir($dest) ) { die("$dest : no such directory."); }
+  if(! is_dir($dest) ) { die("$dest : no such directory."); }
 
-   my @remote_dirs = ($dest);
-   my @remote_files;
+  my @remote_dirs = ($dest);
+  my @remote_files;
 
-   if(can_run("md5sum")) {
-      # if md5sum executable is available
-      # copy a script to the remote host so it is fast to scan
-      # the directory.
+  if(can_run("md5sum")) {
+    # if md5sum executable is available
+    # copy a script to the remote host so it is fast to scan
+    # the directory.
 
-      my $script = q|
+    my $script = q|
 use strict;
 use warnings;
 
 unlink $0;
 
 my $dest = $ARGV[0];
-my @dirs = ($dest);   
+my @dirs = ($dest);  
 my @tree = ();
 
 for my $dir (@dirs) {
-   opendir(my $dh, $dir) or die($!);
-   while(my $entry = readdir($dh)) {
-      next if($entry eq ".");
-      next if($entry eq "..");
-
-      if(-d "$dir/$entry") {
-         push(@dirs, "$dir/$entry");
-         next;
-      }
-
-      my $name = "$dir/$entry";
-      $name =~ s/^\Q$dest\E//;
-
-      my $md5 = qx{md5sum $dir/$entry \| awk ' { print \$1 } '};
-
-      chomp $md5;
-
-      push(@tree, {
-         path => "$dir/$entry",
-         name => $name,
-         md5  => $md5,
-      });
-   }
-   closedir($dh);
+  opendir(my $dh, $dir) or die($!);
+  while(my $entry = readdir($dh)) {
+    next if($entry eq ".");
+    next if($entry eq "..");
+
+    if(-d "$dir/$entry") {
+      push(@dirs, "$dir/$entry");
+      next;
+    }
+
+    my $name = "$dir/$entry";
+    $name =~ s/^\Q$dest\E//;
+
+    my $md5 = qx{md5sum $dir/$entry \| awk ' { print \$1 } '};
+
+    chomp $md5;
+
+    push(@tree, {
+      path => "$dir/$entry",
+      name => $name,
+      md5  => $md5,
+    });
+  }
+  closedir($dh);
 }
 
 print to_json(\@tree);
 
 sub to_json {
-   my ($ref) = @_;
+  my ($ref) = @_;
 
-   my $s = "";
+  my $s = "";
 
-   if(ref $ref eq "ARRAY") {
-      $s .= "[";
-      for my $itm (@{ $ref }) {
-         if(substr($s, -1) ne "[") {
-            $s .= ",";
-         }
-         $s .= to_json($itm);
-      }
-      return $s . "]";
-   }
-   elsif(ref $ref eq "HASH") {
-      $s .= "{";
-      for my $key (keys %{ $ref }) {
-         if(substr($s, -1) ne "{") {
-            $s .= ",";
-         }
-         $s .= "\"$key\": " . to_json($ref->{$key});
+  if(ref $ref eq "ARRAY") {
+    $s .= "[";
+    for my $itm (@{ $ref }) {
+      if(substr($s, -1) ne "[") {
+        $s .= ",";
       }
-      return $s . "}";
-   }
-   else {
-      if($ref =~ /^\d+$/) {
-         return $ref;
+      $s .= to_json($itm);
+    }
+    return $s . "]";
+  }
+  elsif(ref $ref eq "HASH") {
+    $s .= "{";
+    for my $key (keys %{ $ref }) {
+      if(substr($s, -1) ne "{") {
+        $s .= ",";
       }
-      else {
-         $ref =~ s/'/\\\'/g;
-         return "\"$ref\"";
-      }
-   }
+      $s .= "\"$key\": " . to_json($ref->{$key});
+    }
+    return $s . "}";
+  }
+  else {
+    if($ref =~ /^\d+$/) {
+      return $ref;
+    }
+    else {
+      $ref =~ s/'/\\\'/g;
+      return "\"$ref\"";
+    }
+  }
 }
-      |;
-
-      my $rnd_file = get_tmp_file;
-      file $rnd_file, content => $script;
-      my $content = run "perl $rnd_file $dest";
-      my $ref = decode_json($content);
-      @remote_files = @{ $ref };
-   }
-   else {
-      # fallback if no md5sum executable is available
-      for my $dir (@remote_dirs) {
-         for my $entry (list_files($dir)) {
-            next if($entry eq ".");
-            next if($entry eq "..");
-            if(is_dir("$dir/$entry")) {
-               push(@remote_dirs, "$dir/$entry");
-               next;
-            }
-
-            my $name = "$dir/$entry";
-            $name =~ s/^\Q$dest\E//;
-            push(@remote_files, {
-               name => $name,
-               path => "$dir/$entry",
-               md5  => md5("$dir/$entry"),
-            });
-         }
+    |;
+
+    my $rnd_file = get_tmp_file;
+    file $rnd_file, content => $script;
+    my $content = run "perl $rnd_file $dest";
+    my $ref = decode_json($content);
+    @remote_files = @{ $ref };
+  }
+  else {
+    # fallback if no md5sum executable is available
+    for my $dir (@remote_dirs) {
+      for my $entry (list_files($dir)) {
+        next if($entry eq ".");
+        next if($entry eq "..");
+        if(is_dir("$dir/$entry")) {
+          push(@remote_dirs, "$dir/$entry");
+          next;
+        }
+
+        my $name = "$dir/$entry";
+        $name =~ s/^\Q$dest\E//;
+        push(@remote_files, {
+          name => $name,
+          path => "$dir/$entry",
+          md5  => md5("$dir/$entry"),
+        });
       }
-   }
+    }
+  }
 
-   return @remote_files;
+  return @remote_files;
 }
 
 sub _diff_files {
-   my ($files1, $files2) = @_;
-   my @diff;
+  my ($files1, $files2) = @_;
+  my @diff;
 
-   for my $file1 (@{ $files1 }) {
-      my @data = grep { ($_->{name} eq $file1->{name}) && ($_->{md5} eq $file1->{md5}) } @{ $files2 };
-      if(scalar @data == 0) {
-         push(@diff, $file1);
-      }
-   }
+  for my $file1 (@{ $files1 }) {
+    my @data = grep { ($_->{name} eq $file1->{name}) && ($_->{md5} eq $file1->{md5}) } @{ $files2 };
+    if(scalar @data == 0) {
+      push(@diff, $file1);
+    }
+  }
 
-   return @diff;
+  return @diff;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -48,45 +48,45 @@ This function will read the sysctl key $key.
 If $val is given, then this function will set the sysctl key $key.
 
  task "tune", "server01", sub {
-    if( sysctl("net.ipv4.ip_forward") == 0 ) {
-       sysctl "net.ipv4.ip_forward" => 1;
-    }
+   if( sysctl("net.ipv4.ip_forward") == 0 ) {
+     sysctl "net.ipv4.ip_forward" => 1;
+   }
  };
 
 =cut
 
 sub sysctl {
 
-   my ($key, $val) = @_;
+  my ($key, $val) = @_;
 
-   if($val) {
+  if($val) {
 
-      Rex::Logger::debug("Setting sysctl key $key to $val");
-      my $ret = run "/sbin/sysctl -n $key";
+    Rex::Logger::debug("Setting sysctl key $key to $val");
+    my $ret = run "/sbin/sysctl -n $key";
 
-      if($ret ne $val) {
-         run "/sbin/sysctl -w $key=$val";
-         if($? != 0) {
-            die("Sysctl failed $key -> $val");
-         }
-      }
-      else {
-         Rex::Logger::debug("$key has already value $val");
+    if($ret ne $val) {
+      run "/sbin/sysctl -w $key=$val";
+      if($? != 0) {
+        die("Sysctl failed $key -> $val");
       }
+    }
+    else {
+      Rex::Logger::debug("$key has already value $val");
+    }
 
-   }
-   else {
-   
-      my $ret = run "/sbin/sysctl -n $key";
-      if($? == 0) {
-         return $ret;
-      }
-      else {
-         Rex::Logger::info("Error getting sysctl key: $key", "warn");
-         die("Error getting sysctl key: $key");
-      }
+  }
+  else {
+  
+    my $ret = run "/sbin/sysctl -n $key";
+    if($? == 0) {
+      return $ret;
+    }
+    else {
+      Rex::Logger::info("Error getting sysctl key: $key", "warn");
+      die("Error getting sysctl key: $key");
+    }
 
-   }
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -44,19 +44,19 @@ use base qw(Rex::Exporter);
 This function will tail the given file.
 
  task "syslog", "server01", sub {
-    tail "/var/log/syslog";
+   tail "/var/log/syslog";
  };
 
 Or, if you want to format the output by yourself, you can define a callback function.
 
  task "syslog", "server01", sub {
-    tail "/var/log/syslog", sub {
-      my ($data) = @_;
-      
-      my $server = Rex->get_current_connection()->{'server'};
-      
-      print "$server>> $data\n";
-    };
+   tail "/var/log/syslog", sub {
+    my ($data) = @_;
+    
+    my $server = Rex->get_current_connection()->{'server'};
+    
+    print "$server>> $data\n";
+   };
  };
 
 
@@ -64,65 +64,65 @@ Or, if you want to format the output by yourself, you can define a callback func
 =cut
 
 sub tail {
-   my $file = shift;
-   my $callback = shift;
-
-   if(Rex::is_sudo()) {
-      die("Can't use tail within sudo environment.");
-   }
-
-   Rex::Logger::debug("Tailing: $file");
-
-   if(my $ssh = Rex::is_ssh()) {
-      my %stat = stat $file;
-      my $orig_size = $stat{'size'};
-      my $new_pos = $stat{'size'} - 1024;
-      if($new_pos < 0) { $new_pos = 0; }
-
-      my %new_stat;
-      my $old_pos;
-      while(1) {
-         if(!%new_stat || $new_stat{'size'} > $stat{'size'}) {
-            my $fh = file_read $file;
-            unless($fh) {
-               die("Error opening $file for reading");
-            }
-            my $data;
-
-            if(!%new_stat) {
-               $fh->seek($stat{'size'} - 1024);
-               $data = $fh->read(1024);
-            }
-            else {
-               $fh->seek($old_pos);
-               $data = $fh->read($new_stat{'size'} - $old_pos);
-            }
-            
-
-            my @lines = split(/\n/, $data);
-            shift @lines unless $old_pos;
-
-            if($callback) {
-               for my $line (@lines) {
-                  &$callback($line);
-               }
-            }
-            else {
-               print join("\n", @lines) . "\n";
-            }
-
-            $fh->close;
-            $old_pos = $new_stat{'size'};
-         }
-
-         select undef, undef, undef, 0.3;
-         %stat = %new_stat if %new_stat;
-         %new_stat = stat $file;
+  my $file = shift;
+  my $callback = shift;
+
+  if(Rex::is_sudo()) {
+    die("Can't use tail within sudo environment.");
+  }
+
+  Rex::Logger::debug("Tailing: $file");
+
+  if(my $ssh = Rex::is_ssh()) {
+    my %stat = stat $file;
+    my $orig_size = $stat{'size'};
+    my $new_pos = $stat{'size'} - 1024;
+    if($new_pos < 0) { $new_pos = 0; }
+
+    my %new_stat;
+    my $old_pos;
+    while(1) {
+      if(!%new_stat || $new_stat{'size'} > $stat{'size'}) {
+        my $fh = file_read $file;
+        unless($fh) {
+          die("Error opening $file for reading");
+        }
+        my $data;
+
+        if(!%new_stat) {
+          $fh->seek($stat{'size'} - 1024);
+          $data = $fh->read(1024);
+        }
+        else {
+          $fh->seek($old_pos);
+          $data = $fh->read($new_stat{'size'} - $old_pos);
+        }
+        
+
+        my @lines = split(/\n/, $data);
+        shift @lines unless $old_pos;
+
+        if($callback) {
+          for my $line (@lines) {
+            &$callback($line);
+          }
+        }
+        else {
+          print join("\n", @lines) . "\n";
+        }
+
+        $fh->close;
+        $old_pos = $new_stat{'size'};
       }
 
-   } else {
-      system("tail -f $file");
-   }
+      select undef, undef, undef, 0.3;
+      %stat = %new_stat if %new_stat;
+      %new_stat = stat $file;
+    }
+
+  } else {
+    system("tail -f $file");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,7 +15,7 @@ With this module you can upload a local file via sftp to a remote host.
 =head1 SYNOPSIS
 
  task "upload", "remoteserver", sub {
-    upload "localfile", "/remote/file";
+   upload "localfile", "/remote/file";
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -49,7 +49,7 @@ use base qw(Rex::Exporter);
 Perform an upload. If $remote is a directory the file will be uploaded to that directory.
 
  task "upload", "remoteserver", sub {
-    upload "localfile", "/path";
+   upload "localfile", "/path";
  };
 
 
@@ -80,105 +80,105 @@ This gets executed right before the upload() function returns.
 
 sub upload {
 
-   #### check and run before hook
-   eval {
-      my @new_args = Rex::Hook::run_hook(upload => "before", @_);
-      if(@new_args) {
-         @_ = @new_args;
-      }
-      1;
-   } or do {
-      die("Before-Hook failed. Canceling upload() action: $@");
-   };
-   ##############################
-
-   my ($local, $remote) = @_;
-
-   $local  = resolv_path($local, 1);
-   $remote = resolv_path($remote);
-
-   my $fs = Rex::Interface::Fs->create;
-
-   # if remote not set, use name of local.
-   # must be done before the next line.
-   unless($remote) {
-      $remote = basename($local);
-   }
-
-   $local = Rex::Helper::Path::get_file_path($local, caller());
-
-   # if there is a file called filename.environment then use this file
-   # ex: 
-   # upload "files/hosts", "/etc/hosts";
-   # 
-   # rex -E live ...
-   # will first look if files/hosts.live is available, if not it will
-   # use files/hosts
-
-   my $old_local = $local; # for the upload location use the given name
-
-   if(-f "$local." . Rex::Config->get_environment) {
-      $local = "$local." . Rex::Config->get_environment;
-   }
-
-   if(! -f $local) {
-      Rex::Logger::info("File Not Found: $local");
-      die("File $local not found.");
-   }
-
-   if(is_dir($remote)) {
-      $remote = $remote . '/' . basename($old_local);
-   }
-
-   # first get local md5
-   my $local_md5;
-   LOCAL {
-      $local_md5 = md5($local);
-   };
-
-   if(! $local_md5) {
-      die("Error getting local md5 sum of $local");
-   }
-
-   # than get remote md5 to test if we need to upload the file
-   my $remote_md5 = "";
-   eval {
-      $remote_md5 = md5($remote);
-   };
-
-   my $__ret;
-
-   if($local_md5 && $remote_md5 && $local_md5 eq $remote_md5) {
-      Rex::Logger::debug("local md5 and remote md5 are the same: $local_md5 eq $remote_md5. Not uploading.");
-      if(Rex::Config->get_do_reporting) {
-         $__ret = {changed => 0, ret => 0};
-      }
-   }
-   else {
-
-      Rex::Logger::debug("Uploading: $local to $remote");
-
-      #### check and run before_change hook
-      Rex::Hook::run_hook(upload => "before_change", $local, $remote);
-      ##############################
-
-      $__ret = $fs->upload($local, $remote);
-
-      #### check and run after_change hook
-      Rex::Hook::run_hook(upload => "after_change", $local, $remote, $__ret);
-      ##############################
-
-      if(Rex::Config->get_do_reporting) {
-         $__ret = {changed => 1, ret => $__ret };
-      }
-
-   }
-
-   #### check and run before hook
-   Rex::Hook::run_hook(upload => "after", @_, $__ret);
-   ##############################
-
-   return $__ret;
+  #### check and run before hook
+  eval {
+    my @new_args = Rex::Hook::run_hook(upload => "before", @_);
+    if(@new_args) {
+      @_ = @new_args;
+    }
+    1;
+  } or do {
+    die("Before-Hook failed. Canceling upload() action: $@");
+  };
+  ##############################
+
+  my ($local, $remote) = @_;
+
+  $local  = resolv_path($local, 1);
+  $remote = resolv_path($remote);
+
+  my $fs = Rex::Interface::Fs->create;
+
+  # if remote not set, use name of local.
+  # must be done before the next line.
+  unless($remote) {
+    $remote = basename($local);
+  }
+
+  $local = Rex::Helper::Path::get_file_path($local, caller());
+
+  # if there is a file called filename.environment then use this file
+  # ex: 
+  # upload "files/hosts", "/etc/hosts";
+  # 
+  # rex -E live ...
+  # will first look if files/hosts.live is available, if not it will
+  # use files/hosts
+
+  my $old_local = $local; # for the upload location use the given name
+
+  if(-f "$local." . Rex::Config->get_environment) {
+    $local = "$local." . Rex::Config->get_environment;
+  }
+
+  if(! -f $local) {
+    Rex::Logger::info("File Not Found: $local");
+    die("File $local not found.");
+  }
+
+  if(is_dir($remote)) {
+    $remote = $remote . '/' . basename($old_local);
+  }
+
+  # first get local md5
+  my $local_md5;
+  LOCAL {
+    $local_md5 = md5($local);
+  };
+
+  if(! $local_md5) {
+    die("Error getting local md5 sum of $local");
+  }
+
+  # than get remote md5 to test if we need to upload the file
+  my $remote_md5 = "";
+  eval {
+    $remote_md5 = md5($remote);
+  };
+
+  my $__ret;
+
+  if($local_md5 && $remote_md5 && $local_md5 eq $remote_md5) {
+    Rex::Logger::debug("local md5 and remote md5 are the same: $local_md5 eq $remote_md5. Not uploading.");
+    if(Rex::Config->get_do_reporting) {
+      $__ret = {changed => 0, ret => 0};
+    }
+  }
+  else {
+
+    Rex::Logger::debug("Uploading: $local to $remote");
+
+    #### check and run before_change hook
+    Rex::Hook::run_hook(upload => "before_change", $local, $remote);
+    ##############################
+
+    $__ret = $fs->upload($local, $remote);
+
+    #### check and run after_change hook
+    Rex::Hook::run_hook(upload => "after_change", $local, $remote, $__ret);
+    ##############################
+
+    if(Rex::Config->get_do_reporting) {
+      $__ret = {changed => 1, ret => $__ret };
+    }
+
+  }
+
+  #### check and run before hook
+  Rex::Hook::run_hook(upload => "after", @_, $__ret);
+  ##############################
+
+  return $__ret;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,18 +15,18 @@ With this module you can manage user and groups.
 =head1 SYNOPSIS
 
  use Rex::Commands::User;
-    
+ 
  task "create-user", "remoteserver", sub {
-    create_user "root",
-       uid => 0,
-       home => '/root',
-       comment => 'Root Account',
-       expire => '2011-05-30',
-       groups  => ['root', '...'],
-       password => 'blahblah',
-       system => 1,
-       no_create_home => TRUE,
-       ssh_key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
+   create_user "root",
+     uid => 0,
+     home => '/root',
+     comment => 'Root Account',
+     expire => '2011-05-30',
+     groups  => ['root', '...'],
+     password => 'blahblah',
+     system => 1,
+     no_create_home => TRUE,
+     ssh_key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -52,8 +52,39 @@ use vars qw(@EXPORT);
 use base qw(Rex::Exporter);
 
 @EXPORT = qw(create_user delete_user get_uid get_user user_list
-               user_groups create_group delete_group get_group get_gid
-               );
+  user_groups create_group delete_group get_group get_gid
+  account
+);
+
+=item account($name, %option)
+
+Manage user account.
+
+ account "krimdomu",
+    ensure   => "present",
+    uid      => 509,
+    home     => '/root',
+    comment  => 'User Account',
+    expire   => '2011-05-30',
+    groups   => ['root', '...'],
+    password => 'blahblah',
+    system   => 1,
+    no_create_home => TRUE,
+    ssh_key        => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
+
+=cut
+
+sub account {
+  my ( $name, %option ) = @_;
+
+  if ( exists $option{ensure} && $option{ensure} eq "present" ) {
+    delete $option{ensure};
+    create_user( $name, %option );
+  }
+  elsif ( exists $option{ensure} && $option{ensure} eq "absent" ) {
+    delete_user $name;
+  }
+}
 
 =item create_user($user => {})
 
@@ -62,77 +93,81 @@ Create or update a user.
 =cut
 
 sub create_user {
-   my ($user, @_data) = @_;
-
-   #### check and run before hook
-   eval {
-      my @new_args = Rex::Hook::run_hook(create_user => "before", @_);
-      if(@new_args) {
-         ($user, @_data) = @new_args;
-      }
-      1;
-   } or do {
-      die("Before-Hook failed. Canceling create_user() action: $@");
-   };
-   ##############################
-
-   my $data = {};
-
-   if(! ref($_data[0])) {
-      $data = { @_data };
-   }
-   else {
-      $data = $_data[0];
-   }
+  my ( $user, @_data ) = @_;
 
-   my $uid = Rex::User->get()->create_user($user, $data);
+  #### check and run before hook
+  eval {
+    my @new_args = Rex::Hook::run_hook( create_user => "before", @_ );
+    if (@new_args) {
+      ( $user, @_data ) = @new_args;
+    }
+    1;
+  } or do {
+    die("Before-Hook failed. Canceling create_user() action: $@");
+  };
+  ##############################
 
-   if(defined $data->{"ssh_key"} && ! defined $data->{"home"}) {
-      Rex::Logger::debug("If ssh_key option is used you have to specify home, too.");
-      die("If ssh_key option is used you have to specify home, too.");
-   }
+  my $data = {};
 
-   if(defined $data->{"ssh_key"}) {
+  if ( !ref( $_data[0] ) ) {
+    $data = {@_data};
+  }
+  else {
+    $data = $_data[0];
+  }
 
-      if(
-            ! ( exists $data->{"no-create-home"} && $data->{"no-create-home"} )
+  my $uid = Rex::User->get()->create_user( $user, $data );
 
-            && 
+  if ( defined $data->{"ssh_key"} && !defined $data->{"home"} ) {
+    Rex::Logger::debug(
+      "If ssh_key option is used you have to specify home, too.");
+    die("If ssh_key option is used you have to specify home, too.");
+  }
 
-            ! ( exists $data->{"no_create_home"} && $data->{"no_create_home"} )
+  if ( defined $data->{"ssh_key"} ) {
 
-            &&
-      
-            ! is_dir($data->{"home"} . "/.ssh")
-        ) {
+    if (
+      !( exists $data->{"no-create-home"} && $data->{"no-create-home"} )
 
-         eval {
-            mkdir $data->{"home"} . "/.ssh",
-               owner => $user,
-               mode  => 700,
-               not_recursive => 1;
-         } or do {
-            # error creating .ssh directory
-            Rex::Logger::debug("Not creating .ssh directory because parent doesn't exists.");
-         };
-      }
+      &&
 
-      if(is_dir($data->{"home"} . "/.ssh")) {
+      !( exists $data->{"no_create_home"} && $data->{"no_create_home"} )
 
-         file $data->{"home"} . "/.ssh/authorized_keys",
-            content => $data->{"ssh_key"},
-            owner   => $user,
-            mode    => 600;
+      &&
 
-      }
+      !is_dir( $data->{"home"} . "/.ssh" )
+      )
+    {
 
-   }
+      eval {
+        mkdir $data->{"home"} . "/.ssh",
+          owner         => $user,
+          mode          => 700,
+          not_recursive => 1;
+      } or do {
+
+        # error creating .ssh directory
+        Rex::Logger::debug(
+          "Not creating .ssh directory because parent doesn't exists.");
+      };
+    }
 
-   #### check and run before hook
-   Rex::Hook::run_hook(create_user => "after", @_, $uid);
-   ##############################
+    if ( is_dir( $data->{"home"} . "/.ssh" ) ) {
 
-   return $uid;
+      file $data->{"home"} . "/.ssh/authorized_keys",
+        content => $data->{"ssh_key"},
+        owner   => $user,
+        mode    => 600;
+
+    }
+
+  }
+
+  #### check and run before hook
+  Rex::Hook::run_hook( create_user => "after", @_, $uid );
+  ##############################
+
+  return $uid;
 }
 
 =item get_uid($user)
@@ -142,7 +177,7 @@ Returns the uid of $user.
 =cut
 
 sub get_uid {
-   Rex::User->get()->get_uid(@_);
+  Rex::User->get()->get_uid(@_);
 }
 
 =item get_user($user)
@@ -152,7 +187,7 @@ Returns all information about $user.
 =cut
 
 sub get_user {
-   Rex::User->get()->get_user(@_);
+  Rex::User->get()->get_user(@_);
 }
 
 =item user_group($user)
@@ -162,7 +197,7 @@ Returns group membership about $user.
 =cut
 
 sub user_groups {
-   Rex::User->get()->user_groups(@_);
+  Rex::User->get()->user_groups(@_);
 }
 
 =item user_list()
@@ -170,42 +205,41 @@ sub user_groups {
 Returns user list via getent passwd.
 
  task "list_user", "server01", sub {
-    for my $user (user_list) {
-       print "name: $user / uid: " . get_uid($user) . "\n";
-    }
+   for my $user (user_list) {
+     print "name: $user / uid: " . get_uid($user) . "\n";
+   }
  };
 
 =cut
 
 sub user_list {
-   Rex::User->get()->user_list(@_);
+  Rex::User->get()->user_list(@_);
 }
 
-
 =item delete_user($user)
 
 Delete a user from the system.
 
  delete_user "trak", {
-    delete_home => 1,
-    force       => 1,
+   delete_home => 1,
+   force     => 1,
  };
 
 =cut
 
 sub delete_user {
-   my ($user, @_data) = @_;
+  my ( $user, @_data ) = @_;
 
-   my $data = {};
+  my $data = {};
 
-   if(! ref($_data[0])) {
-      $data = { @_data };
-   }
-   else {
-      $data = $_data[0];
-   }
+  if ( !ref( $_data[0] ) ) {
+    $data = {@_data};
+  }
+  else {
+    $data = $_data[0];
+  }
 
-   Rex::User->get()->rm_user($user, $data);
+  Rex::User->get()->rm_user( $user, $data );
 }
 
 =item create_group($group, {})
@@ -213,24 +247,24 @@ sub delete_user {
 Create or update a group.
 
  create_group $group, {
-    gid => 1500,
-    system => 1,
+   gid => 1500,
+   system => 1,
  };
 
 =cut
 
 sub create_group {
-   my $group = shift;
-   my @params;
+  my $group = shift;
+  my @params;
 
-   if(! ref $_[0]) {
-      push @params, { @_ };
-   }
-   else {
-      push @params, @_;
-   }
+  if ( !ref $_[0] ) {
+    push @params, {@_};
+  }
+  else {
+    push @params, @_;
+  }
 
-   Rex::User->get()->create_group($group, @params);
+  Rex::User->get()->create_group( $group, @params );
 }
 
 =item get_gid($group)
@@ -240,7 +274,7 @@ Return the group id of $group.
 =cut
 
 sub get_gid {
-   Rex::User->get()->get_gid(@_);
+  Rex::User->get()->get_gid(@_);
 }
 
 =item get_group($group)
@@ -252,7 +286,7 @@ Return information of $group.
 =cut
 
 sub get_group {
-   Rex::User->get()->get_group(@_);
+  Rex::User->get()->get_group(@_);
 }
 
 =item delete_group($group)
@@ -262,7 +296,7 @@ Delete a group.
 =cut
 
 sub delete_group {
-   Rex::User->get()->rm_group(@_);
+  Rex::User->get()->rm_group(@_);
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Commands::Virtualization;
@@ -20,10 +20,10 @@ use Rex::Virtualization;
 
 
 sub vm {
-   my ($action, $vmname, @opt) = @_;
+  my ($action, $vmname, @opt) = @_;
 
-   my $vm_obj = Rex::Virtualization->create();
-   return $vm_obj->execute($action, $vmname, @opt);
+  my $vm_obj = Rex::Virtualization->create();
+  return $vm_obj->execute($action, $vmname, @opt);
 }
 
 =head1 NAME
@@ -37,40 +37,40 @@ With this module you can manage your virtualization.
 =head1 SYNOPSIS
 
  use Rex::Commands::Virtualization;
-    
+   
  set virtualization => "LibVirt";
  set virtualization => "VBox";
-    
- use Data::Dumper;   
-
+   
+ use Data::Dumper;  
+ 
  print Dumper vm list => "all";
  print Dumper vm list => "running";
-    
+   
  vm destroy => "vm01";
-    
+   
  vm delete => "vm01"; 
-     
- vm start => "vm01";
     
+ vm start => "vm01";
+   
  vm shutdown => "vm01";
-    
+   
  vm reboot => "vm01";
-    
+   
  vm option => "vm01",
-          max_memory => 1024*1024,
-          memory     => 512*1024;
-              
+       max_memory => 1024*1024,
+       memory    => 512*1024;
+          
  print Dumper vm info => "vm01";
-    
+   
  # creating a vm on a kvm host
  vm create => "vm01",
-      storage     => [
-         {   
-            file   => "/mnt/data/libvirt/images/vm01.img",
-            dev    => "vda",
-         }   
-      ];  
-       
+    storage    => [
+      {  
+        file  => "/mnt/data/libvirt/images/vm01.img",
+        dev   => "vda",
+      }  
+    ];  
+     
  print Dumper vm hypervisor => "capabilities";
 
 =head1 EXPORTED FUNCTIONS
@@ -91,191 +91,191 @@ Create a (VirtualBox) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive,
 With a cdrom as an iso image and a natted network. The bootorder is set to "dvd".
 
  vm create => "vm01",
-      storage     => [
-         {   
-            file   => "/mnt/data/vbox/vm01.img",
-            size   => "10G",
-         },
-         {
-            file => "/mnt/iso/debian6.iso",
-         }
-      ],
-      memory => 512,
-      type => "Linux26", 
-      cpus => 1,
-      boot => "dvd";
+    storage    => [
+      {  
+        file  => "/mnt/data/vbox/vm01.img",
+        size  => "10G",
+      },
+      {
+        file => "/mnt/iso/debian6.iso",
+      }
+    ],
+    memory => 512,
+    type => "Linux26", 
+    cpus => 1,
+    boot => "dvd";
 
 
 Create a (KVM) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive, 10 GB in size beeing a file on disk.
 With a cdrom as an iso image and a bridged network on the bridge virbr0. The Bootorder is set to "cdrom".
 
  vm create => "vm01",
-      boot => "cdrom",
-      storage     => [
-         {
-            size   => "10G",
-            file   => "/mnt/data/libvirt/images/vm01.img",
-         },
-                                                                                                                                        
-         {
-            file     => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso",
-         },
-      ]; 
+    boot => "cdrom",
+    storage    => [
+      {
+        size  => "10G",
+        file  => "/mnt/data/libvirt/images/vm01.img",
+      },
+                                                                                           
+      {
+        file    => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso",
+      },
+    ]; 
 
 This is the same as above, but with all options in use.
 
  vm create => "vm01",
-      memory   => 512*1024,
-      cpus     => 1,      
-      arch     => "x86_64",
-      boot     => "cdrom",
-      clock    => "utc", 
-      emulator => "/usr/bin/qemu-system-x86_64",
-      on_poweroff => "destroy",
-      on_reboot   => "restart",
-      on_crash    => "restart",
-      storage     => [
-         {  type   => "file",
-            size   => "10G",
-            device => "disk",
-            file   => "/mnt/data/libvirt/images/vm01.img",
-            dev    => "vda",
-            bus    => "virtio",
-            address => {
-               type     => "pci",
-               domain   => "0x0000",
-               bus      => "0x00",
-               slot     => "0x05",
-               function => "0x0",
-            },
-         },
-         {  type     => "file",
-            device   => "cdrom",
-            file     => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso",
-            dev      => "hdc",
-            bus      => "ide",
-            readonly => 1,
-            address  => {                                                                                                               
-               type       => "drive",
-               controller => 0,
-               bus        => 1,
-               unit       => 0,
-            },
-         },
-      ],
-      network => [
-         {  type    => "bridge",
-            bridge  => "virbr0",
-            model   => "virtio",
-            address => {
-               type     => "pci",
-               domain   => "0x0000",
-               bus      => "0x00",
-               slot     => "0x03",
-               function => "0x0",
-            },
-         },
-      ];
+    memory  => 512*1024,
+    cpus    => 1,    
+    arch    => "x86_64",
+    boot    => "cdrom",
+    clock   => "utc", 
+    emulator => "/usr/bin/qemu-system-x86_64",
+    on_poweroff => "destroy",
+    on_reboot  => "restart",
+    on_crash   => "restart",
+    storage    => [
+      {  type  => "file",
+        size  => "10G",
+        device => "disk",
+        file  => "/mnt/data/libvirt/images/vm01.img",
+        dev   => "vda",
+        bus   => "virtio",
+        address => {
+          type    => "pci",
+          domain  => "0x0000",
+          bus    => "0x00",
+          slot    => "0x05",
+          function => "0x0",
+        },
+      },
+      {  type    => "file",
+        device  => "cdrom",
+        file    => "/mnt/data/iso/debian-6.0.2.1-amd64-netinst.iso",
+        dev    => "hdc",
+        bus    => "ide",
+        readonly => 1,
+        address  => {                                                                          
+          type     => "drive",
+          controller => 0,
+          bus      => 1,
+          unit     => 0,
+        },
+      },
+    ],
+    network => [
+      {  type   => "bridge",
+        bridge  => "virbr0",
+        model  => "virtio",
+        address => {
+          type    => "pci",
+          domain  => "0x0000",
+          bus    => "0x00",
+          slot    => "0x03",
+          function => "0x0",
+        },
+      },
+    ];
 
 Create a (Xen/HVM) VM named "vm01" with 512 MB ram and 1 cpu. One harddrive, cloned from an existing one.
 
  vm create => "vm01",
-      type   => "hvm",
-      storage     => [
-         {
-            file     => "/mnt/data/libvirt/images/vm01.img",
-            template => "/mnt/data/libvirt/images/svn01.img",                                                                           
-         },
-      ];
+    type  => "hvm",
+    storage    => [
+      {
+        file    => "/mnt/data/libvirt/images/vm01.img",
+        template => "/mnt/data/libvirt/images/svn01.img",                                                  
+      },
+    ];
 
 This is the same as above, but with all options in use.
 
  vm create => "vm01",
-      memory => 512*1024,
-      cpus   => 1,
-      boot   => "hd",
-      clock  => "utc",
-      on_poweroff => "destroy",
-      on_reboot   => "restart",
-      on_crash    => "restart",
-      storage     => [
-         {  type   => "file",
-            size   => "10G",
-            device => "disk",
-            file   => "/mnt/data/libvirt/images/vm01.img",
-            dev    => "hda",
-            bus    => "ide",
-            template => "/mnt/data/libvirt/images/svn01.img",                                                                           
-         },
-         {  type     => "file",
-            device   => "cdrom",
-            dev      => "hdc",
-            bus      => "ide",
-            readonly => 1,
-         },
-      ],
-      network => [
-         {  type    => "bridge",
-            bridge  => "virbr0",
-         },
-      ],
-      type => "hvm";
+    memory => 512*1024,
+    cpus  => 1,
+    boot  => "hd",
+    clock  => "utc",
+    on_poweroff => "destroy",
+    on_reboot  => "restart",
+    on_crash   => "restart",
+    storage    => [
+      {  type  => "file",
+        size  => "10G",
+        device => "disk",
+        file  => "/mnt/data/libvirt/images/vm01.img",
+        dev   => "hda",
+        bus   => "ide",
+        template => "/mnt/data/libvirt/images/svn01.img",                                                  
+      },
+      {  type    => "file",
+        device  => "cdrom",
+        dev    => "hdc",
+        bus    => "ide",
+        readonly => 1,
+      },
+    ],
+    network => [
+      {  type   => "bridge",
+        bridge  => "virbr0",
+      },
+    ],
+    type => "hvm";
 
 Create a (Xen/PVM) VM named "vm01" with 512 MB ram and 1 cpu. With one root partition (10GB in size) and one swap parition (1GB in size).
 
  vm create => "vm01",
-      type   => "pvm",
-      storage     => [
-         {
-            file    => "/mnt/data/libvirt/images/domains/vm01/disk.img",
-            dev     => "xvda2",
-            is_root => 1,                                                                                                               
-         },
-         {  
-            file   => "/mnt/data/libvirt/images/domains/vm01/swap.img",
-            dev    => "xvda1",
-         },
-      ];
+    type  => "pvm",
+    storage    => [
+      {
+        file   => "/mnt/data/libvirt/images/domains/vm01/disk.img",
+        dev    => "xvda2",
+        is_root => 1,                                                                          
+      },
+      {  
+        file  => "/mnt/data/libvirt/images/domains/vm01/swap.img",
+        dev   => "xvda1",
+      },
+    ];
 
 This is the same as above, but with all options in use.
 
  vm create => "vm01",
-      type   => "pvm",
-      memory => 512*1024,
-      cpus   => 1,
-      clock  => "utc",
-      on_poweroff => "destroy",
-      on_reboot   => "restart",
-      on_crash    => "restart",
-      os          => {
-         type  => "linux",
-         kernel => "/boot/vmlinuz-2.6.32-5-xen-amd64",
-         initrd => "/boot/initrd.img-2.6.32-5-xen-amd64",
-         cmdline => "root=/dev/xvda2 ro",
+    type  => "pvm",
+    memory => 512*1024,
+    cpus  => 1,
+    clock  => "utc",
+    on_poweroff => "destroy",
+    on_reboot  => "restart",
+    on_crash   => "restart",
+    os       => {
+      type  => "linux",
+      kernel => "/boot/vmlinuz-2.6.32-5-xen-amd64",
+      initrd => "/boot/initrd.img-2.6.32-5-xen-amd64",
+      cmdline => "root=/dev/xvda2 ro",
+    },
+    storage    => [
+      {  type  => "file",
+        size  => "10G",
+        device => "disk",
+        file  => "/mnt/data/libvirt/images/domains/vm01/disk.img",
+        dev   => "xvda2",
+        bus   => "xen",
+        aio   => 1, # if you want to use aio
+      },
+      {  type  => "file",
+        size  => "4G",
+        device => "disk",
+        file  => "/mnt/data/libvirt/images/domains/vm01/swap.img",
+        dev   => "xvda1",
+        bus   => "xen",
+        aio   => 1, # if you want to use aio
+      },
+    ],
+    network => [
+      {  type   => "bridge",
+        bridge  => "virbr0",
       },
-      storage     => [
-         {  type   => "file",
-            size   => "10G",
-            device => "disk",
-            file   => "/mnt/data/libvirt/images/domains/vm01/disk.img",
-            dev    => "xvda2",
-            bus    => "xen",
-            aio    => 1, # if you want to use aio
-         },
-         {  type   => "file",
-            size   => "4G",
-            device => "disk",
-            file   => "/mnt/data/libvirt/images/domains/vm01/swap.img",
-            dev    => "xvda1",
-            bus    => "xen",
-            aio    => 1, # if you want to use aio
-         },
-      ],
-      network => [
-         {  type    => "bridge",
-            bridge  => "virbr0",
-         },
-      ];
+    ];
 
 =head2 Start/Stop/Destroy
 
@@ -301,8 +301,8 @@ Hard Stop a running vm
 Currently you can only modify the memory.
 
  vm option => "name",
-         max_memory => 1024*1024, # in bytes
-         memory     => 512*1024;
+      max_memory => 1024*1024, # in bytes
+      memory    => 512*1024;
 
 =head2 Request information of a vm
 
@@ -6,20 +6,20 @@ unlink $0;
 open (my $in, "<%= $file %>") || exit(1);
 my $found=0;
 while(<$in>) {
-      chomp;
-      <% for my $r (@{ $regex }) { %>
-        if ("<%= quotemeta($r) %>") {
-            my $reg = qr/<%= $r %>/;
-            ($_ =~ $reg) && ($found=1);
-         }
-         if ("<%= quotemeta($line) %>") {
-            ($_ eq "<%= quotemeta($line) %>") && ($found=1);
-         }
-      <% } %>
+    chomp;
+    <% for my $r (@{ $regex }) { %>
+      if ("<%= quotemeta($r) %>") {
+        my $reg = qr/<%= $r %>/;
+        ($_ =~ $reg) && ($found=1);
+      }
+      if ("<%= quotemeta($line) %>") {
+        ($_ eq "<%= quotemeta($line) %>") && ($found=1);
+      }
+    <% } %>
 }
 close $in;
 if (!$found) {
-   open (my $out, ">><%= $file %>") || exit(3);
-   print $out '<%= $line %>' . "\n";
-   close $out;
+  open (my $out, ">><%= $file %>") || exit(3);
+  print $out '<%= $line %>' . "\n";
+  close $out;
 }
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -24,12 +24,12 @@ This module is the core commands module.
  user "user";
  
  password "password";
-     
+    
  environment live => sub {
-    user "root";
-    password "foobar";
-    pass_auth;
-    group frontend => "www01", "www02";
+   user "root";
+   password "foobar";
+   pass_auth;
+   group frontend => "www01", "www02";
  };
  
  
@@ -107,37 +107,37 @@ use vars qw(@EXPORT $current_desc $global_no_ssh $environments $dont_register_ta
 use base qw(Rex::Exporter);
 
 @EXPORT = qw(task desc group 
-            user password port sudo_password public_key private_key pass_auth key_auth krb5_auth no_ssh
-            get_random batch timeout max_connect_retries parallelism
-            do_task run_task run_batch needs
-            exit
-            evaluate_hostname
-            logging
-            include
-            say
-            environment
-            LOCAL
-            path
-            set
-            get
-            before after around
-            logformat log_format
-            sayformat say_format
-            connection
-            auth
-            FALSE TRUE
-            set_distributor
-            set_executor_for
-            template_function
-            report
-            make
-            source_global_profile
-            last_command_output
-            case
-            inspect
-            tmp_dir
-            cache
-          );
+        user password port sudo_password public_key private_key pass_auth key_auth krb5_auth no_ssh
+        get_random batch timeout max_connect_retries parallelism
+        do_task run_task run_batch needs
+        exit
+        evaluate_hostname
+        logging
+        include
+        say
+        environment
+        LOCAL
+        path
+        set
+        get
+        before after around
+        logformat log_format
+        sayformat say_format
+        connection
+        auth
+        FALSE TRUE
+        set_distributor
+        set_executor_for
+        template_function
+        report
+        make
+        source_global_profile
+        last_command_output
+        case
+        inspect
+        tmp_dir
+        cache
+       );
 
 our $REGISTER_SUB_HASH_PARAMTER = 0;
 
@@ -152,18 +152,18 @@ If you want to disable ssh connection for your complete tasks (for example if yo
 If you want to disable ssh connection for a given task, put I<no_ssh> in front of the task definition.
 
  no_ssh task "mytask", "myserver", sub {
-    say "Do something without a ssh connection";
+   say "Do something without a ssh connection";
  };
 
 =cut
 
 sub no_ssh {
-   if(@_) {
-      $_[0]->(no_ssh => 1);
-   }
-   else {
-      $global_no_ssh = 1;
-   }
+  if(@_) {
+    $_[0]->(no_ssh => 1);
+  }
+  else {
+    $global_no_ssh = 1;
+  }
 }
 
 =item task($name [, @servers], $funcref)
@@ -175,7 +175,7 @@ This function will create a new task.
 =item Create a local task (a server independent task)
 
  task "mytask", sub {
-    say "Do something";
+   say "Do something";
  };
 
 If you call this task with (R)?ex it will run on your local machine. You can explicit run this task on other machines if you specify the I<-H> command line parameter.
@@ -183,19 +183,19 @@ If you call this task with (R)?ex it will run on your local machine. You can exp
 =item Create a server bound task.
 
  task "mytask", "server1", sub {
-    say "Do something";
+   say "Do something";
  };
 
 You can also specify more than one server.
 
  task "mytask", "server1", "server2", "server3", sub {
-    say "Do something";
+   say "Do something";
  };
 
 Or you can use some expressions to define more than one server.
 
  task "mytask", "server[1..3]", sub {
-    say "Do something";
+   say "Do something";
  };
 
 If you want, you can overwrite the servers with the I<-H> command line parameter.
@@ -207,7 +207,7 @@ You can define server groups with the I<group> function.
  group "allserver" => "server[1..3]", "workstation[1..10]";
  
  task "mytask", group => "allserver", sub {
-    say "Do something";
+   say "Do something";
  };
 
 =back
@@ -215,117 +215,117 @@ You can define server groups with the I<group> function.
 =cut
 
 sub task {
-   my($class, $file, @tmp) = caller;
-   my @_ARGS = @_;
-
-   if(! @_) {
-      if(my $t = Rex::get_current_connection) {
-         return $t->{task};
-      }
-      return;
-   }
-
-   # for things like
-   # no_ssh task ...
-   if(wantarray) {
-      return sub {
-         my %option = @_;
+  my($class, $file, @tmp) = caller;
+  my @_ARGS = @_;
 
-         $option{class} = $class;
-         $option{file}  = $file;
-         $option{tmp}   = \@tmp;
+  if(! @_) {
+    if(my $t = Rex::get_current_connection) {
+      return $t->{task};
+    }
+    return;
+  }
+
+  # for things like
+  # no_ssh task ...
+  if(wantarray) {
+    return sub {
+      my %option = @_;
+
+      $option{class} = $class;
+      $option{file}  = $file;
+      $option{tmp}  = \@tmp;
+
+      task(@_ARGS,\%option);
+    };
+  }
+
+  if(ref($_ARGS[-1]) eq "HASH") {
+    if($_ARGS[-1]->{class}) {
+      $class = $_ARGS[-1]->{class};
+    }
 
-         task(@_ARGS,\%option);
-      };
-   }
+    if($_ARGS[-1]->{file}) {
+      $file = $_ARGS[-1]->{file};
+    }
 
-   if(ref($_ARGS[-1]) eq "HASH") {
-      if($_ARGS[-1]->{class}) {
-         $class = $_ARGS[-1]->{class};
+    if($_ARGS[-1]->{tmp}) {
+      @tmp = @{ $_ARGS[-1]->{tmp} };
+    }
+  }
+
+  my $task_name = shift;
+  my $task_name_save = $task_name;
+
+  my $options = {};
+
+  if(ref($_[-1]) eq "HASH") {
+    $options = pop;
+  }
+
+  if($global_no_ssh) {
+    $options->{"no_ssh"} = 1;
+  }
+
+  if($class ne "main" && $class ne "Rex::CLI") {
+    $task_name = $class . ":" . $task_name;
+  }
+
+  $task_name =~ s/^Rex:://;
+  $task_name =~ s/::/:/g;
+
+  if($current_desc) {
+    push(@_, $current_desc);
+    $current_desc = "";
+  }
+  else {
+    push(@_, "");
+  }
+
+  no strict 'refs';
+  no warnings;
+  push (@{"${class}::tasks"}, { name => $task_name_save, code => $_[-2] } );
+  use strict;
+  use warnings;
+
+  if(! $class->can($task_name_save) && $task_name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/) {
+    no strict 'refs';
+    Rex::Logger::debug("Registering task: ${class}::$task_name_save");
+
+    my $code = $_[-2];
+    *{"${class}::$task_name_save"} = sub {
+      Rex::Logger::info("Running task $task_name_save on current connection");
+      if(ref($_[0]) eq "HASH") {
+        $code->(@_);
       }
-
-      if($_ARGS[-1]->{file}) {
-         $file = $_ARGS[-1]->{file};
+      else {
+        if($REGISTER_SUB_HASH_PARAMTER) {
+          $code->({ @_ });
+        }
+        else {
+          $code->(@_);
+        }
       }
-
-      if($_ARGS[-1]->{tmp}) {
-         @tmp = @{ $_ARGS[-1]->{tmp} };
+    };
+    use strict;
+  } elsif(($class ne "main" && $class ne "Rex::CLI") && ! $class->can($task_name_save) && $task_name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/) {
+    # if not in main namespace, register the task as a sub
+    no strict 'refs';
+    Rex::Logger::debug("Registering task (not main namespace): ${class}::$task_name_save");
+    my $code = $_[-2];
+    *{"${class}::$task_name_save"} = sub {
+      if(ref($_[0]) eq "HASH") {
+        $code->(@_);
       }
-   }
-
-   my $task_name = shift;
-   my $task_name_save = $task_name;
-
-   my $options = {};
-
-   if(ref($_[-1]) eq "HASH") {
-      $options = pop;
-   }
-
-   if($global_no_ssh) {
-      $options->{"no_ssh"} = 1;
-   }
-
-   if($class ne "main" && $class ne "Rex::CLI") {
-      $task_name = $class . ":" . $task_name;
-   }
-
-   $task_name =~ s/^Rex:://;
-   $task_name =~ s/::/:/g;
-
-   if($current_desc) {
-      push(@_, $current_desc);
-      $current_desc = "";
-   }
-   else {
-      push(@_, "");
-   }
+      else {
+        $code->({ @_ });
+      }
+    };
 
-   no strict 'refs';
-   no warnings;
-   push (@{"${class}::tasks"}, { name => $task_name_save, code => $_[-2] } );
-   use strict;
-   use warnings;
-
-   if(! $class->can($task_name_save) && $task_name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/) {
-      no strict 'refs';
-      Rex::Logger::debug("Registering task: ${class}::$task_name_save");
-
-      my $code = $_[-2];
-      *{"${class}::$task_name_save"} = sub {
-         Rex::Logger::info("Running task $task_name_save on current connection");
-         if(ref($_[0]) eq "HASH") {
-            $code->(@_);
-         }
-         else {
-            if($REGISTER_SUB_HASH_PARAMTER) {
-               $code->({ @_ });
-            }
-            else {
-               $code->(@_);
-            }
-         }
-      };
-      use strict;
-   } elsif(($class ne "main" && $class ne "Rex::CLI") && ! $class->can($task_name_save) && $task_name_save =~ m/^[a-zA-Z_][a-zA-Z0-9_]+$/) {
-      # if not in main namespace, register the task as a sub
-      no strict 'refs';
-      Rex::Logger::debug("Registering task (not main namespace): ${class}::$task_name_save");
-      my $code = $_[-2];
-      *{"${class}::$task_name_save"} = sub {
-         if(ref($_[0]) eq "HASH") {
-            $code->(@_);
-         }
-         else {
-            $code->({ @_ });
-         }
-      };
-
-      use strict;
-   }
+    use strict;
+  }
 
-   $options->{'dont_register'} ||= $dont_register_tasks;
-   Rex::TaskList->create()->create_task($task_name, @_, $options);
+  $options->{'dont_register'} ||= $dont_register_tasks;
+  Rex::TaskList->create()->create_task($task_name, @_, $options);
 }
 
 =item desc($description)
@@ -334,13 +334,13 @@ Set the description of a task.
 
  desc "This is a task description of the following task";
  task "mytask", sub {
-    say "Do something";
+   say "Do something";
  }
 
 =cut
 
 sub desc {
-   $current_desc = shift;
+  $current_desc = shift;
 }
 
 =item group($name, @servers)
@@ -356,12 +356,12 @@ Or with the expression syntax.
 =cut
 
 sub group {
-   Rex::Group->create_group(@_);
+  Rex::Group->create_group(@_);
 }
 
 # Register set-handler for group
 Rex::Config->register_set_handler(group => sub {
-   Rex::Commands::group(@_);
+  Rex::Commands::group(@_);
 });
 
 =item batch($name, @tasks)
@@ -375,15 +375,15 @@ And call it with the I<-b> console parameter. I<rex -b name>
 =cut
 
 sub batch {
-   if($current_desc) {
-      push(@_, $current_desc);
-      $current_desc = "";
-   }
-   else {
-      push(@_, "");
-   }
-
-   Rex::Batch->create_batch(@_);
+  if($current_desc) {
+    push(@_, $current_desc);
+    $current_desc = "";
+  }
+  else {
+    push(@_, "");
+  }
+
+  Rex::Batch->create_batch(@_);
 }
 
 =item user($user)
@@ -393,7 +393,7 @@ Set the user for the ssh connection.
 =cut
 
 sub user {
-   Rex::Config->set_user(@_);
+  Rex::Config->set_user(@_);
 }
 
 =item password($password)
@@ -403,7 +403,7 @@ Set the password for the ssh connection (or for the private key file).
 =cut
 
 sub password {
-   Rex::Config->set_password(@_);
+  Rex::Config->set_password(@_);
 }
 
 =item auth(for => $entity, %data)
@@ -416,69 +416,69 @@ If you want to set special login information for a group you have to activate th
   
  group frontends => "web[01..10]";
  group backends => "be[01..05]";
-      
- auth for => "frontends" => 
-                  user => "root",
-                  password => "foobar";
     
+ auth for => "frontends" => 
+            user => "root",
+            password => "foobar";
+   
  auth for => "backends" =>
-                  user => "admin",
-                  private_key => "/path/to/id_rsa",
-                  public_key => "/path/to/id_rsa.pub",
-                  sudo => TRUE;
-    
+            user => "admin",
+            private_key => "/path/to/id_rsa",
+            public_key => "/path/to/id_rsa.pub",
+            sudo => TRUE;
+   
  task "prepare", group => ["frontends", "backends"], sub {
-    # do something
+   # do something
  };
-    
+   
  auth for => "prepare" =>
-                  user => "root";
+            user => "root";
 
 =cut
 sub auth {
-   my ($_d, $entity, %data) = @_;
-
-   my $group = Rex::Group->get_group_object($entity);
-   if(! $group) {
-      Rex::Logger::debug("No group $entity found, looking for a task.");
-      if(ref($entity) eq "Regexp") {
-         my @tasks = Rex::TaskList->create()->get_tasks;
-         my @selected_tasks = grep { m/$entity/ } @tasks;
-         for my $t (@selected_tasks) {
-            auth($_d, $t, %data);
-         }
-         return;
-      }
-      else {
-         $group = Rex::TaskList->create()->get_task($entity);
+  my ($_d, $entity, %data) = @_;
+
+  my $group = Rex::Group->get_group_object($entity);
+  if(! $group) {
+    Rex::Logger::debug("No group $entity found, looking for a task.");
+    if(ref($entity) eq "Regexp") {
+      my @tasks = Rex::TaskList->create()->get_tasks;
+      my @selected_tasks = grep { m/$entity/ } @tasks;
+      for my $t (@selected_tasks) {
+        auth($_d, $t, %data);
       }
-   }
-
-   if(! $group) {
-      Rex::Logger::info("Group or Task $entity not found.");
       return;
-   }
-
-   if(ref($group) eq "Rex::Group") {
-      Rex::Logger::debug("=================================================");
-      Rex::Logger::debug("You're setting special login credentials for a Group.");
-      Rex::Logger::debug("Please remember that the default auth information/task auth information has precedence.");
-      Rex::Logger::debug("If you want to overwrite this behaviour please use ,,use Rex -feature => 0.31;'' in your Rexfile.");
-      Rex::Logger::debug("=================================================");
-   }
-
-   if(exists $data{pass_auth}) {
-      $data{auth_type} = "pass";
-   }
-   if(exists $data{key_auth}) {
-      $data{auth_type} = "key";
-   }
-   if(exists $data{krb5_auth}) {
-      $data{auth_type} = "krb5";
-   }
-
-   Rex::Logger::debug("Setting auth info for " . ref($group) . " $entity");
-   $group->set_auth(%data);
+    }
+    else {
+      $group = Rex::TaskList->create()->get_task($entity);
+    }
+  }
+
+  if(! $group) {
+    Rex::Logger::info("Group or Task $entity not found.");
+    return;
+  }
+
+  if(ref($group) eq "Rex::Group") {
+    Rex::Logger::debug("=================================================");
+    Rex::Logger::debug("You're setting special login credentials for a Group.");
+    Rex::Logger::debug("Please remember that the default auth information/task auth information has precedence.");
+    Rex::Logger::debug("If you want to overwrite this behaviour please use ,,use Rex -feature => 0.31;'' in your Rexfile.");
+    Rex::Logger::debug("=================================================");
+  }
+
+  if(exists $data{pass_auth}) {
+    $data{auth_type} = "pass";
+  }
+  if(exists $data{key_auth}) {
+    $data{auth_type} = "key";
+  }
+  if(exists $data{krb5_auth}) {
+    $data{auth_type} = "krb5";
+  }
+
+  Rex::Logger::debug("Setting auth info for " . ref($group) . " $entity");
+  $group->set_auth(%data);
 }
 
 
@@ -490,7 +490,7 @@ Set the port where the ssh server is listening.
 =cut
 
 sub port {
-   Rex::Config->set_port(@_);
+  Rex::Config->set_port(@_);
 }
 
 =item sudo_password($password)
@@ -500,7 +500,7 @@ Set the password for the sudo command.
 =cut
 
 sub sudo_password {
-   Rex::Config->set_sudo_password(@_);
+  Rex::Config->set_sudo_password(@_);
 }
 
 =item timeout($seconds)
@@ -510,7 +510,7 @@ Set the timeout for the ssh connection and other network related stuff.
 =cut
 
 sub timeout {
-   Rex::Config->set_timeout(@_);
+  Rex::Config->set_timeout(@_);
 }
 
 =item max_connect_retries($count)
@@ -519,7 +519,7 @@ Set the maximum number of connection retries.
 
 =cut
 sub max_connect_retries {
-   Rex::Config->set_max_connect_fails(@_);
+  Rex::Config->set_max_connect_fails(@_);
 }
 
 =item get_random($count, @chars)
@@ -548,12 +548,12 @@ sub get_random {
 Call $task from an other task. Will execute the given $task with the servers defined in $task.
 
  task "task1", "server1", sub {
-    say "Running on server1";
-    do_task "task2";
+   say "Running on server1";
+   do_task "task2";
  };
  
  task "task2", "server2", sub {
-    say "Running on server2";
+   say "Running on server2";
  };
 
 You may also use an arrayRef for $task if you want to call multiple tasks.
@@ -563,16 +563,16 @@ You may also use an arrayRef for $task if you want to call multiple tasks.
 =cut
 
 sub do_task {
-   my $task = shift;
+  my $task = shift;
 
-   if(ref($task) eq "ARRAY") {
-      for my $t (@{$task}) {
-         Rex::TaskList->create()->run($t);
-      }
-   }
-   else {
-      return Rex::TaskList->create()->run($task);
-   }
+  if(ref($task) eq "ARRAY") {
+    for my $t (@{$task}) {
+      Rex::TaskList->create()->run($t);
+    }
+  }
+  else {
+    return Rex::TaskList->create()->run($task);
+  }
 }
 
 =item run_task($task_name, %option)
@@ -584,58 +584,58 @@ Run a task on a given host.
 Do something on server5 if memory is less than 100 MB free on server3.
 
  task "prepare", "server5", sub {
-    my $free_mem = run_task "get_free_mem", on => "server3";
-    if($free_mem < 100) {
-       say "Less than 100 MB free mem on server3";
-       # create a new server instance on server5 to unload server3
-    }
+   my $free_mem = run_task "get_free_mem", on => "server3";
+   if($free_mem < 100) {
+     say "Less than 100 MB free mem on server3";
+     # create a new server instance on server5 to unload server3
+   }
  };
-    
+   
  task "get_free_mem", sub {
-     return memory->{free};
+    return memory->{free};
  };
 
 If called without a hostname the task is run localy.
 
  # this task will run on server5
  task "prepare", "server5", sub {
-    # this will call task check_something. but this task will run on localhost.
-    my $check = run_task "check_something";
+   # this will call task check_something. but this task will run on localhost.
+   my $check = run_task "check_something";
  }
-   
+  
  task "check_something", "server4", sub {
-    return "foo";
+   return "foo";
  };
 
 If you want to add custom parameters for the task you can do it this way.
 
  task "prepare", "server5", sub {
-   run_task "check_something", on => "foo", params => { param1 => "value1", param2 => "value2" };
+  run_task "check_something", on => "foo", params => { param1 => "value1", param2 => "value2" };
  };
 
 =cut
 
 sub run_task {
-   my ($task_name, %option) = @_;
+  my ($task_name, %option) = @_;
 
-   if(exists $option{on}) {
-      my $task = Rex::TaskList->create()->get_task($task_name);
-      if(exists $option{params}) {
-         $task->run($option{on}, params => $option{params});
-      }
-      else {
-         $task->run($option{on});
-      }
-   }
-   else {
-      my $task = Rex::TaskList->create()->get_task($task_name);
-      if(exists $option{params}) {
-         $task->run("<local>", params => $option{params});
-      }
-      else {
-         $task->run("<local>");
-      }
-   }
+  if(exists $option{on}) {
+    my $task = Rex::TaskList->create()->get_task($task_name);
+    if(exists $option{params}) {
+      $task->run($option{on}, params => $option{params});
+    }
+    else {
+      $task->run($option{on});
+    }
+  }
+  else {
+    my $task = Rex::TaskList->create()->get_task($task_name);
+    if(exists $option{params}) {
+      $task->run("<local>", params => $option{params});
+    }
+    else {
+      $task->run("<local>");
+    }
+  }
 
 }
 
@@ -650,16 +650,16 @@ It calls internally run_task, and passes it any option given.
 =cut
 
 sub run_batch {
-   my ($batch_name, %option) = @_;
-
-   my @tasks = Rex::Batch->get_batch($batch_name);
-   my @results;   
-   for my $task (@tasks) {
-      my $return = run_task $task, %option;
-      push @results, $return;
-   }
-   
-   return @results;
+  my ($batch_name, %option) = @_;
+
+  my @tasks = Rex::Batch->get_batch($batch_name);
+  my @results;  
+  for my $task (@tasks) {
+    my $return = run_task $task, %option;
+    push @results, $return;
+  }
+  
+  return @results;
 }
 
 =item public_key($key)
@@ -669,7 +669,7 @@ Set the public key.
 =cut
 
 sub public_key {
-   Rex::Config->set_public_key(@_);
+  Rex::Config->set_public_key(@_);
 }
 
 =item private_key($key)
@@ -679,7 +679,7 @@ Set the private key.
 =cut
 
 sub private_key {
-   Rex::Config->set_private_key(@_);
+  Rex::Config->set_private_key(@_);
 }
 
 =item pass_auth
@@ -694,8 +694,8 @@ If you want to use password authentication, then you need to call I<pass_auth>.
 =cut
 
 sub pass_auth {
-   if(wantarray) { return "pass"; }
-   Rex::Config->set_password_auth(1);
+  if(wantarray) { return "pass"; }
+  Rex::Config->set_password_auth(1);
 }
 
 =item key_auth
@@ -711,8 +711,8 @@ If you want to use pubkey authentication, then you need to call I<key_auth>.
 =cut
 
 sub key_auth {
-   if(wantarray) { return "key"; }
-   Rex::Config->set_key_auth(1);
+  if(wantarray) { return "key"; }
+  Rex::Config->set_key_auth(1);
 }
 
 =item krb5_auth
@@ -727,8 +727,8 @@ This authentication mechanism is only available if you use Net::OpenSSH.
 =cut
 
 sub krb5_auth {
-   if(wantarray) { return "krb5"; }
-   Rex::Config->set_krb5_auth(1);
+  if(wantarray) { return "krb5"; }
+  Rex::Config->set_krb5_auth(1);
 }
 
 =item parallelism($count)
@@ -738,7 +738,7 @@ Will execute the tasks in parallel on the given servers. $count is the thread co
 =cut
 
 sub parallelism {
-   Rex::Config->set_parallelism($_[0]);
+  Rex::Config->set_parallelism($_[0]);
 }
 
 =item set_distributor($distributor)
@@ -749,7 +749,7 @@ Possible values are: Base, Gearman
 
 =cut
 sub set_distributor {
-   Rex::Config->set_distributor($_[0]);
+  Rex::Config->set_distributor($_[0]);
 }
 
 =item template_function(sub { ... })
@@ -758,7 +758,7 @@ This function sets the template processing function. So it is possible to change
 
 =cut
 sub template_function {
-   Rex::Config->set_template_function($_[0]);
+  Rex::Config->set_template_function($_[0]);
 }
 
 =item logging
@@ -780,25 +780,25 @@ With this function you can define the logging behaviour of (R)?ex.
 =cut
 
 sub logging {
-   my $args;
-
-   if($_[0] eq "-nolog" || $_[0] eq "nolog") {
-      $Rex::Logger::silent = 1 unless $Rex::Logger::debug;
-      return;
-   }
-   else {
-      $args = { @_ };
-   }
-
-   if(exists $args->{'to_file'}) {
-      Rex::Config->set_log_filename($args->{'to_file'});
-   }
-   elsif(exists $args->{'to_syslog'}) {
-      Rex::Config->set_log_facility($args->{'to_syslog'});
-   }
-   else {
-      Rex::Config->set_log_filename('rex.log');
-   }
+  my $args;
+
+  if($_[0] eq "-nolog" || $_[0] eq "nolog") {
+    $Rex::Logger::silent = 1 unless $Rex::Logger::debug;
+    return;
+  }
+  else {
+    $args = { @_ };
+  }
+
+  if(exists $args->{'to_file'}) {
+    Rex::Config->set_log_filename($args->{'to_file'});
+  }
+  elsif(exists $args->{'to_syslog'}) {
+    Rex::Config->set_log_facility($args->{'to_syslog'});
+  }
+  else {
+    Rex::Config->set_log_filename('rex.log');
+  }
 }
 
 =item needs($package [, @tasks])
@@ -814,7 +814,7 @@ I<needs> will not execute before, around and after hooks.
 Depend on all tasks in the package MyPkg. All tasks will be called with the server I<server1>.
 
  task "mytask", "server1", sub {
-    needs MyPkg;
+   needs MyPkg;
  };
 
 =item Depend on a single task in a given package.
@@ -822,13 +822,13 @@ Depend on all tasks in the package MyPkg. All tasks will be called with the serv
 Depend on the I<uname> task in the package MyPkg. The I<uname> task will be called with the server I<server1>.
 
  task "mytask", "server1", sub {
-    needs MyPkg "uname";
+   needs MyPkg "uname";
  };
 
 =item To call tasks defined in the Rexfile from within a module
 
  task "mytask", "server1", sub {
-    needs main "uname";
+   needs main "uname";
  };
 
 
@@ -837,83 +837,83 @@ Depend on the I<uname> task in the package MyPkg. The I<uname> task will be call
 =cut
 
 sub needs {
-   my ($self, @args) = @_;
+  my ($self, @args) = @_;
 
-   # if no namespace is given, use the current one
-   if(ref($self) eq "ARRAY") {
-      @args = @{ $self };
-      ($self) = caller;
-   }
+  # if no namespace is given, use the current one
+  if(ref($self) eq "ARRAY") {
+    @args = @{ $self };
+    ($self) = caller;
+  }
 
-   if($self eq "main") {
-      $self = "Rex::CLI";
-   }
+  if($self eq "main") {
+    $self = "Rex::CLI";
+  }
 
-   no strict 'refs';
-   my @maybe_tasks_to_run = @{"${self}::tasks"};
-   use strict;
+  no strict 'refs';
+  my @maybe_tasks_to_run = @{"${self}::tasks"};
+  use strict;
 
-   if(! @args && ! @maybe_tasks_to_run) {
-      @args = ($self);
-      ($self) = caller;
-   }
+  if(! @args && ! @maybe_tasks_to_run) {
+    @args = ($self);
+    ($self) = caller;
+  }
 
-   if(ref($args[0]) eq "ARRAY") {
-      @args = @{ $args[0] };
-   }
+  if(ref($args[0]) eq "ARRAY") {
+    @args = @{ $args[0] };
+  }
 
-   Rex::Logger::debug("need to call tasks from $self");
+  Rex::Logger::debug("need to call tasks from $self");
 
-   no strict 'refs';
-   my @tasks_to_run = @{"${self}::tasks"};
-   use strict;
+  no strict 'refs';
+  my @tasks_to_run = @{"${self}::tasks"};
+  use strict;
 
-   my %opts = Rex::Args->get;
+  my %opts = Rex::Args->get;
 
-   for my $task (@tasks_to_run) {
-      my $task_name = $task->{"name"};
-      if(@args && grep (/^$task_name$/, @args)) {
-         Rex::Logger::debug("Calling " . $task->{"name"});
-         &{ $task->{"code"} }(\%opts);
-      }
-      elsif(! @args) {
-         Rex::Logger::debug("Calling " . $task->{"name"});
-         &{ $task->{"code"} }(\%opts);
-      }
-   }
+  for my $task (@tasks_to_run) {
+    my $task_name = $task->{"name"};
+    if(@args && grep (/^$task_name$/, @args)) {
+      Rex::Logger::debug("Calling " . $task->{"name"});
+      &{ $task->{"code"} }(\%opts);
+    }
+    elsif(! @args) {
+      Rex::Logger::debug("Calling " . $task->{"name"});
+      &{ $task->{"code"} }(\%opts);
+    }
+  }
 
 }
 
 # register needs in main namespace
 {
-   my ($caller_pkg) = caller(1);
-   if($caller_pkg eq "Rex::CLI") {
-      no strict 'refs';
-      *{"main::needs"} = \&needs;
-      use strict;
-   }
+  my ($caller_pkg) = caller(1);
+  if($caller_pkg eq "Rex::CLI") {
+    no strict 'refs';
+    *{"main::needs"} = \&needs;
+    use strict;
+  }
 };
 
 =item include Module::Name
 
 Include a module without registering its tasks.
 
-   include qw/
-      Module::One
-      Module::Two
-   /;
+  include qw/
+    Module::One
+    Module::Two
+  /;
 
 =cut
 sub include {
-   my (@mods) = @_;
-
-   my $old_val = $dont_register_tasks;
-   $dont_register_tasks = 1;
-   for my $mod (@mods) {
-      eval "require $mod";
-      if($@) { die $@; }
-   }
-   $dont_register_tasks = $old_val;
+  my (@mods) = @_;
+
+  my $old_val = $dont_register_tasks;
+  $dont_register_tasks = 1;
+  for my $mod (@mods) {
+    eval "require $mod";
+    if($@) { die $@; }
+  }
+  $dont_register_tasks = $old_val;
 }
 
 =item environment($name => $code)
@@ -924,28 +924,28 @@ Define an environment. With environments one can use the same task for different
  user "root";
  password "foobar";
  pass_auth;
-     
+    
  # define default frontend group containing only testwww01.
  group frontend => "testwww01";
-     
+    
  # define live environment, with different user/password 
  # and a frontend server group containing www01, www02 and www03.
  environment live => sub {
-    user "root";
-    password "livefoo";
-    pass_auth;
-       
-    group frontend => "www01", "www02", "www03";
- };
+   user "root";
+   password "livefoo";
+   pass_auth;
      
+   group frontend => "www01", "www02", "www03";
+ };
+    
  # define stage environment with default user and password. but with 
  # a own frontend group containing only stagewww01.
  environment stage => sub {
-    group frontend => "stagewww01";
+   group frontend => "stagewww01";
  };
-    
+   
  task "prepare", group => "frontend", sub {
-     say run "hostname";
+    say run "hostname";
  };
 
 Calling this task I<rex prepare> will execute on testwww01. 
@@ -955,26 +955,26 @@ Calling this task I<rex -E stage prepare> will execute on stagewww01.
 You can call the function within a task to get the current environment.
 
  task "prepare", group => "frontend", sub {
-    if(environment() eq "dev") {
-       say "i'm in the dev environment";
-    }
+   if(environment() eq "dev") {
+     say "i'm in the dev environment";
+   }
  };
 
 =cut
 sub environment {
-   if(@_) {
-      my ($name, $code) = @_;
-      $environments->{$name} = $code;
+  if(@_) {
+    my ($name, $code) = @_;
+    $environments->{$name} = $code;
 
-      if(Rex::Config->get_environment eq $name) {
-         &$code();
-      }
+    if(Rex::Config->get_environment eq $name) {
+      &$code();
+    }
 
-      return 1;
-   }
-   else {
-      return Rex::Config->get_environment || "default";
-   }
+    return 1;
+  }
+  else {
+    return Rex::Config->get_environment || "default";
+  }
 }
 
 =item LOCAL(&)
@@ -982,35 +982,35 @@ sub environment {
 With the LOCAL function you can do local commands within a task that is defined to work on remote servers.
 
  task "mytask", "server1", "server2", sub {
-     # this will call 'uptime' on the servers 'server1' and 'server2'
-     say run "uptime";
-     
-     # this will call 'uptime' on the local machine.
-     LOCAL {
-        say run "uptime";
-     };
+    # this will call 'uptime' on the servers 'server1' and 'server2'
+    say run "uptime";
+    
+    # this will call 'uptime' on the local machine.
+    LOCAL {
+      say run "uptime";
+    };
  };
 
 =cut
 
 sub LOCAL (&) {
-   my $cur_conn = Rex::get_current_connection();
-   my $local_connect = Rex::Interface::Connection->create("Local");
+  my $cur_conn = Rex::get_current_connection();
+  my $local_connect = Rex::Interface::Connection->create("Local");
 
-   Rex::push_connection({
-         conn   => $local_connect,
-         ssh    => 0,
-         server => $cur_conn->{server}, 
-         cache => Rex::Interface::Cache->create(),
-         task  => task(),
-   });
+  Rex::push_connection({
+      conn  => $local_connect,
+      ssh   => 0,
+      server => $cur_conn->{server}, 
+      cache => Rex::Interface::Cache->create(),
+      task  => task(),
+  });
 
 
-   my $ret = $_[0]->();
+  my $ret = $_[0]->();
 
-   Rex::pop_connection();
+  Rex::pop_connection();
 
-   return $ret;
+  return $ret;
 }
 
 =item path(@path)
@@ -1021,7 +1021,7 @@ Set the execution path for all commands.
 
 =cut
 sub path {
-   Rex::Config->set_path([@_]);
+  Rex::Config->set_path([@_]);
 }
 
 =item set($key, $value)
@@ -1029,9 +1029,9 @@ sub path {
 Set a configuration parameter. These Variables can be used in templates as well.
 
  set database => "db01";
-      
+    
  task "prepare", sub {
-    my $db = get "database";
+   my $db = get "database";
  };
 
 Or in a template
@@ -1040,8 +1040,8 @@ Or in a template
 
 =cut
 sub set {
-   my ($key, @value) = @_;
-   Rex::Config->set($key, @value);
+  my ($key, @value) = @_;
+  Rex::Config->set($key, @value);
 }
 
 =item get($key, $value)
@@ -1049,9 +1049,9 @@ sub set {
 Get a configuration parameter.
 
  set database => "db01";
-      
+    
  task "prepare", sub {
-    my $db = get "database";
+   my $db = get "database";
  };
 
 Or in a template
@@ -1060,13 +1060,13 @@ Or in a template
 
 =cut
 sub get {
-   my ($key) = @_;
+  my ($key) = @_;
 
-   if(ref($key) eq "Rex::Value") {
-      return $key->value;
-   }
+  if(ref($key) eq "Rex::Value") {
+    return $key->value;
+  }
 
-   return Rex::Config->get($key);
+  return Rex::Config->get($key);
 }
 
 =item before($task => sub {})
@@ -1077,15 +1077,15 @@ Run code before executing the specified task.
 Note: must come after the definition of the specified task
 
  before mytask => sub {
-   my ($server) = @_;
-   run "vzctl start vm$server";
+  my ($server) = @_;
+  run "vzctl start vm$server";
  };
 
 =cut
 sub before {
-   my ($task, $code) = @_;
-   my ($package, $file, $line) = caller;
-   Rex::TaskList->create()->modify('before', $task, $code, $package, $file, $line);
+  my ($task, $code) = @_;
+  my ($package, $file, $line) = caller;
+  Rex::TaskList->create()->modify('before', $task, $code, $package, $file, $line);
 }
 
 =item after($task => sub {})
@@ -1096,18 +1096,18 @@ Run code after the task is finished.
 Note: must come after the definition of the specified task
 
  after mytask => sub {
-   my ($server, $failed) = @_;
-   if($failed) { say "Connection to $server failed."; }
-    
-   run "vzctl stop vm$server";
+  my ($server, $failed) = @_;
+  if($failed) { say "Connection to $server failed."; }
+   
+  run "vzctl stop vm$server";
  };
 
 =cut
 sub after {
-   my ($task, $code) = @_;
-   my ($package, $file, $line) = caller;
+  my ($task, $code) = @_;
+  my ($package, $file, $line) = caller;
 
-   Rex::TaskList->create()->modify('after', $task, $code, $package, $file, $line);
+  Rex::TaskList->create()->modify('after', $task, $code, $package, $file, $line);
 }
 
 =item around($task => sub {})
@@ -1118,22 +1118,22 @@ Run code before and after the task is finished.
 Note: must come after the definition of the specified task
 
  around mytask => sub {
-   my ($server, $position) = @_;
-   
-   unless($position) {
-      say "Before Task\n";
-   }
-   else {
-      say "After Task\n";
-   }
+  my ($server, $position) = @_;
+  
+  unless($position) {
+    say "Before Task\n";
+  }
+  else {
+    say "After Task\n";
+  }
  };
 
 =cut
 sub around {
-   my ($task, $code) = @_;
-   my ($package, $file, $line) = caller;
-   
-   Rex::TaskList->create()->modify('around', $task, $code, $package, $file, $line);
+  my ($task, $code) = @_;
+  my ($package, $file, $line) = caller;
+  
+  Rex::TaskList->create()->modify('around', $task, $code, $package, $file, $line);
 }
 
 
@@ -1155,8 +1155,8 @@ Default is: [%D] %l - %s
 
 =cut
 sub logformat {
-   my ($format) = @_;
-   $Rex::Logger::format = $format;
+  my ($format) = @_;
+  $Rex::Logger::format = $format;
 }
 
 sub log_format { logformat(@_); }
@@ -1166,12 +1166,12 @@ sub log_format { logformat(@_); }
 This function returns the current connection object.
 
  task "foo", group => "baz", sub {
-    say "Current Server: " . connection->server;
+   say "Current Server: " . connection->server;
  };
 
 =cut
 sub connection {
-   return Rex::get_current_connection()->{conn};
+  return Rex::get_current_connection()->{conn};
 }
 
 =item cache
@@ -1180,13 +1180,13 @@ This function returns the current cache object.
 
 =cut
 sub cache {
-   my ($type) = @_;
+  my ($type) = @_;
 
-   if(! $type) {
-      return Rex::get_cache();
-   }
+  if(! $type) {
+    return Rex::get_cache();
+  }
 
-   Rex::Config->set_cache_type($type);
+  Rex::Config->set_cache_type($type);
 }
 
 =item profiler
@@ -1195,13 +1195,13 @@ Returns the profiler object for the current connection.
 
 =cut
 sub profiler {
-   my $c_profiler = Rex::get_current_connection()->{"profiler"};
-   unless($c_profiler) {
-      $c_profiler = $profiler || Rex::Profiler->new;
-      $profiler = $c_profiler;
-   }
+  my $c_profiler = Rex::get_current_connection()->{"profiler"};
+  unless($c_profiler) {
+    $c_profiler = $profiler || Rex::Profiler->new;
+    $profiler = $c_profiler;
+  }
 
-   return $c_profiler;
+  return $c_profiler;
 }
 
 =item report($switch, $type)
@@ -1212,21 +1212,21 @@ This function will initialize the reporting.
 
 =cut
 sub report {
-   my ($str, $type) = @_;
+  my ($str, $type) = @_;
 
-   $type ||= "Base";
-   Rex::Config->set_report_type($type);
+  $type ||= "Base";
+  Rex::Config->set_report_type($type);
 
-   if($str eq "-on" || $str eq "on") {
-      Rex::Config->set_do_reporting(1);
-      return;
-   }
-   elsif($str eq "-off" || $str eq "off") {
-      Rex::Config->set_do_reporting(0);
-      return;
-   }
+  if($str eq "-on" || $str eq "on") {
+    Rex::Config->set_do_reporting(1);
+    return;
+  }
+  elsif($str eq "-off" || $str eq "off") {
+    Rex::Config->set_do_reporting(0);
+    return;
+  }
 
-   return Rex::get_current_connection()->{reporter};
+  return Rex::get_current_connection()->{reporter};
 }
 
 =item source_global_profile(0|1)
@@ -1236,8 +1236,8 @@ If this option is set, every run() command will first source /etc/profile before
 =cut
 
 sub source_global_profile {
-   my ($source) = @_;
-   Rex::Config->set_source_global_profile($source);
+  my ($source) = @_;
+  Rex::Config->set_source_global_profile($source);
 }
 
 =item last_command_output
@@ -1247,14 +1247,14 @@ This function returns the output of the last "run" command.
 On a debian system this example will return the output of I<apt-get install foobar>.
 
  task "mytask", "myserver", sub {
-    install "foobar";
-    say last_command_output();
+   install "foobar";
+   say last_command_output();
  };
 
 =cut
 
 sub last_command_output {
-   return $Rex::Commands::Run::LAST_OUTPUT->[0];
+  return $Rex::Commands::Run::LAST_OUTPUT->[0];
 }
 
 =item case($compare, $option)
@@ -1262,49 +1262,49 @@ sub last_command_output {
 This is a function to compare a string with some given options.
 
  task "mytask", "myserver", sub {
-    my $ntp_service = case operating_sytem, {
-                         Debian  => "ntp",
-                         default => "ntpd",
-                      };
-      
-    my $ntp_service = case operating_sytem, {
-                         qr{debian}i => "ntp",
-                         default     => "ntpd",
-                      };
-     
-    my $ntp_service = case operating_sytem, {
-                         qr{debian}i => "ntp",
-                         default     => sub { return "foo"; },
-                      };
+   my $ntp_service = case operating_sytem, {
+                 Debian  => "ntp",
+                 default => "ntpd",
+               };
+    
+   my $ntp_service = case operating_sytem, {
+                 qr{debian}i => "ntp",
+                 default    => "ntpd",
+               };
+    
+   my $ntp_service = case operating_sytem, {
+                 qr{debian}i => "ntp",
+                 default    => sub { return "foo"; },
+               };
  };
 
 =cut
 sub case {
-   my ($compare, $option) = @_;
-
-   my $to_return = undef;
-
-   if(exists $option->{$compare}) {
-      $to_return = $option->{$compare};
-   }
-   else {
-      for my $key (keys %{ $option }) {
-         if($compare =~ $key) {
-            $to_return = $option->{$key};
-            last;
-         }
+  my ($compare, $option) = @_;
+
+  my $to_return = undef;
+
+  if(exists $option->{$compare}) {
+    $to_return = $option->{$compare};
+  }
+  else {
+    for my $key (keys %{ $option }) {
+      if($compare =~ $key) {
+        $to_return = $option->{$key};
+        last;
       }
-   }
+    }
+  }
 
-   if(exists $option->{default} && ! $to_return) {
-      $to_return = $option->{default};
-   }
+  if(exists $option->{default} && ! $to_return) {
+    $to_return = $option->{default};
+  }
 
-   if(ref $to_return eq "CODE") {
-      $to_return = &$to_return();
-   }
+  if(ref $to_return eq "CODE") {
+    $to_return = &$to_return();
+  }
 
-   return $to_return;
+  return $to_return;
 }
 
 =item set_executor_for($type, $executor)
@@ -1315,7 +1315,7 @@ Set the executor for a special type. This is primary used for the upload_and_run
 
 =cut
 sub set_executor_for {
-   Rex::Config->set_executor_for(@_);
+  Rex::Config->set_executor_for(@_);
 }
 
 =item tmp_dir($tmp_dir)
@@ -1325,7 +1325,7 @@ Set the tmp directory on the remote host to store temporary files.
 =cut
 
 sub tmp_dir {
-   Rex::Config->set_tmp_dir(@_);
+  Rex::Config->set_tmp_dir(@_);
 }
 
 =item inspect($varRef)
@@ -1333,12 +1333,12 @@ sub tmp_dir {
 This function dumps the contents of a variable to STDOUT.
 
 task "mytask", "myserver", sub {
-   my $myvar = {
-      name => "foo",
-      sys  => "bar",
-   };
-    
-   inspect $myvar;
+  my $myvar = {
+    name => "foo",
+    sys  => "bar",
+  };
+   
+  inspect $myvar;
 };
 
 =cut
@@ -1347,133 +1347,133 @@ task "mytask", "myserver", sub {
 
 my $depth = 0;
 sub _dump_hash {
-   my ($hash, $option) = @_;
-
-   unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
-      print "{\n";
-   }
-   $depth++;
-
-   for my $key (keys %{ $hash }) {
-      _print_indent($option);
-      if(exists $option->{prepend_key}) { print $option->{prepend_key}; }
-      print "$key" . ( exists $option->{key_value_sep} ? $option->{key_value_sep} : " => " );
-      _dump_var($hash->{$key});
-   }
-
-   $depth--;
-   _print_indent($option);
-
-   unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
-      print "}\n";
-   }
+  my ($hash, $option) = @_;
+
+  unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
+    print "{\n";
+  }
+  $depth++;
+
+  for my $key (keys %{ $hash }) {
+    _print_indent($option);
+    if(exists $option->{prepend_key}) { print $option->{prepend_key}; }
+    print "$key" . ( exists $option->{key_value_sep} ? $option->{key_value_sep} : " => " );
+    _dump_var($hash->{$key});
+  }
+
+  $depth--;
+  _print_indent($option);
+
+  unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
+    print "}\n";
+  }
 }
 
 sub _dump_array {
-   my ($array, $option) = @_;
+  my ($array, $option) = @_;
 
-   unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
-      print "[\n";
-   }
-   $depth++;
+  unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
+    print "[\n";
+  }
+  $depth++;
 
-   for my $itm (@{ $array }) {
-      _print_indent($option);
-      _dump_var($itm);
-   }
+  for my $itm (@{ $array }) {
+    _print_indent($option);
+    _dump_var($itm);
+  }
 
-   $depth--;
-   _print_indent($option);
+  $depth--;
+  _print_indent($option);
 
-   unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
-      print "]\n";
-   }
+  unless($depth == 0 && exists $option->{no_root} && $option->{no_root}) {
+    print "]\n";
+  }
 }
 
 sub _print_indent {
-   my ($option) = @_;
-   unless($depth == 1 && exists $option->{no_root} && $option->{no_root}) {
-      print "   " x $depth;
-   }
+  my ($option) = @_;
+  unless($depth == 1 && exists $option->{no_root} && $option->{no_root}) {
+    print "  " x $depth;
+  }
 }
 
 sub _dump_var {
-   my ($var, $option) = @_;
-
-   if(ref $var eq "HASH") {
-      _dump_hash($var, $option);
-   }
-   elsif(ref $var eq "ARRAY") {
-      _dump_array($var, $option);
-   }
-   else {
-      if(defined $var) {
-         $var =~ s/\n/\\n/gms;
-         $var =~ s/\r/\\r/gms;
-         $var =~ s/'/\\'/gms;
-
-         print "'$var'\n";
-      }
-      else {
-         print "no value\n";
-      }
-   }
+  my ($var, $option) = @_;
+
+  if(ref $var eq "HASH") {
+    _dump_hash($var, $option);
+  }
+  elsif(ref $var eq "ARRAY") {
+    _dump_array($var, $option);
+  }
+  else {
+    if(defined $var) {
+      $var =~ s/\n/\\n/gms;
+      $var =~ s/\r/\\r/gms;
+      $var =~ s/'/\\'/gms;
+
+      print "'$var'\n";
+    }
+    else {
+      print "no value\n";
+    }
+  }
 }
 
 sub inspect {
-   _dump_var(@_);
+  _dump_var(@_);
 }
 
 ######### private functions
 
 sub evaluate_hostname {
-   my $str = shift;
-   return unless $str;
+  my $str = shift;
+  return unless $str;
 
-   my ($start, $from, $to, $dummy, $step, $end) = $str =~ m/^([0-9\.\w\-:]+)\[(\d+)..(\d+)(\/(\d+))?\]([0-9\w\.\-:]+)?$/;
+  my ($start, $from, $to, $dummy, $step, $end) = $str =~ m/^([0-9\.\w\-:]+)\[(\d+)..(\d+)(\/(\d+))?\]([0-9\w\.\-:]+)?$/;
 
-   unless($start) {
-      return $str;
-   }
+  unless($start) {
+    return $str;
+  }
 
-   $end  ||= '';
-   $step ||= 1;
+  $end  ||= '';
+  $step ||= 1;
 
-   my $strict_length = 0;
-   if( length $from == length $to ) {
-      $strict_length = length $to;
-   }
+  my $strict_length = 0;
+  if( length $from == length $to ) {
+    $strict_length = length $to;
+  }
 
-   my @ret = ();
-   for(; $from <= $to; $from += $step) {
-         my $format = "%0".$strict_length."i";
-         push @ret, $start . sprintf($format, $from) . $end;
-   }
+  my @ret = ();
+  for(; $from <= $to; $from += $step) {
+      my $format = "%0".$strict_length."i";
+      push @ret, $start . sprintf($format, $from) . $end;
+  }
 
-   return @ret;
+  return @ret;
 }
 
 sub exit {
-   Rex::Logger::info("Exiting Rex...");
-   Rex::Logger::info("Cleaning up...");
+  Rex::Logger::info("Exiting Rex...");
+  Rex::Logger::info("Cleaning up...");
 
-   Rex::global_sudo(0);
-   unlink("$::rexfile.lock") if($::rexfile);
-   CORE::exit($_[0] || 0);
+  Rex::global_sudo(0);
+  unlink("$::rexfile.lock") if($::rexfile);
+  CORE::exit($_[0] || 0);
 }
 
 sub get_environment {
-   my ($class, $env) = @_;
+  my ($class, $env) = @_;
 
-   if(exists $environments->{$env}) {
-      return $environments->{$env};
-   }
+  if(exists $environments->{$env}) {
+    return $environments->{$env};
+  }
 }
 
 sub get_environments {
-   my $class = shift;
+  my $class = shift;
 
-   return sort { $a cmp $b } keys %{$environments};
+  return sort { $a cmp $b } keys %{$environments};
 }
 
 =item sayformat($format)
@@ -1497,31 +1497,31 @@ asis - will print every single parameter in its own line. This is usefull if you
 =cut
 
 sub sayformat {
-   my ($format) = @_;
-   Rex::Config->set_say_format($format);
+  my ($format) = @_;
+  Rex::Config->set_say_format($format);
 }
 
 sub say_format { sayformat(@_); }
 
 sub say {
-   my (@data) = @_;
+  my (@data) = @_;
 
-   return unless defined $_[0];
+  return unless defined $_[0];
 
-   my $format = Rex::Config->get_say_format;
-   if(! defined $format || $format eq "default") {
-      print @_, "\n";
-      return;
-   }
+  my $format = Rex::Config->get_say_format;
+  if(! defined $format || $format eq "default") {
+    print @_, "\n";
+    return;
+  }
 
-   if($format eq "asis") {
-      print join("\n", @_);
-      return;
-   }
+  if($format eq "asis") {
+    print join("\n", @_);
+    return;
+  }
 
-   for my $line (@data) {
-      print _format_string($format, $line) . "\n";
-   }
+  for my $line (@data) {
+    print _format_string($format, $line) . "\n";
+  }
 
 }
 
@@ -1529,43 +1529,43 @@ sub say {
 # %h - Host
 # %s - Logstring
 sub _format_string {
-   my ($format, $line) = @_;
+  my ($format, $line) = @_;
 
-   my $date = _get_timestamp();
-   my $host = Rex::get_current_connection() ? Rex::get_current_connection()->{conn}->server : "<local>";
-   my $pid = $$;
+  my $date = _get_timestamp();
+  my $host = Rex::get_current_connection() ? Rex::get_current_connection()->{conn}->server : "<local>";
+  my $pid = $$;
 
-   $format =~ s/\%D/$date/gms;
-   $format =~ s/\%h/$host/gms;
-   $format =~ s/\%s/$line/gms;
-   $format =~ s/\%p/$pid/gms;
+  $format =~ s/\%D/$date/gms;
+  $format =~ s/\%h/$host/gms;
+  $format =~ s/\%s/$line/gms;
+  $format =~ s/\%p/$pid/gms;
 
-   return $format;
+  return $format;
 }
 
 sub _get_timestamp {
-   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-   $mon++;
-   $year += 1900;
-
-   return "$year-" 
-               . sprintf("%02i", $mon) . "-" 
-               . sprintf("%02i", $mday) . " " 
-               . sprintf("%02i", $hour) . ":" 
-               . sprintf("%02i", $min) . ":" 
-               . sprintf("%02i", $sec);
+  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+  $mon++;
+  $year += 1900;
+
+  return "$year-" 
+          . sprintf("%02i", $mon) . "-" 
+          . sprintf("%02i", $mday) . " " 
+          . sprintf("%02i", $hour) . ":" 
+          . sprintf("%02i", $min) . ":" 
+          . sprintf("%02i", $sec);
 }
 
 sub TRUE {
-   return 1;
+  return 1;
 }
 
 sub FALSE {
-   return 0;
+  return 0;
 }
 
 sub make(&) {
-   return $_[0];
+  return $_[0];
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -31,524 +31,524 @@ use YAML;
 use Data::Dumper;
 
 our ($user, $password, $port,
-            $timeout, $max_connect_fails,
-            $password_auth, $key_auth, $krb5_auth, $public_key, $private_key, $parallelism, $log_filename, $log_facility, $sudo_password,
-            $ca_file, $ca_cert, $ca_key,
-            $path, $no_path_cleanup,
-            $set_param,
-            $environment,
-            $connection_type,
-            $distributor,
-            $template_function,
-            $SET_HANDLER, $HOME_CONFIG, $HOME_CONFIG_YAML,
-            %SSH_CONFIG_FOR,
-            $sudo_without_locales,
-            $sudo_without_sh,
-            $no_tty,
-            $source_global_profile, $source_profile,
-            %executor_for,
-            $allow_empty_groups,
-            $use_server_auth,
-            $tmp_dir,
-            %openssh_opt,
-            $use_cache, $cache_type,
-            $use_sleep_hack,
-            $report_type,
-            $do_reporting,
-            $say_format,
-            $exec_autodie);
+        $timeout, $max_connect_fails,
+        $password_auth, $key_auth, $krb5_auth, $public_key, $private_key, $parallelism, $log_filename, $log_facility, $sudo_password,
+        $ca_file, $ca_cert, $ca_key,
+        $path, $no_path_cleanup,
+        $set_param,
+        $environment,
+        $connection_type,
+        $distributor,
+        $template_function,
+        $SET_HANDLER, $HOME_CONFIG, $HOME_CONFIG_YAML,
+        %SSH_CONFIG_FOR,
+        $sudo_without_locales,
+        $sudo_without_sh,
+        $no_tty,
+        $source_global_profile, $source_profile,
+        %executor_for,
+        $allow_empty_groups,
+        $use_server_auth,
+        $tmp_dir,
+        %openssh_opt,
+        $use_cache, $cache_type,
+        $use_sleep_hack,
+        $report_type,
+        $do_reporting,
+        $say_format,
+        $exec_autodie);
 
 # some defaults
 %executor_for = (
-   perl   => "perl",
-   python => "python",
-   ruby   => "ruby",
-   bash   => "bash",
+  perl  => "perl",
+  python => "python",
+  ruby  => "ruby",
+  bash  => "bash",
 );
 
 sub set_exec_autodie {
-   my $class = shift;
-   $exec_autodie = shift;
+  my $class = shift;
+  $exec_autodie = shift;
 }
 
 sub get_exec_autodie {
-   return $exec_autodie;
+  return $exec_autodie;
 }
 sub set_no_path_cleanup {
-   my $class = shift;
-   $no_path_cleanup = shift;
+  my $class = shift;
+  $no_path_cleanup = shift;
 }
 
 sub get_no_path_cleanup {
-   return $no_path_cleanup;
+  return $no_path_cleanup;
 }
 
 sub set_source_profile {
-   my $class = shift;
-   $source_profile = shift;
+  my $class = shift;
+  $source_profile = shift;
 }
 
 sub get_source_profile {
-   return $source_profile;
+  return $source_profile;
 }
 
 sub set_say_format {
-   my $class = shift;
-   $say_format = shift;
+  my $class = shift;
+  $say_format = shift;
 }
 
 sub get_say_format {
-   return $say_format;
+  return $say_format;
 }
 
 sub set_do_reporting {
-   my $class = shift;
-   $do_reporting = shift;
+  my $class = shift;
+  $do_reporting = shift;
 }
 
 sub get_do_reporting {
-   return $do_reporting;
+  return $do_reporting;
 }
 
 sub set_report_type {
-   my $class = shift;
-   $report_type = shift;
+  my $class = shift;
+  $report_type = shift;
 }
 
 sub get_report_type {
-   if(exists $ENV{REX_REPORT_TYPE}) {
-      return $ENV{REX_REPORT_TYPE};
-   }
+  if(exists $ENV{REX_REPORT_TYPE}) {
+    return $ENV{REX_REPORT_TYPE};
+  }
 
-   return $report_type;
+  return $report_type;
 }
 
 sub set_sleep_hack {
-   my $class = shift;
-   $use_sleep_hack = shift;
+  my $class = shift;
+  $use_sleep_hack = shift;
 }
 
 sub get_sleep_hack {
-   return $use_sleep_hack;
+  return $use_sleep_hack;
 }
 
 sub set_cache_type {
-   my $class = shift;
-   $cache_type = shift;
+  my $class = shift;
+  $cache_type = shift;
 }
 
 sub get_cache_type {
-   if(exists $ENV{REX_CACHE_TYPE}) {
-      return $ENV{REX_CACHE_TYPE};
-   }
+  if(exists $ENV{REX_CACHE_TYPE}) {
+    return $ENV{REX_CACHE_TYPE};
+  }
 
-   return $cache_type || "Base";
+  return $cache_type || "Base";
 }
 
 sub set_use_cache {
-   my $class = shift;
-   $use_cache = shift;
+  my $class = shift;
+  $use_cache = shift;
 }
 
 sub get_use_cache {
-   return $use_cache;
+  return $use_cache;
 }
 
 sub get_sudo_without_locales {
-   return $sudo_without_locales;
+  return $sudo_without_locales;
 }
 
 sub get_sudo_without_sh {
-   return $sudo_without_sh;
+  return $sudo_without_sh;
 }
 
 sub set_openssh_opt {
-   my ($class, $key, $val) = @_;
-   if(! defined $val) {
-      $openssh_opt{$key} = undef;
-      delete $openssh_opt{$key};
-      return;
-   }
+  my ($class, $key, $val) = @_;
+  if(! defined $val) {
+    $openssh_opt{$key} = undef;
+    delete $openssh_opt{$key};
+    return;
+  }
 
-   $openssh_opt{$key} = $val;
+  $openssh_opt{$key} = $val;
 }
 
 sub get_openssh_opt {
-   return %openssh_opt;
+  return %openssh_opt;
 }
 
 sub set_sudo_without_locales {
-   my $class = shift;
-   $sudo_without_locales = shift;
+  my $class = shift;
+  $sudo_without_locales = shift;
 }
 
 sub set_sudo_without_sh {
-   my $class = shift;
-   $sudo_without_sh = shift;
+  my $class = shift;
+  $sudo_without_sh = shift;
 }
 
 sub set_executor_for {
-   my $class = shift;
-   my $for   = shift;
-   my $e     = shift;
+  my $class = shift;
+  my $for  = shift;
+  my $e    = shift;
 
-   $executor_for{$for} = $e;
+  $executor_for{$for} = $e;
 }
 
 sub get_executor_for {
-   my $class = shift;
-   my $e     = shift;
+  my $class = shift;
+  my $e    = shift;
 
-   return $executor_for{$e};
+  return $executor_for{$e};
 }
 
 sub set_tmp_dir {
-   $tmp_dir = shift;
+  $tmp_dir = shift;
 }
 
 sub get_tmp_dir {
-   return $tmp_dir || "/tmp";
+  return $tmp_dir || "/tmp";
 }
 
 sub set_path {
-   my $class = shift;
-   $path = shift;
+  my $class = shift;
+  $path = shift;
 }
 
 sub get_path {
-   if(!$path) {
-      return ("/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/local/bin", "/usr/local/sbin", "/usr/pkg/bin", "/usr/pkg/sbin");
-   }
-   return @{ $path };
+  if(!$path) {
+    return ("/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/local/bin", "/usr/local/sbin", "/usr/pkg/bin", "/usr/pkg/sbin");
+  }
+  return @{ $path };
 }
 
 sub set_user {
-   my $class = shift;
-   $user = shift;
+  my $class = shift;
+  $user = shift;
 }
 
 sub set_password {
-   my $class = shift;
-   $password = shift;
+  my $class = shift;
+  $password = shift;
 }
 
 sub set_port {
-   my $class = shift;
-   $port = shift;
+  my $class = shift;
+  $port = shift;
 }
 
 sub set_sudo_password {
-   my $class = shift;
-   $sudo_password = shift;
+  my $class = shift;
+  $sudo_password = shift;
 }
 
 sub set_source_global_profile {
-   my $class = shift;
-   $source_global_profile = shift;
+  my $class = shift;
+  $source_global_profile = shift;
 }
 
 sub get_source_global_profile {
-   return $source_global_profile;
+  return $source_global_profile;
 }
 
 sub set_max_connect_fails {
-   my $class = shift;
-   $max_connect_fails = shift;
+  my $class = shift;
+  $max_connect_fails = shift;
 }
 
 sub get_max_connect_fails {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{connectionattempts}) {
-      return $SSH_CONFIG_FOR{$param->{server}}->{connectionattempts};
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{connectionattempts}) {
+    return $SSH_CONFIG_FOR{$param->{server}}->{connectionattempts};
+  }
 
-   return $max_connect_fails || 3;
+  return $max_connect_fails || 3;
 }
 
 sub has_user {
-   my $class = shift;
-   return $user;
+  my $class = shift;
+  return $user;
 }
 
 sub get_user {
-   my $class = shift;
-   if($user) {
-      return $user;
-   }
+  my $class = shift;
+  if($user) {
+    return $user;
+  }
 
-   return getlogin || getpwuid($<) || "Kilroy";
+  return getlogin || getpwuid($<) || "Kilroy";
 }
 
 sub get_password {
-   my $class = shift;
-   return $password;
+  my $class = shift;
+  return $password;
 }
 
 sub get_port {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{port}) {
-      return $SSH_CONFIG_FOR{$param->{server}}->{port};
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{port}) {
+    return $SSH_CONFIG_FOR{$param->{server}}->{port};
+  }
 
-   return $port;
+  return $port;
 }
 
 sub get_sudo_password {
-   my $class = shift;
-   if($sudo_password) {
-      return $sudo_password;
-   }
-   elsif(! defined $sudo_password) {
-      return "";
-   }
-   else {
-      return $password;
-   }
+  my $class = shift;
+  if($sudo_password) {
+    return $sudo_password;
+  }
+  elsif(! defined $sudo_password) {
+    return "";
+  }
+  else {
+    return $password;
+  }
 
-   return "";
+  return "";
 }
 
 sub set_timeout {
-   my $class = shift;
-   $timeout = shift;
+  my $class = shift;
+  $timeout = shift;
 }
 
 sub get_timeout {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{connecttimeout}) {
-      return $SSH_CONFIG_FOR{$param->{server}}->{connecttimeout};
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{connecttimeout}) {
+    return $SSH_CONFIG_FOR{$param->{server}}->{connecttimeout};
+  }
 
-   return $timeout || 2;
+  return $timeout || 2;
 }
 
 sub set_password_auth {
-   my $class = shift;
-   $key_auth = 0;
-   $krb5_auth = 0;
-   $password_auth = shift || 1;
+  my $class = shift;
+  $key_auth = 0;
+  $krb5_auth = 0;
+  $password_auth = shift || 1;
 }
 
 sub set_key_auth {
-   my $class = shift;
-   $password_auth = 0;
-   $krb5_auth = 0;
-   $key_auth = shift || 1;
+  my $class = shift;
+  $password_auth = 0;
+  $krb5_auth = 0;
+  $key_auth = shift || 1;
 }
 
 sub set_krb5_auth {
-   my $class = shift;
-   $password_auth = 0;
-   $key_auth = 0;
-   $krb5_auth = shift || 1;
+  my $class = shift;
+  $password_auth = 0;
+  $key_auth = 0;
+  $krb5_auth = shift || 1;
 }
 
 sub get_password_auth {
-   return $password_auth;
+  return $password_auth;
 }
 
 sub get_key_auth {
-   return $key_auth;
+  return $key_auth;
 }
 
 sub get_krb5_auth {
-   return $krb5_auth;
+  return $krb5_auth;
 }
 
 sub set_public_key {
-   my $class = shift;
-   $public_key = shift;
+  my $class = shift;
+  $public_key = shift;
 }
 
 sub has_public_key {
-   return $public_key;
+  return $public_key;
 }
 
 sub get_public_key {
-   if($public_key) {
-      return $public_key;
-   }
+  if($public_key) {
+    return $public_key;
+  }
 
-   return _home_dir() . '/.ssh/id_rsa.pub';
+  return undef;
 }
 
 sub set_private_key {
-   my $class = shift;
-   $private_key = shift;
+  my $class = shift;
+  $private_key = shift;
 }
 
 sub has_private_key {
-   return $private_key;
+  return $private_key;
 }
 
 sub get_private_key {
-   if($private_key) {
-      return $private_key;
-   }
+  if($private_key) {
+    return $private_key;
+  }
 
-   return _home_dir() . '/.ssh/id_rsa';
+  return undef;
 }
 
 sub set_parallelism {
-   my $class = shift;
-   $parallelism = $_[0];
+  my $class = shift;
+  $parallelism = $_[0];
 }
 
 sub get_parallelism {
-   my $class = shift;
-   return $parallelism || 1;
+  my $class = shift;
+  return $parallelism || 1;
 }
 
 sub set_log_filename {
-   my $class = shift;
-   $log_filename = shift;
+  my $class = shift;
+  $log_filename = shift;
 }
 
 sub get_log_filename {
-   my $class = shift;
-   return $log_filename;
+  my $class = shift;
+  return $log_filename;
 }
 
 sub set_log_facility {
-   my $class = shift;
-   $log_facility = shift;
+  my $class = shift;
+  $log_facility = shift;
 }
 
 sub get_log_facility {
-   my $class = shift;
-   return $log_facility || "local0";
+  my $class = shift;
+  return $log_facility || "local0";
 }
 
 sub set_environment {
-   my ($class, $env) = @_;
-   $environment = $env;
+  my ($class, $env) = @_;
+  $environment = $env;
 }
 
 sub get_environment {
-   return $environment || "";
+  return $environment || "";
 }
 
 sub get_ssh_config_username {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{user}) {
-      return $SSH_CONFIG_FOR{$param->{server}}->{user};
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{user}) {
+    return $SSH_CONFIG_FOR{$param->{server}}->{user};
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_ssh_config_hostname {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{hostname}) {
-      return $SSH_CONFIG_FOR{$param->{server}}->{hostname};
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{hostname}) {
+    return $SSH_CONFIG_FOR{$param->{server}}->{hostname};
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_ssh_config_private_key {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
+
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{identityfile}) {
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{identityfile}) {
+    my $file = $SSH_CONFIG_FOR{$param->{server}}->{identityfile};
+    my $home_dir = _home_dir();
+    $file =~ s/^~/$home_dir/;
 
-      my $file = $SSH_CONFIG_FOR{$param->{server}}->{identityfile};
-      my $home_dir = _home_dir();
-      $file =~ s/^~/$home_dir/;
-      
-      return $file;
-   }
+    return $file;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_ssh_config_public_key {
-   my $class = shift;
-   my $param = { @_ };
+  my $class = shift;
+  my $param = { @_ };
 
-   if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
-         && exists $SSH_CONFIG_FOR{$param->{server}}->{identityfile}) {
-      my $file = $SSH_CONFIG_FOR{$param->{server}}->{identityfile} . ".pub";
-      my $home_dir = _home_dir();
-      $file =~ s/^~/$home_dir/;
-      return $file;
-   }
+  if(exists $param->{server} && exists $SSH_CONFIG_FOR{$param->{server}}
+      && exists $SSH_CONFIG_FOR{$param->{server}}->{identityfile}) {
+    my $file = $SSH_CONFIG_FOR{$param->{server}}->{identityfile} . ".pub";
+    my $home_dir = _home_dir();
+    $file =~ s/^~/$home_dir/;
+    return $file;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_connection_type {
-   my $class = shift;
-   return $connection_type || "SSH";
+  my $class = shift;
+  return $connection_type || "SSH";
 }
 
 sub get_ca {
-   my $class = shift;
-   return $ca_file || "";
+  my $class = shift;
+  return $ca_file || "";
 }
 
 sub get_ca_cert {
-   my $class = shift;
-   return $ca_cert || "";
+  my $class = shift;
+  return $ca_cert || "";
 }
 
 sub get_ca_key {
-   my $class = shift;
-   return $ca_key || "";
+  my $class = shift;
+  return $ca_key || "";
 }
 
 
 sub set_distributor {
-   my $class = shift;
-   $distributor = shift;
+  my $class = shift;
+  $distributor = shift;
 }
 
 sub get_distributor {
-   my $class = shift;
-   return $distributor || "Base";
+  my $class = shift;
+  return $distributor || "Base";
 }
 
 sub set_template_function {
-   my $class = shift;
-   ($template_function) = @_;
+  my $class = shift;
+  ($template_function) = @_;
 }
 
 sub get_template_function {
-   if(ref($template_function) eq "CODE") {
-      return $template_function;
-   }
+  if(ref($template_function) eq "CODE") {
+    return $template_function;
+  }
 
-   return sub {
-         my ($content, $template_vars) = @_;
-         use Rex::Template;
-         my $template = Rex::Template->new;
-         return $template->parse($content, $template_vars);
-   };
+  return sub {
+      my ($content, $template_vars) = @_;
+      use Rex::Template;
+      my $template = Rex::Template->new;
+      return $template->parse($content, $template_vars);
+  };
 }
 
 sub set_no_tty {
-   shift;
-   $no_tty = shift;
+  shift;
+  $no_tty = shift;
 }
 
 sub get_no_tty {
-   return $no_tty;
+  return $no_tty;
 }
 
 =item register_set_handler($handler_name, $code)
@@ -556,8 +556,8 @@ sub get_no_tty {
 Register a handler that gets called by I<set>.
 
  Rex::Config->register_set_handler("foo", sub {
-    my ($value) = @_;
-    print "The user set foo -> $value\n";
+   my ($value) = @_;
+   print "The user set foo -> $value\n";
  });
 
 And now you can use this handler in your I<Rexfile> like this:
@@ -566,50 +566,50 @@ And now you can use this handler in your I<Rexfile> like this:
 
 =cut
 sub register_set_handler {
-   my ($class, $handler_name, $code) = @_;
-   $SET_HANDLER->{$handler_name} = $code;
+  my ($class, $handler_name, $code) = @_;
+  $SET_HANDLER->{$handler_name} = $code;
 }
 
 sub set {
-   my ($class, $var, $data) = @_;
-
-   if(exists($SET_HANDLER->{$var})) {
-      shift; shift;
-      return &{ $SET_HANDLER->{$var} }(@_);
-   }
-
-   if(ref($data) eq "HASH") {
-      if(! ref($set_param->{$var})) {
-         $set_param->{$var} = {};
-      }
-      for my $key (keys %{$data}) {
-         $set_param->{$var}->{$key} = $data->{$key};
-      }
-   }
-   elsif(ref($data) eq "ARRAY") {
-      push(@{$set_param->{$var}}, @{$data});
-   }
-   else {
-      $set_param->{$var} = $data;
-   }
+  my ($class, $var, $data) = @_;
+
+  if(exists($SET_HANDLER->{$var})) {
+    shift; shift;
+    return &{ $SET_HANDLER->{$var} }(@_);
+  }
+
+  if(ref($data) eq "HASH") {
+    if(! ref($set_param->{$var})) {
+      $set_param->{$var} = {};
+    }
+    for my $key (keys %{$data}) {
+      $set_param->{$var}->{$key} = $data->{$key};
+    }
+  }
+  elsif(ref($data) eq "ARRAY") {
+    push(@{$set_param->{$var}}, @{$data});
+  }
+  else {
+    $set_param->{$var} = $data;
+  }
 }
 
 sub unset {
-   my ($class, $var) = @_;
-   $set_param->{$var} = undef;
-   delete $set_param->{$var};
+  my ($class, $var) = @_;
+  $set_param->{$var} = undef;
+  delete $set_param->{$var};
 }
 
 sub get {
-   my ($class, $var) = @_;
-   if(exists $set_param->{$var}) {
-      return $set_param->{$var};
-   }
+  my ($class, $var) = @_;
+  if(exists $set_param->{$var}) {
+    return $set_param->{$var};
+  }
 }
 
 sub get_all {
-   my ($class) = @_;
-   return $set_param;
+  my ($class) = @_;
+  return $set_param;
 }
 
 =item register_config_handler($topic, $code)
@@ -619,195 +619,195 @@ With this function it is possible to register own sections in the users config f
 Example:
 
  Rex::Config->register_config_handler("foo", sub {
-   my ($param) = @_;
-   print "bar is: " . $param->{bar} . "\n";
+  my ($param) = @_;
+  print "bar is: " . $param->{bar} . "\n";
  });
 
 And now the user can set this in his configuration file:
 
  base:
-    user: theuser
-    password: thepassw0rd
+   user: theuser
+   password: thepassw0rd
  foo:
-    bar: baz
+   bar: baz
 
 =cut
 sub register_config_handler {
-   my ($class, $topic, $code) = @_;
+  my ($class, $topic, $code) = @_;
 
-   if(! ref($HOME_CONFIG)) { $HOME_CONFIG = {}; }
-   $HOME_CONFIG->{$topic} = $code;
+  if(! ref($HOME_CONFIG)) { $HOME_CONFIG = {}; }
+  $HOME_CONFIG->{$topic} = $code;
 
-   if(ref($HOME_CONFIG_YAML) && exists $HOME_CONFIG_YAML->{$topic}) {
-      &$code($HOME_CONFIG_YAML->{$topic});
-   }
+  if(ref($HOME_CONFIG_YAML) && exists $HOME_CONFIG_YAML->{$topic}) {
+    &$code($HOME_CONFIG_YAML->{$topic});
+  }
 }
 
 sub read_config_file {
-   my ($config_file) = @_;
-   $config_file ||= _home_dir() . "/.rex/config.yml";
-
-   if(-f $config_file) {
-      my $yaml = eval { local(@ARGV, $/) = ($config_file); <>; };
-      eval {
-         $HOME_CONFIG_YAML = Load($yaml);
-      };
-
-      if($@) {
-         print STDERR "Error loading $config_file\n";
-         print STDERR "$@\n";
-         exit 2;
-      }
-
-      for my $key (keys %{ $HOME_CONFIG }) {
-         if(exists $HOME_CONFIG_YAML->{$key}) {
-            my $code = $HOME_CONFIG->{$key};
-            &$code($HOME_CONFIG_YAML->{$key});
-         }
+  my ($config_file) = @_;
+  $config_file ||= _home_dir() . "/.rex/config.yml";
+
+  if(-f $config_file) {
+    my $yaml = eval { local(@ARGV, $/) = ($config_file); <>; };
+    eval {
+      $HOME_CONFIG_YAML = Load($yaml);
+    };
+
+    if($@) {
+      print STDERR "Error loading $config_file\n";
+      print STDERR "$@\n";
+      exit 2;
+    }
+
+    for my $key (keys %{ $HOME_CONFIG }) {
+      if(exists $HOME_CONFIG_YAML->{$key}) {
+        my $code = $HOME_CONFIG->{$key};
+        &$code($HOME_CONFIG_YAML->{$key});
       }
-   }
+    }
+  }
 }
 
 sub read_ssh_config_file {
-   my ($config_file) = @_;
-   $config_file ||= _home_dir() . '/.ssh/config';
-   
-   if(-f $config_file) {
-      my @lines = eval { local(@ARGV) = ($config_file); <>;  };
-      %SSH_CONFIG_FOR = _parse_ssh_config(@lines);
-   }
+  my ($config_file) = @_;
+  $config_file ||= _home_dir() . '/.ssh/config';
+
+  if(-f $config_file) {
+    my @lines = eval { local(@ARGV) = ($config_file); <>;  };
+    %SSH_CONFIG_FOR = _parse_ssh_config(@lines);
+  }
 }
 
 sub _parse_ssh_config {
-   my (@lines) = @_;
-
-   my %ret = ();
-
-   my (@host, $in_host);
-   for my $line (@lines) {
-      chomp $line;
-      next if ($line =~ m/^\s*#/);
-      next if ($line =~ m/^\s*$/);
-
-      if($line =~ m/^Host(?:\s*=\s*|\s+)(.*)$/i) {
-         my $host_tmp = $1; 
-         @host = split(/\s+/, $host_tmp);
-         $in_host = 1;
-         for my $h (@host) {
-            $ret{$h} = {}; 
-         }
-         next;
-      }   
-      elsif($in_host) {
-         #my ($key, $val) = ($line =~ m/^\s*([^\s]+)\s+=?\s*(.*)$/);
-         $line =~ s/^\s*//g;
-         my ($key, $val_tmp) = split(/[\s=]/, $line, 2);
-         $val_tmp =~ s/^[\s=]+//g;
-         my $val = $val_tmp;
-
-         $val =~ s/^\s+//;
-         $val =~ s/\s+$//;
-         for my $h (@host) {
-            $ret{$h}->{lc($key)} = $val;
-         }
-      }   
-   }
-
-   return %ret;
+  my (@lines) = @_;
+
+  my %ret = ();
+
+  my (@host, $in_host);
+  for my $line (@lines) {
+    chomp $line;
+    next if ($line =~ m/^\s*#/);
+    next if ($line =~ m/^\s*$/);
+
+    if($line =~ m/^Host(?:\s*=\s*|\s+)(.*)$/i) {
+      my $host_tmp = $1;
+      @host = split(/\s+/, $host_tmp);
+      $in_host = 1;
+      for my $h (@host) {
+        $ret{$h} = {};
+      }
+      next;
+    }
+    elsif($in_host) {
+      #my ($key, $val) = ($line =~ m/^\s*([^\s]+)\s+=?\s*(.*)$/);
+      $line =~ s/^\s*//g;
+      my ($key, $val_tmp) = split(/[\s=]/, $line, 2);
+      $val_tmp =~ s/^[\s=]+//g;
+      my $val = $val_tmp;
+
+      $val =~ s/^\s+//;
+      $val =~ s/\s+$//;
+      for my $h (@host) {
+        $ret{$h}->{lc($key)} = $val;
+      }
+    }
+  }
+
+  return %ret;
 }
 
 sub set_allow_empty_groups {
-   my ($class, $set) = @_;
-   if($set) {
-      $allow_empty_groups = 1;
-   }
-   else {
-      $allow_empty_groups = 0;
-   }
+  my ($class, $set) = @_;
+  if($set) {
+    $allow_empty_groups = 1;
+  }
+  else {
+    $allow_empty_groups = 0;
+  }
 }
 
 sub get_allow_empty_groups {
-   if($allow_empty_groups) {
-      return 1;
-   }
+  if($allow_empty_groups) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub set_use_server_auth {
-   my ($class, $set) = @_;
-   if($set) {
-      $use_server_auth = 1;
-   }
-   else {
-      $use_server_auth = 0;
-   }
+  my ($class, $set) = @_;
+  if($set) {
+    $use_server_auth = 1;
+  }
+  else {
+    $use_server_auth = 0;
+  }
 }
 
 sub get_use_server_auth {
-   if($use_server_auth) {
-      return 1;
-   }
+  if($use_server_auth) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub import {
-   read_ssh_config_file();
-   read_config_file();   
+  read_ssh_config_file();
+  read_config_file();
 }
 
 no strict 'refs';
 __PACKAGE__->register_config_handler(base => sub {
-   my ($param) = @_;
+  my ($param) = @_;
 
-   for my $key (keys %{ $param }) {
+  for my $key (keys %{ $param }) {
 
-      if($key eq "keyauth") {
-         $key_auth = $param->{keyauth};
-         next;
-      }
+    if($key eq "keyauth") {
+      $key_auth = $param->{keyauth};
+      next;
+    }
 
-      if($key eq "passwordauth") {
-         $password_auth = $param->{passwordauth};
-         next;
-      }
+    if($key eq "passwordauth") {
+      $password_auth = $param->{passwordauth};
+      next;
+    }
 
-      if($key eq "passauth") {
-         $password_auth = $param->{passauth};
-         next;
-      }
+    if($key eq "passauth") {
+      $password_auth = $param->{passauth};
+      next;
+    }
 
-      $$key = $param->{$key};
-   }
+    $$key = $param->{$key};
+  }
 });
 
 my @set_handler = qw/user password private_key public_key -keyauth -passwordauth -passauth parallelism sudo_password connection ca cert key distributor template_function/;
 for my $hndl (@set_handler) {
-   __PACKAGE__->register_set_handler($hndl => sub {
-      my ($val) = @_;
-      if($hndl =~ m/^\-/) {
-         $hndl = substr($hndl, 1);
-      }
-      if($hndl eq "keyauth") { $hndl = "key_auth"; $val = 1; }
-      if($hndl eq "passwordauth" || $hndl eq "passauth") { $hndl = "password_auth"; $val = 1; }
-      if($hndl eq "connection") { $hndl = "connection_type"; }
-      if($hndl eq "ca") { $hndl = "ca_file"; }
-      if($hndl eq "cert") { $hndl = "ca_cert"; }
-      if($hndl eq "key") { $hndl = "ca_key"; }
-
-      $$hndl = $val; 
-   });
+  __PACKAGE__->register_set_handler($hndl => sub {
+    my ($val) = @_;
+    if($hndl =~ m/^\-/) {
+      $hndl = substr($hndl, 1);
+    }
+    if($hndl eq "keyauth") { $hndl = "key_auth"; $val = 1; }
+    if($hndl eq "passwordauth" || $hndl eq "passauth") { $hndl = "password_auth"; $val = 1; }
+    if($hndl eq "connection") { $hndl = "connection_type"; }
+    if($hndl eq "ca") { $hndl = "ca_file"; }
+    if($hndl eq "cert") { $hndl = "ca_cert"; }
+    if($hndl eq "key") { $hndl = "ca_key"; }
+
+    $$hndl = $val;
+  });
 }
 
 use strict;
 
 sub _home_dir {
-   if($^O =~ m/^MSWin/) {
-      return $ENV{'USERPROFILE'};
-   }
+  if($^O =~ m/^MSWin/) {
+    return $ENV{'USERPROFILE'};
+  }
 
-   return $ENV{'HOME'} || "";
+  return $ENV{'HOME'} || "";
 }
 
 =back
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Cron::Base;
 
 use strict;
@@ -19,218 +19,218 @@ use Data::Dumper;
 use Rex::Helper::Path;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub list {
-   my ($self) = @_;
-   return @{ $self->{cron} };
+  my ($self) = @_;
+  return @{ $self->{cron} };
 }
 
 sub list_jobs {
-   my ($self) = @_;
-   my @jobs = @{ $self->{cron} };
-   my @ret = map { $_ = { line => $_->{line}, %{ $_->{cron} } } } grep { $_->{type} eq "job" } @jobs;
+  my ($self) = @_;
+  my @jobs = @{ $self->{cron} };
+  my @ret = map { $_ = { line => $_->{line}, %{ $_->{cron} } } } grep { $_->{type} eq "job" } @jobs;
 }
 
 sub list_envs {
-   my ($self) = @_;
-   my @jobs = @{ $self->{cron} };
-   my @ret = grep { $_->{type} eq "env" } @jobs;
+  my ($self) = @_;
+  my @jobs = @{ $self->{cron} };
+  my @ret = grep { $_->{type} eq "env" } @jobs;
 }
 
 sub add {
-   my ($self, %config) = @_;
-
-   $config{"minute"}          = "*" unless defined $config{"minute"};
-   $config{"hour"}            = "*" unless defined $config{"hour"};
-   $config{"day_of_month"}  ||= "*",
-   $config{"month"}         ||= "*";
-   $config{"day_of_week"}     = "*" unless defined $config{"day_of_week"};
-   $config{"command"}       ||= "false",
-
-
-   my $new_cron = sprintf("%s %s %s %s %s %s", $config{"minute"},
-                                               $config{"hour"},
-                                               $config{"day_of_month"},
-                                               $config{"month"},
-                                               $config{"day_of_week"},
-                                               $config{"command"},
-   );
-
-   my $dupe = grep { $_->{line} eq $new_cron } @{ $self->{cron} };
-   if($dupe) {
-      Rex::Logger::debug("Job \"$new_cron\" already installed, skipping.");
-      return;
-   }
-
-   push(@{ $self->{cron} }, {
-      type => "job",
-      line => $new_cron,
-      cron => \%config,
-   });
+  my ($self, %config) = @_;
+
+  $config{"minute"}       = "*" unless defined $config{"minute"};
+  $config{"hour"}        = "*" unless defined $config{"hour"};
+  $config{"day_of_month"}  ||= "*",
+  $config{"month"}      ||= "*";
+  $config{"day_of_week"}    = "*" unless defined $config{"day_of_week"};
+  $config{"command"}     ||= "false",
+
+
+  my $new_cron = sprintf("%s %s %s %s %s %s", $config{"minute"},
+                                $config{"hour"},
+                                $config{"day_of_month"},
+                                $config{"month"},
+                                $config{"day_of_week"},
+                                $config{"command"},
+  );
+
+  my $dupe = grep { $_->{line} eq $new_cron } @{ $self->{cron} };
+  if($dupe) {
+    Rex::Logger::debug("Job \"$new_cron\" already installed, skipping.");
+    return;
+  }
+
+  push(@{ $self->{cron} }, {
+    type => "job",
+    line => $new_cron,
+    cron => \%config,
+  });
 }
 
 sub add_env {
-   my ($self, $name, $value) = @_;
-   unshift(@{ $self->{cron} }, {
-      type  => "env",
-      line  => "$name=\"$value\"",
-      name  => $name,
-      value => $value,
-   });
+  my ($self, $name, $value) = @_;
+  unshift(@{ $self->{cron} }, {
+    type  => "env",
+    line  => "$name=\"$value\"",
+    name  => $name,
+    value => $value,
+  });
 }
 
 sub delete_job {
-   my ($self, $num) = @_;
-   my @jobs = $self->list_jobs;
+  my ($self, $num) = @_;
+  my @jobs = $self->list_jobs;
 
-   my $i = 0;
-   my $to_delete;
-   for my $j (@{ $self->{cron} }) {
-      if($j->{line} eq $jobs[$num]->{line}) {
-         $to_delete = $i;
-         last;
-      }
+  my $i = 0;
+  my $to_delete;
+  for my $j (@{ $self->{cron} }) {
+    if($j->{line} eq $jobs[$num]->{line}) {
+      $to_delete = $i;
+      last;
+    }
 
-      $i++;
-   }
+    $i++;
+  }
 
-   unless(defined $to_delete) {
-      die("Cron Entry $num not found.");
-   }
+  unless(defined $to_delete) {
+    die("Cron Entry $num not found.");
+  }
 
-   $self->delete($to_delete);
+  $self->delete($to_delete);
 }
 
 sub delete_env {
-   my ($self, $num) = @_;
+  my ($self, $num) = @_;
 
-   my @jobs = $self->list_envs;
+  my @jobs = $self->list_envs;
 
-   my $i = 0;
-   my $to_delete;
-   for my $j (@{ $self->{cron} }) {
-      if($j->{line} eq $jobs[$num]->{line}) {
-         $to_delete = $i;
-         last;
-      }
+  my $i = 0;
+  my $to_delete;
+  for my $j (@{ $self->{cron} }) {
+    if($j->{line} eq $jobs[$num]->{line}) {
+      $to_delete = $i;
+      last;
+    }
 
-      $i++;
-   }
+    $i++;
+  }
 
-   unless(defined $to_delete) {
-      die("Cron Entry $num not found.");
-   }
+  unless(defined $to_delete) {
+    die("Cron Entry $num not found.");
+  }
 
-   $self->delete($to_delete);
+  $self->delete($to_delete);
 }
 
 sub delete {
-   my ($self, $num) = @_;
-   splice(@{ $self->{cron} }, $num, 1);
+  my ($self, $num) = @_;
+  splice(@{ $self->{cron} }, $num, 1);
 }
 
 # returns a filename where the new cron is written to
 # after that the cronfile must be activated
 sub write_cron {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $rnd_file = get_tmp_file;
+  my $rnd_file = get_tmp_file;
 
-   my @lines = map { $_ = $_->{line} } @{ $self->{cron} };
+  my @lines = map { $_ = $_->{line} } @{ $self->{cron} };
 
-   my $fh = file_write $rnd_file;
-   $fh->write(join("\n", @lines) . "\n");
-   $fh->close;
+  my $fh = file_write $rnd_file;
+  $fh->write(join("\n", @lines) . "\n");
+  $fh->close;
 
-   return $rnd_file;
+  return $rnd_file;
 }
 
 sub activate_user_cron {
-   my ($self, $file, $user) = @_;
-   i_run "crontab -u $user $file";
-   unlink $file;
+  my ($self, $file, $user) = @_;
+  i_run "crontab -u $user $file";
+  unlink $file;
 }
 
 sub read_user_cron {
-   my ($self, $user) = @_;
-   my @lines = i_run "crontab -u $user -l";
-   $self->parse_cron(@lines);
+  my ($self, $user) = @_;
+  my @lines = i_run "crontab -u $user -l";
+  $self->parse_cron(@lines);
 }
 
 sub parse_cron {
-   my ($self, @lines) = @_;
-
-   chomp @lines;
-
-   my @cron;
-
-   for my $line (@lines) {
-
-      # comment
-      if($line =~ m/^#/) {
-         push(@cron, {
-            type => "comment",
-            line => $line,
-         });
-      }
-
-      # empty line
-      elsif($line =~ m/^\s*$/) {
-         push(@cron, {
-            type => "empty",
-            line => $line,
-         });
-      }
-
-      # job
-      elsif($line =~ m/^(@|\*|[0-9])/) {
-         my ($min, $hour, $day, $month, $dow, $cmd) = split(/\s+/, $line, 6);
-         push(@cron, {
-            type => "job",
-            line => $line,
-            cron => {
-               minute       => $min,
-               hour         => $hour,
-               day_of_month => $day,
-               month        => $month,
-               day_of_week  => $dow,
-               command      => $cmd,
-            },
-         });
-      }
-
-      elsif($line =~ m/=/) {
-         my ($name, $value) = split(/=/, $line, 2);
-         $name  =~ s/^\s+//;
-         $name  =~ s/\s+$//;
-         $value =~ s/^\s+//;
-         $value =~ s/\s+$//;
-
-         push(@cron, {
-            type  => "env",
-            line  => $line,
-            name  => $name,
-            value => $value,
-         });
-      }
-
-      else {
-         Rex::Logger::debug("Error parsing cron line: $line");
-         next;
-      }
-
-   }
-
-   $self->{cron} = \@cron;
-   return @cron;
+  my ($self, @lines) = @_;
+
+  chomp @lines;
+
+  my @cron;
+
+  for my $line (@lines) {
+
+    # comment
+    if($line =~ m/^#/) {
+      push(@cron, {
+        type => "comment",
+        line => $line,
+      });
+    }
+
+    # empty line
+    elsif($line =~ m/^\s*$/) {
+      push(@cron, {
+        type => "empty",
+        line => $line,
+      });
+    }
+
+    # job
+    elsif($line =~ m/^(@|\*|[0-9])/) {
+      my ($min, $hour, $day, $month, $dow, $cmd) = split(/\s+/, $line, 6);
+      push(@cron, {
+        type => "job",
+        line => $line,
+        cron => {
+          minute     => $min,
+          hour      => $hour,
+          day_of_month => $day,
+          month      => $month,
+          day_of_week  => $dow,
+          command    => $cmd,
+        },
+      });
+    }
+
+    elsif($line =~ m/=/) {
+      my ($name, $value) = split(/=/, $line, 2);
+      $name  =~ s/^\s+//;
+      $name  =~ s/\s+$//;
+      $value =~ s/^\s+//;
+      $value =~ s/\s+$//;
+
+      push(@cron, {
+        type  => "env",
+        line  => $line,
+        name  => $name,
+        value => $value,
+      });
+    }
+
+    else {
+      Rex::Logger::debug("Error parsing cron line: $line");
+      next;
+    }
+
+  }
+
+  $self->{cron} = \@cron;
+  return @cron;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Cron::Linux;
 
 use strict;
@@ -13,13 +13,13 @@ use Rex::Cron::Base;
 use base qw(Rex::Cron::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Cron::SunOS;
 
 use strict;
@@ -17,25 +17,25 @@ use Rex::Helper::Run;
 use Rex::Commands::Fs;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub read_user_cron {
-   my ($self, $user) = @_;
-   my @lines = i_run "crontab -l $user";
-   $self->parse_cron(@lines);
+  my ($self, $user) = @_;
+  my @lines = i_run "crontab -l $user";
+  $self->parse_cron(@lines);
 }
 
 sub activate_user_cron {
-   my ($self, $file, $user) = @_;
-   i_run "crontab $file";
-   unlink $file;
+  my ($self, $file, $user) = @_;
+  i_run "crontab $file";
+  unlink $file;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Cron;
 
 use strict;
@@ -12,20 +12,20 @@ use warnings;
 use Rex::Commands::Gather;
 
 sub create {
-   my ($class) = @_;
+  my ($class) = @_;
 
-   my $type = "Linux";
-   if(operating_system_is("SunOS")) {
-      $type = "SunOS";
-   }
+  my $type = "Linux";
+  if(operating_system_is("SunOS")) {
+    $type = "SunOS";
+  }
 
-   my $klass = "Rex::Cron::$type";
-   eval "use $klass;";
-   if($@) {
-      die("Error creating cron class: $klass\n$@");
-   }
+  my $klass = "Rex::Cron::$type";
+  eval "use $klass;";
+  if($@) {
+    die("Error creating cron class: $klass\n$@");
+  }
 
-   return $klass->new;
+  return $klass->new;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Exporter;
-   
+  
 use strict;
 use warnings;
 
@@ -16,27 +16,27 @@ our @EXPORT;
 no strict 'refs';
 
 sub import {
-   my ($mod_to_register, %option) = @_;
-   my ($mod_to_register_in, $file, $line) = caller;
+  my ($mod_to_register, %option) = @_;
+  my ($mod_to_register_in, $file, $line) = caller;
 
-   if(exists $option{register_in} && $option{register_in}) {
-      $mod_to_register_in = $option{register_in};
-   }
+  if(exists $option{register_in} && $option{register_in}) {
+    $mod_to_register_in = $option{register_in};
+  }
 
-   my $no_import = "";
-   if(exists $option{"-no"} && $option{"-no"}) {
-      $no_import = "," . join(",", @{ $option{"-no"} }) . ",";
-   }
+  my $no_import = "";
+  if(exists $option{"-no"} && $option{"-no"}) {
+    $no_import = "," . join(",", @{ $option{"-no"} }) . ",";
+  }
 
-   for my $reg_func (@{ $_[0] . "::EXPORT" }) {
-      if($no_import =~ m/,$reg_func,/) {
-         next;
-      }
+  for my $reg_func (@{ $_[0] . "::EXPORT" }) {
+    if($no_import =~ m/,$reg_func,/) {
+      next;
+    }
 
-      *{ $mod_to_register_in . "::" . $reg_func } = *{ $mod_to_register . "::" . $reg_func };
-   }
+    *{ $mod_to_register_in . "::" . $reg_func } = *{ $mod_to_register . "::" . $reg_func };
+  }
 }
 
 use strict;
-   
+  
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -42,18 +42,18 @@ This is the constructor. You need to set the filehandle which the object should
 =cut
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub DESTROY {
-   my ($self) = @_;
-   $self->close if ($self->{'fh'});
+  my ($self) = @_;
+  $self->close if ($self->{'fh'});
 }
 
 =item write($buf)
@@ -65,19 +65,19 @@ Write $buf into the filehandle.
 =cut
 
 sub write {
-   
-   my ($self, @buf) = @_;
-   my $fh = $self->{fh};
-
-   if(scalar(@buf) > 1) {
-      for my $line (@buf) {
-         $fh->write($line);
-         $fh->write($/);
-      }
-   }
-   else {
-      $fh->write($buf[0]);
-   }
+  
+  my ($self, @buf) = @_;
+  my $fh = $self->{fh};
+
+  if(scalar(@buf) > 1) {
+    for my $line (@buf) {
+      $fh->write($line);
+      $fh->write($/);
+    }
+  }
+  else {
+    $fh->write($buf[0]);
+  }
 }
 
 =item seek($offset)
@@ -90,10 +90,10 @@ Set the file pointer to the 5th byte.
 
 =cut
 sub seek {
-   my ($self, $offset) = @_;
+  my ($self, $offset) = @_;
 
-   my $fh = $self->{'fh'};
-   $fh->seek($offset);
+  my $fh = $self->{'fh'};
+  $fh->seek($offset);
 }
 
 =item read($len)
@@ -105,11 +105,11 @@ Read $len bytes out of the filehandle.
 =cut
 
 sub read {
-   my ($self, $len) = @_;
-   $len = DEFAULT_READ_LEN if(!$len);
+  my ($self, $len) = @_;
+  $len = DEFAULT_READ_LEN if(!$len);
 
-   my $fh = $self->{'fh'};
-   return $fh->read($len);
+  my $fh = $self->{'fh'};
+  return $fh->read($len);
 }
 
 =item read_all
@@ -121,16 +121,16 @@ Read everything out of the filehandle.
 =cut
 
 sub read_all {
-   my ($self) = @_;
-
-   my $all = '';
-   while(my $in = $self->read()) {
-      $all .= $in;
-   }
-   if(wantarray) {
-      return split(/\n/, $all);
-   }
-   return $all;
+  my ($self) = @_;
+
+  my $all = '';
+  while(my $in = $self->read()) {
+    $all .= $in;
+  }
+  if(wantarray) {
+    return split(/\n/, $all);
+  }
+  return $all;
 }
 
 =item close
@@ -142,9 +142,9 @@ Close the file.
 =cut
 
 sub close {
-   my ($self) = @_;
-   my $fh = $self->{'fh'};
-   $fh->close;
+  my ($self) = @_;
+  my $fh = $self->{'fh'};
+  $fh->close;
 }
 
 =back
@@ -1,58 +1,58 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::File::Parser::Data;
-   
+  
 use strict;
 use warnings;
  
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub read {
-   my ($self, $file) = @_;
-   return $self->_read_file($file);
+  my ($self, $file) = @_;
+  return $self->_read_file($file);
 }
 
 sub _read_file {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $content = "";
+  my $content = "";
 
-   my $in_file = 0;
-   for my $line (@{$self->{"data"}}) {
-      chomp $line;
+  my $in_file = 0;
+  for my $line (@{$self->{"data"}}) {
+    chomp $line;
 
-      if($line eq "\@end") {
-         $in_file = 0;
-         next;
-      }
+    if($line eq "\@end") {
+      $in_file = 0;
+      next;
+    }
 
-      if($in_file) {
-         $content .= $line . $/;
-      }
+    if($in_file) {
+      $content .= $line . $/;
+    }
 
-      if($line eq "\@$file") {
-         $in_file = 1;
-         next;
-      }
-   }
+    if($line eq "\@$file") {
+      $in_file = 1;
+      next;
+    }
+  }
 
-   return $content;
+  return $content;
 }
 
 sub get {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 }
 
 1;
@@ -1,80 +1,80 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::File::Parser::Ini;
-   
+  
 use strict;
 use warnings;
 
 use Data::Dumper;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub get {
-   my ($self, $section, $key) = @_;
+  my ($self, $section, $key) = @_;
 
-   unless(exists $self->{"__data"}->{$section}) {
-      die("$section not found");
-   }
+  unless(exists $self->{"__data"}->{$section}) {
+    die("$section not found");
+  }
 
-   unless(exists $self->{"__data"}->{$section}->{$key}) {
-      die("$key not found in $section");
-   }
+  unless(exists $self->{"__data"}->{$section}->{$key}) {
+    die("$key not found in $section");
+  }
 
-   return $self->{"__data"}->{$section}->{$key};
+  return $self->{"__data"}->{$section}->{$key};
 }
 
 sub get_sections {
-   my ($self) = @_;
-   return keys %{$self->{"__data"}};
+  my ($self) = @_;
+  return keys %{$self->{"__data"}};
 }
 
 sub read {
-   my ($self) = @_;
-   $self->{"__data"} = $self->_read_file;
+  my ($self) = @_;
+  $self->{"__data"} = $self->_read_file;
 }
 
 sub _read_file {
-   my ($self) = @_;
-
-   my $data = {};
-
-   my $section;
-   open(my $fh, "<", $self->{"file"});
-   while(my $line = <$fh>) {
-      chomp $line;
-      next if($line =~ m/^\s*?;/);
-      next if($line =~ m/^\s*?$/);
-
-      if($line =~ m/^\[(.+)\]$/) {
-         $section = $1;
-         $data->{$section} = {};
-         next;
-      }
-
-      if($section) {
-         my ($key, $val) = split(/=/, $line, 2);
-         $val =~ s/^\s+|\s+$//g;
-         $key =~ s/^\s+|\s+$//g;
-
-         $data->{$section}->{$key} = $val;
-      }
-   }
-   close($fh);
-
-   return $data;
+  my ($self) = @_;
+
+  my $data = {};
+
+  my $section;
+  open(my $fh, "<", $self->{"file"});
+  while(my $line = <$fh>) {
+    chomp $line;
+    next if($line =~ m/^\s*?;/);
+    next if($line =~ m/^\s*?$/);
+
+    if($line =~ m/^\[(.+)\]$/) {
+      $section = $1;
+      $data->{$section} = {};
+      next;
+    }
+
+    if($section) {
+      my ($key, $val) = split(/=/, $line, 2);
+      $val =~ s/^\s+|\s+$//g;
+      $key =~ s/^\s+|\s+$//g;
+
+      $data->{$section}->{$key} = $val;
+    }
+  }
+  close($fh);
+
+  return $data;
 }
 
-   
+  
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Fork::Manager;
@@ -12,81 +12,81 @@ use warnings;
 use Rex::Fork::Task;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{'forks'}   = [];
-   $self->{'running'} = 0;
+  $self->{'forks'}  = [];
+  $self->{'running'} = 0;
 
-   return $self;
+  return $self;
 }
 
 sub add {
-   my ($self, $task, $start) = @_;
-   my $f = Rex::Fork::Task->new(task => $task);
+  my ($self, $task, $start) = @_;
+  my $f = Rex::Fork::Task->new(task => $task);
 
-   push(@{$self->{'forks'}}, $f);
+  push(@{$self->{'forks'}}, $f);
 
-   if($start) {
-      $f->start;
-      ++$self->{'running'};
+  if($start) {
+    $f->start;
+    ++$self->{'running'};
 
-      if($self->{'running'} >= $self->{'max'}) {
-         $self->wait_for_one;
-      }
-   }
+    if($self->{'running'} >= $self->{'max'}) {
+      $self->wait_for_one;
+    }
+  }
 }
 
 sub start {
-   my ($self) = @_;
-
-   my @threads = @{$self->{'forks'}};
-   for (my $i = 0; $i < scalar(@threads); ++$i) {
-      $threads[$i]->start;
-      ++$self->{'running'};
-      if($self->{'running'} >= $self->{'max'}) {
-         $self->wait_for_one;
-      }
-   }
-
-   $self->wait_for_all;
+  my ($self) = @_;
+
+  my @threads = @{$self->{'forks'}};
+  for (my $i = 0; $i < scalar(@threads); ++$i) {
+    $threads[$i]->start;
+    ++$self->{'running'};
+    if($self->{'running'} >= $self->{'max'}) {
+      $self->wait_for_one;
+    }
+  }
+
+  $self->wait_for_all;
 }
 
 sub wait_for_one {
-   my ($self) = @_;
-   $self->wait_for;
+  my ($self) = @_;
+  $self->wait_for;
 }
 
 sub wait_for_all {
-   my ($self) = @_;
-   $self->wait_for(1);
+  my ($self) = @_;
+  $self->wait_for(1);
 }
 
 sub wait_for {
-   my ($self, $all) = @_;
-   do {
-      for( my $i = 0; $i < scalar(@{$self->{'forks'}}); $i++) {
-         my $thr = $self->{'forks'}->[$i];
-         unless ($thr->{'running'}) {
-            next;
-         }
-
-         my $kid;
-         $kid = $thr->wait;
-
-         if($kid == -1) {
-            $thr = undef;
-            $thr->{running} = 0;
-            --$self->{'running'};
-
-            return 1 unless $all;
-         }
-         select undef, undef, undef, .1;
+  my ($self, $all) = @_;
+  do {
+    for( my $i = 0; $i < scalar(@{$self->{'forks'}}); $i++) {
+      my $thr = $self->{'forks'}->[$i];
+      unless ($thr->{'running'}) {
+        next;
+      }
+
+      my $kid;
+      $kid = $thr->wait;
+
+      if($kid == -1) {
+        $thr = undef;
+        $thr->{running} = 0;
+        --$self->{'running'};
+
+        return 1 unless $all;
       }
-   } until $self->{'running'} == 0;
+      select undef, undef, undef, .1;
+    }
+  } until $self->{'running'} == 0;
 }
 
 1;
@@ -1,15 +1,15 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Fork::Task;
 
 BEGIN {
 
-   use Rex::Shared::Var;
-   share qw(@PROCESS_LIST);
+  use Rex::Shared::Var;
+  share qw(@PROCESS_LIST);
 
 };
 
@@ -18,53 +18,53 @@ use warnings;
 use POSIX ":sys_wait_h";
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{'running'} = 0;
+  $self->{'running'} = 0;
 
-   return $self;
+  return $self;
 }
 
 
 sub start {
-   my ($self) = @_;
-   $self->{'running'} = 1;
-   if($self->{pid} = fork) { return $self->{pid}; }
-   else {
-      $self->{chld} = 1;
-      my $func = $self->{task};
-      if($Rex::WITH_EXIT_STATUS) {
-         eval {
-            &$func($self);
-            1;
-         } or do {
-            push(@PROCESS_LIST, 1);
-            $self->{'running'} = 0;
-            die($@);
-         };
+  my ($self) = @_;
+  $self->{'running'} = 1;
+  if($self->{pid} = fork) { return $self->{pid}; }
+  else {
+    $self->{chld} = 1;
+    my $func = $self->{task};
+    if($Rex::WITH_EXIT_STATUS) {
+      eval {
+        &$func($self);
+        1;
+      } or do {
+        push(@PROCESS_LIST, 1);
+        $self->{'running'} = 0;
+        die($@);
+      };
 
-         $self->{'running'} = 0;
-         push(@PROCESS_LIST, 0);
-         exit();
-      }
-      else {
-         &$func($self);
-         $self->{'running'} = 0;
-         exit();
-      }
-   }
+      $self->{'running'} = 0;
+      push(@PROCESS_LIST, 0);
+      exit();
+    }
+    else {
+      &$func($self);
+      $self->{'running'} = 0;
+      exit();
+    }
+  }
 }
 
 sub wait {
-   my ($self) = @_;
-   my $rpid = waitpid($self->{pid}, &WNOHANG);
-   if($rpid == -1) { $self->{'running'} = 0; }
+  my ($self) = @_;
+  my $rpid = waitpid($self->{pid}, &WNOHANG);
+  if($rpid == -1) { $self->{'running'} = 0; }
 
-   return $rpid;
+  return $rpid;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Group::Entry::Server;
-   
+  
 use strict;
 use warnings;
 
@@ -16,306 +16,306 @@ use Rex::Interface::Exec;
 use Data::Dumper;
 
 use overload
-   'eq' => sub { shift->is_eq(@_); },
-   'ne' => sub { shift->is_ne(@_); },
-   '""' => sub { shift->to_s(@_); };
+  'eq' => sub { shift->is_eq(@_); },
+  'ne' => sub { shift->is_ne(@_); },
+  '""' => sub { shift->to_s(@_); };
 
 use attributes;
 
 sub function {
-   my ($class, $name, $code) = @_;
+  my ($class, $name, $code) = @_;
 
-   no strict "refs";
-   *{ $class . "::" . $name } = $code;
-   use strict;
+  no strict "refs";
+  *{ $class . "::" . $name } = $code;
+  use strict;
 }
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
-
-   bless($self, $proto);
-
-   # be save check if name is already a server ref
-
-   if(ref $self->{name} eq __PACKAGE__) {
-      return $self->{name};
-   }
-
-   # rewrite auth info
-   if($self->{user}) {
-      $self->{auth}->{user} = $self->{user};
-      delete $self->{user};
-   }
-
-   if($self->{password}) {
-      $self->{auth}->{password} = $self->{password};
-      delete $self->{password};
-   }
-
-   if($self->{public_key}) {
-      $self->{auth}->{public_key} = $self->{public_key};
-      delete $self->{public_key};
-   }
-
-   if($self->{private_key}) {
-      $self->{auth}->{private_key} = $self->{private_key};
-      delete $self->{private_key};
-   }
-
-   if($self->{sudo}) {
-      $self->{auth}->{sudo} = $self->{sudo};
-      delete $self->{sudo};
-   }
-
-   if($self->{sudo_password}) {
-      $self->{auth}->{sudo_password} = $self->{sudo_password};
-      delete $self->{sudo_password};
-   }
-
-   if($self->{auth_type}) {
-      $self->{auth}->{auth_type} = $self->{auth_type};
-      delete $self->{auth_type};
-   }
-
-   return $self;
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
+
+  bless($self, $proto);
+
+  # be save check if name is already a server ref
+
+  if(ref $self->{name} eq __PACKAGE__) {
+    return $self->{name};
+  }
+
+  # rewrite auth info
+  if($self->{user}) {
+    $self->{auth}->{user} = $self->{user};
+    delete $self->{user};
+  }
+
+  if($self->{password}) {
+    $self->{auth}->{password} = $self->{password};
+    delete $self->{password};
+  }
+
+  if($self->{public_key}) {
+    $self->{auth}->{public_key} = $self->{public_key};
+    delete $self->{public_key};
+  }
+
+  if($self->{private_key}) {
+    $self->{auth}->{private_key} = $self->{private_key};
+    delete $self->{private_key};
+  }
+
+  if($self->{sudo}) {
+    $self->{auth}->{sudo} = $self->{sudo};
+    delete $self->{sudo};
+  }
+
+  if($self->{sudo_password}) {
+    $self->{auth}->{sudo_password} = $self->{sudo_password};
+    delete $self->{sudo_password};
+  }
+
+  if($self->{auth_type}) {
+    $self->{auth}->{auth_type} = $self->{auth_type};
+    delete $self->{auth_type};
+  }
+
+  return $self;
 }
 
 sub get_servers {
-   my ($self) = @_;
-   return map {
-               if(ref($_) ne "Rex::Group::Entry::Server") {
-                  $_ = Rex::Group::Entry::Server->new(name => $_, auth => $self->{auth});
-               }
-               else {
-                  $_;
-               }
-              } $self->evaluate_hostname;
+  my ($self) = @_;
+  return map {
+          if(ref($_) ne "Rex::Group::Entry::Server") {
+            $_ = Rex::Group::Entry::Server->new(name => $_, auth => $self->{auth});
+          }
+          else {
+            $_;
+          }
+          } $self->evaluate_hostname;
 }
 
 sub to_s {
-   my ($self) = @_;
-   return $self->{name};
+  my ($self) = @_;
+  return $self->{name};
 }
 
 sub is_eq {
-   my ($self, $comp) = @_;
-   if($comp eq $self->to_s) {
-      return 1;
-   }
+  my ($self, $comp) = @_;
+  if($comp eq $self->to_s) {
+    return 1;
+  }
 }
 
 sub is_ne {
-   my ($self, $comp) = @_;
-   if($comp ne $self->to_s) {
-      return 1;
-   }
+  my ($self, $comp) = @_;
+  if($comp ne $self->to_s) {
+    return 1;
+  }
 }
 
 sub has_auth {
-   my ($self) = @_;
-   return exists $self->{auth};
+  my ($self) = @_;
+  return exists $self->{auth};
 }
 
 sub set_auth {
-   my ($self, %auth) = @_;
-   $self->{auth} = \%auth;
+  my ($self, %auth) = @_;
+  $self->{auth} = \%auth;
 }
 
 sub get_auth {
-   my ($self) = @_;
-   return $self->{auth};
+  my ($self) = @_;
+  return $self->{auth};
 }
 
 sub get_user {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{auth}->{user}) {
-      return $self->{auth}->{user};
-   }
+  if(exists $self->{auth}->{user}) {
+    return $self->{auth}->{user};
+  }
 
-   if( ! Rex::Config->has_user && Rex::Config->get_ssh_config_username(server => $self->to_s) ) {
-      Rex::Logger::debug("Checking for a user in .ssh/config");
-      return Rex::Config->get_ssh_config_username(server => $self->to_s);
-   }
+  if( ! Rex::Config->has_user && Rex::Config->get_ssh_config_username(server => $self->to_s) ) {
+    Rex::Logger::debug("Checking for a user in .ssh/config");
+    return Rex::Config->get_ssh_config_username(server => $self->to_s);
+  }
 
-   return Rex::Config->get_user;
+  return Rex::Config->get_user;
 }
 
 sub get_password {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{auth}->{password}) {
-      return $self->{auth}->{password};
-   }
+  if(exists $self->{auth}->{password}) {
+    return $self->{auth}->{password};
+  }
 
-   return Rex::Config->get_password;
+  return Rex::Config->get_password;
 }
 
 sub get_public_key {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{auth}->{public_key} && -f $self->{auth}->{public_key}) {
-      return $self->{auth}->{public_key};
-   }
+  if(exists $self->{auth}->{public_key} && -f $self->{auth}->{public_key}) {
+    return $self->{auth}->{public_key};
+  }
 
-   if( ! Rex::Config->has_public_key && Rex::Config->get_ssh_config_public_key(server => $self->to_s) ) {
-      Rex::Logger::debug("Checking for a public key in .ssh/config");
-      return Rex::Config->get_ssh_config_public_key(server => $self->to_s);
-   }
+  if( ! Rex::Config->has_public_key && Rex::Config->get_ssh_config_public_key(server => $self->to_s) ) {
+    Rex::Logger::debug("Checking for a public key in .ssh/config");
+    return Rex::Config->get_ssh_config_public_key(server => $self->to_s);
+  }
 
-   return Rex::Config->get_public_key;
+  return Rex::Config->get_public_key;
 }
 
 sub get_private_key {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{auth}->{private_key} && -f $self->{auth}->{public_key}) {
-      return $self->{auth}->{private_key};
-   }
+  if(exists $self->{auth}->{private_key} && -f $self->{auth}->{public_key}) {
+    return $self->{auth}->{private_key};
+  }
 
-   if( ! Rex::Config->has_private_key && Rex::Config->get_ssh_config_private_key(server => $self->to_s) ) {
-      Rex::Logger::debug("Checking for a private key in .ssh/config");
-      return Rex::Config->get_ssh_config_private_key(server => $self->to_s);
-   }
+  if( ! Rex::Config->has_private_key && Rex::Config->get_ssh_config_private_key(server => $self->to_s) ) {
+    Rex::Logger::debug("Checking for a private key in .ssh/config");
+    return Rex::Config->get_ssh_config_private_key(server => $self->to_s);
+  }
 
-   return Rex::Config->get_private_key;
+  return Rex::Config->get_private_key;
 }
 
 sub get_auth_type {
-   my ($self) = @_;
-
-   if(exists $self->{auth}->{auth_type} && $self->{auth}->{auth_type}) {
-      return $self->{auth}->{auth_type};
-   }
-
-   if(exists $self->{auth}->{public_key} &&  -f $self->{auth}->{public_key}
-         && exists $self->{auth}->{private_key} &&  -f $self->{auth}->{private_key}) {
-      return "try";
-   }
-   elsif(exists $self->{auth}->{user} && $self->{auth}->{user}
-         && exists $self->{auth}->{password} && $self->{auth}->{password} ne "") {
-      return "try";
-   }
-   elsif(Rex::Config->get_krb5_auth) {
-      return "krb5";
-   }
-   elsif(Rex::Config->get_password_auth) {
-      return "pass";
-   }
-   elsif(Rex::Config->get_key_auth) {
-      return "key";
-   }
-
-   return "try";
+  my ($self) = @_;
+
+  if(exists $self->{auth}->{auth_type} && $self->{auth}->{auth_type}) {
+    return $self->{auth}->{auth_type};
+  }
+
+  if(exists $self->{auth}->{public_key} &&  -f $self->{auth}->{public_key}
+      && exists $self->{auth}->{private_key} &&  -f $self->{auth}->{private_key}) {
+    return "try";
+  }
+  elsif(exists $self->{auth}->{user} && $self->{auth}->{user}
+      && exists $self->{auth}->{password} && $self->{auth}->{password} ne "") {
+    return "try";
+  }
+  elsif(Rex::Config->get_krb5_auth) {
+    return "krb5";
+  }
+  elsif(Rex::Config->get_password_auth) {
+    return "pass";
+  }
+  elsif(Rex::Config->get_key_auth) {
+    return "key";
+  }
+
+  return "try";
 }
 
 sub get_sudo {
-   my ($self) = @_;
-   if(exists $self->{auth}->{sudo}) {
-      return $self->{auth}->{sudo};
-   }
+  my ($self) = @_;
+  if(exists $self->{auth}->{sudo}) {
+    return $self->{auth}->{sudo};
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_sudo_password {
-   my ($self) = @_;
-   if(exists $self->{auth}->{sudo_password}) {
-      return $self->{auth}->{sudo_password};
-   }
+  my ($self) = @_;
+  if(exists $self->{auth}->{sudo_password}) {
+    return $self->{auth}->{sudo_password};
+  }
 
-   Rex::Config->get_sudo_password;
+  Rex::Config->get_sudo_password;
 }
 
 
 
 sub merge_auth {
-   my ($self, $other_auth) = @_;
-
-   my %new_auth;
-   my @keys = qw/user password private_key public_key auth_type sudo sudo_password/;
-
-   for my $key (@keys) {
-      my $call = "get_$key";
-      if(ref($self)->can($call)) {
-         $new_auth{$key} = $self->$call();
-      }
-      else {
-         $new_auth{$key} = $other_auth->{$key};
-      }
-
-      # other_auth has presedence
-      if(exists $other_auth->{$key} && Rex::Config->get_use_server_auth() == 0) {
-         $new_auth{$key} = $other_auth->{$key};
-      }
-   }
-
-   return %new_auth;
+  my ($self, $other_auth) = @_;
+
+  my %new_auth;
+  my @keys = qw/user password private_key public_key auth_type sudo sudo_password/;
+
+  for my $key (@keys) {
+    my $call = "get_$key";
+    if(ref($self)->can($call)) {
+      $new_auth{$key} = $self->$call();
+    }
+    else {
+      $new_auth{$key} = $other_auth->{$key};
+    }
+
+    # other_auth has presedence
+    if(exists $other_auth->{$key} && Rex::Config->get_use_server_auth() == 0) {
+      $new_auth{$key} = $other_auth->{$key};
+    }
+  }
+
+  return %new_auth;
 }
 
 sub option {
-   my ($self, $option) = @_;
-   if(exists $self->{$option}) {
-      return $self->{$option};
-   }
+  my ($self, $option) = @_;
+  if(exists $self->{$option}) {
+    return $self->{$option};
+  }
 }
 
 sub gather_information {
-   my ($self) = @_;
-   my %info = Rex::Helper::System::info();
-   $self->{__hardware_info__} = \%info;
+  my ($self) = @_;
+  my %info = Rex::Helper::System::info();
+  $self->{__hardware_info__} = \%info;
 }
 
 sub AUTOLOAD {
-   use vars qw($AUTOLOAD);
-   my $self = shift;
+  use vars qw($AUTOLOAD);
+  my $self = shift;
 
-   return $self if( $AUTOLOAD =~ m/DESTROY/ );
+  return $self if( $AUTOLOAD =~ m/DESTROY/ );
 
-   my ($wanted_data) = ($AUTOLOAD =~ m/::([a-z0-9A-Z_]+)$/);
+  my ($wanted_data) = ($AUTOLOAD =~ m/::([a-z0-9A-Z_]+)$/);
 
-   if(scalar(keys %{ $self->{__hardware_info__} }) == 0) {
-      $self->gather_information;
-   }
+  if(scalar(keys %{ $self->{__hardware_info__} }) == 0) {
+    $self->gather_information;
+  }
 
-   if(exists $self->{__hardware_info__}->{$wanted_data}) {
-      return $self->{__hardware_info__}->{$wanted_data};
-   }
+  if(exists $self->{__hardware_info__}->{$wanted_data}) {
+    return $self->{__hardware_info__}->{$wanted_data};
+  }
 
-   if(exists $self->{$wanted_data}) {
-      return $self->{$wanted_data};
-   }
+  if(exists $self->{$wanted_data}) {
+    return $self->{$wanted_data};
+  }
 
-   return undef;
+  return undef;
 }
 
 sub evaluate_hostname {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @servers = Rex::Commands::evaluate_hostname($self->to_s);
-   my @multiple_me;
+  my @servers = Rex::Commands::evaluate_hostname($self->to_s);
+  my @multiple_me;
 
-   for (@servers) {
-      push @multiple_me, ref($self)->new(%{ $self });
-      $multiple_me[-1]->{name} = $_;
-   }
+  for (@servers) {
+    push @multiple_me, ref($self)->new(%{ $self });
+    $multiple_me[-1]->{name} = $_;
+  }
 
-   return @multiple_me;
+  return @multiple_me;
 }
 
 sub test_perl {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("which perl");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("which perl");
 
-   if($? != 0) {
-      return 0;
-   }
+  if($? != 0) {
+    return 0;
+  }
 
-   return 1;
+  return 1;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) xiahou feng <fanyeren@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,10 +15,10 @@ With this module you can define hostgroups out of a command.
 =head1 SYNOPSIS
 
  use Rex::Group::Lookup::Command;
-
- group "dbserver"   => lookup_command("cat ip.list | grep -v -E '^#'");
-
- rex xxxx                                          # dbserver
+ 
+ group "dbserver"  => lookup_command("cat ip.list | grep -v -E '^#'");
+ 
+ rex xxxx                            # dbserver
 
 =head1 EXPORTED FUNCTIONS
 
@@ -41,30 +41,30 @@ use vars qw(@EXPORT);
 
 
 sub lookup_command {
-   my $command = shift;
-
-   my $command_to_exec;
-   my @content;
-
-   if (defined $command && $command) {
-      $command_to_exec = $command;
-      Rex::Logger::info("command: $command");
-   }
-
-   unless (defined $command_to_exec && $command_to_exec) {
-      Rex::Logger::info("you must give a valid command.");
-      return @content;
-   }
-
-   eval {
-      open(my $command_rt, "$command_to_exec |") or die($!);
-      @content = grep { !/^\s*$|^#/ } <$command_rt>;
-      close($command_rt);
-
-      chomp @content;
-   };
-   Rex::Logger::info("you must give a valid command.") unless $#content;
-   return @content;
+  my $command = shift;
+
+  my $command_to_exec;
+  my @content;
+
+  if (defined $command && $command) {
+    $command_to_exec = $command;
+    Rex::Logger::info("command: $command");
+  }
+
+  unless (defined $command_to_exec && $command_to_exec) {
+    Rex::Logger::info("you must give a valid command.");
+    return @content;
+  }
+
+  eval {
+    open(my $command_rt, "$command_to_exec |") or die($!);
+    @content = grep { !/^\s*$|^#/ } <$command_rt>;
+    close($command_rt);
+
+    chomp @content;
+  };
+  Rex::Logger::info("you must give a valid command.") unless $#content;
+  return @content;
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -23,16 +23,16 @@ With this module you can define hostgroups out of a file.
 =over 4
 
 =cut
-   
+  
 package Rex::Group::Lookup::File;
-   
+  
 use strict;
 use warnings;
 
 require Exporter;
 use base qw(Exporter);
 use vars qw(@EXPORT);
-    
+   
 @EXPORT = qw(lookup_file);
 
 
@@ -45,15 +45,15 @@ With this function you can read hostnames from a file. Every hostname in one lin
 
 =cut
 sub lookup_file {
-   my ($file) = @_;
+  my ($file) = @_;
 
-   open(my $fh, "<", $file) or die($!);
-   my @content = grep { !/^\s*$|^#/ } <$fh>;
-   close($fh);
+  open(my $fh, "<", $file) or die($!);
+  my @content = grep { !/^\s*$|^#/ } <$fh>;
+  close($fh);
 
-   chomp @content;
+  chomp @content;
 
-   return @content;
+  return @content;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -23,9 +23,9 @@ With this module you can define hostgroups out of an ini style file.
 =over 4
 
 =cut
-   
+  
 package Rex::Group::Lookup::INI;
-   
+  
 use strict;
 use warnings;
 
@@ -36,7 +36,7 @@ use base qw(Exporter);
 use vars qw(@EXPORT);
 
 use Rex::Helper::INI;
-    
+   
 @EXPORT = qw(groups_file);
 
 
@@ -50,41 +50,41 @@ File Example:
  fe01
  fe02
  f03
-     
+    
  [backends]
  be01
  be02
-
+ 
  groups_file($file);
 
 =cut
 sub groups_file {
-   my ($file) = @_;
+  my ($file) = @_;
 
-   my $section;
-   my %hash;
+  my $section;
+  my %hash;
 
-   open (my $INI, "$file") || die "Can't open $file: $!\n";
-   my @lines = <$INI>;
-   chomp @lines;
-   close($INI);
+  open (my $INI, "$file") || die "Can't open $file: $!\n";
+  my @lines = <$INI>;
+  chomp @lines;
+  close($INI);
 
-   my $hash = Rex::Helper::INI::parse(@lines);
+  my $hash = Rex::Helper::INI::parse(@lines);
 
-   for my $k (keys %{ $hash }) {
-      my @servers;
-      for my $servername (keys %{ $hash->{$k} }) {
-         my $add = {};
-         if(exists $hash->{$k}->{$servername} && ref $hash->{$k}->{$servername} eq "HASH") {
-            $add = $hash->{$k}->{$servername};
-         }
-
-         my $obj = Rex::Group::Entry::Server->new(name => $servername, %{ $add });
-         push @servers, $obj;
+  for my $k (keys %{ $hash }) {
+    my @servers;
+    for my $servername (keys %{ $hash->{$k} }) {
+      my $add = {};
+      if(exists $hash->{$k}->{$servername} && ref $hash->{$k}->{$servername} eq "HASH") {
+        $add = $hash->{$k}->{$servername};
       }
 
-      group("$k" => @servers);
-   }
+      my $obj = Rex::Group::Entry::Server->new(name => $servername, %{ $add });
+      push @servers, $obj;
+    }
+
+    group("$k" => @servers);
+  }
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Group;
@@ -19,34 +19,34 @@ use List::MoreUtils qw(uniq);
 use Data::Dumper;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 
 sub get_servers {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @servers = map { ref($_->to_s) eq "CODE" ? &{ $_->to_s } : $_ } @{ $self->{servers} };
+  my @servers = map { ref($_->to_s) eq "CODE" ? &{ $_->to_s } : $_ } @{ $self->{servers} };
 
-   return @servers;
+  return @servers;
 }
 
 sub set_auth {
-   my ($self, %data) = @_;
-   $self->{auth} = \%data;
+  my ($self, %data) = @_;
+  $self->{auth} = \%data;
 
-   map { $_->set_auth(%{ $self->get_auth }) } $self->get_servers;
+  map { $_->set_auth(%{ $self->get_auth }) } $self->get_servers;
 }
 
 sub get_auth {
-   my ($self) = @_;
-   return $self->{auth};
+  my ($self) = @_;
+  return $self->{auth};
 }
 
 
@@ -55,58 +55,58 @@ sub get_auth {
 ################################################################################
 
 sub create_group {
-   my $class = shift;
-   my $group_name = shift;
-   my @server = uniq grep { defined } @_;
-
-   $groups{$group_name} = Rex::Group->new(servers => [ map {
-                                                              if(ref($_) ne "Rex::Group::Entry::Server") {
-                                                                 $_ = Rex::Group::Entry::Server->new(name => $_)
-                                                              }
-                                                              else {
-                                                                 $_;
-                                                              }
-                                                           } @server
-                                                     ]
-                                         );
+  my $class = shift;
+  my $group_name = shift;
+  my @server = uniq grep { defined } @_;
+
+  $groups{$group_name} = Rex::Group->new(servers => [ map {
+                                          if(ref($_) ne "Rex::Group::Entry::Server") {
+                                            $_ = Rex::Group::Entry::Server->new(name => $_)
+                                          }
+                                          else {
+                                            $_;
+                                          }
+                                        } @server
+                                    ]
+                            );
 }
 
 # returns the servers in the group
 sub get_group {
-   my $class = shift;
-   my $group_name = shift;
+  my $class = shift;
+  my $group_name = shift;
 
-   if(exists $groups{$group_name}) {
-      return $groups{$group_name}->get_servers;
-   }
+  if(exists $groups{$group_name}) {
+    return $groups{$group_name}->get_servers;
+  }
 
-   return ();
+  return ();
 }
 
 sub is_group {
-   my $class = shift;
-   my $group_name = shift;
+  my $class = shift;
+  my $group_name = shift;
 
-   if(defined $groups{$group_name}) { return 1; }
-   return 0;
+  if(defined $groups{$group_name}) { return 1; }
+  return 0;
 }
 
 sub get_groups {
-   my $class = shift;
-   my %ret = ();
-   
-   for my $key (keys %groups) {
-      $ret{$key} = [ $groups{$key}->get_servers ];
-   }
-
-   return %ret;
+  my $class = shift;
+  my %ret = ();
+  
+  for my $key (keys %groups) {
+    $ret{$key} = [ $groups{$key}->get_servers ];
+  }
+
+  return %ret;
 }
 
 sub get_group_object {
-   my $class = shift;
-   my $name = shift;
+  my $class = shift;
+  my $name = shift;
 
-   return $groups{$name};
+  return $groups{$name};
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Hardware::Host;
@@ -22,275 +22,280 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.host");
-
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
-
-   if(Rex::is_ssh || $^O !~ m/^MSWin/i) {
-
-      my $bios = Rex::Inventory::Bios::get();
-
-      my $os = get_operating_system();
-
-      my ($domain, $hostname);
-      if($os eq "Windows") {
-         my @env = i_run("env");
-         ($hostname) = grep { $_=$1 if /^COMPUTERNAME=(.*)$/ } split(/\r?\n/, @env);
-         ($domain)   = grep { $_=$1 if /^USERDOMAIN=(.*)$/ } split(/\r?\n/, @env);
-      }
-      elsif($os eq "NetBSD" || $os eq "OpenBSD" || $os eq 'FreeBSD') {
-	 ($hostname, $domain) =  split(/\./, i_run("hostname") , 2);
-      }
-      elsif($os eq "SunOS") {
-         ($hostname) = grep { $_=$1 if /^([^\.]+)$/ } i_run("hostname");
-         ($domain) = i_run("domainname");
-      }
-      elsif($os eq "OpenWrt") {
-         ($hostname) = i_run("uname -n");
-         ($domain) = i_run("cat /proc/sys/kernel/domainname");
-      }
-      else {
-         my @out = i_run("hostname -f 2>/dev/null");
-	 ($hostname, $domain) =  split(/\./, i_run("hostname -f 2>/dev/null") , 2);
-
-         if(! $hostname || $hostname eq "") {
-            Rex::Logger::debug("Error getting hostname and domainname. There is something wrong with your /etc/hosts file.");
-            $hostname = i_run("hostname");
-         }
+  my $cache          = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.host");
+
+  if ( $cache->valid($cache_key_name) ) {
+    return $cache->get($cache_key_name);
+  }
+
+  if ( Rex::is_ssh || $^O !~ m/^MSWin/i ) {
+
+    my $bios = Rex::Inventory::Bios::get();
+
+    my $os = get_operating_system();
+
+    my ( $domain, $hostname );
+    if ( $os eq "Windows" ) {
+      my @env = i_run("env");
+      ($hostname) =
+        grep { $_ = $1 if /^COMPUTERNAME=(.*)$/ } split( /\r?\n/, @env );
+      ($domain) =
+        grep { $_ = $1 if /^USERDOMAIN=(.*)$/ } split( /\r?\n/, @env );
+    }
+    elsif ( $os eq "NetBSD" || $os eq "OpenBSD" || $os eq 'FreeBSD' ) {
+      ( $hostname, $domain ) = split( /\./, i_run("hostname"), 2 );
+    }
+    elsif ( $os eq "SunOS" ) {
+      ($hostname) = grep { $_ = $1 if /^([^\.]+)$/ } i_run("hostname");
+      ($domain) = i_run("domainname");
+    }
+    elsif ( $os eq "OpenWrt" ) {
+      ($hostname) = i_run("uname -n");
+      ($domain)   = i_run("cat /proc/sys/kernel/domainname");
+    }
+    else {
+      my @out = i_run("hostname -f 2>/dev/null");
+      ( $hostname, $domain ) =
+        split( /\./, i_run("hostname -f 2>/dev/null"), 2 );
+
+      if ( !$hostname || $hostname eq "" ) {
+        Rex::Logger::debug(
+          "Error getting hostname and domainname. There is something wrong with your /etc/hosts file."
+        );
+        $hostname = i_run("hostname");
       }
+    }
+
+    my $data = {
 
-      my $data = {
-      
-         manufacturer => $bios->get_system_information()->get_manufacturer() || "",
-         hostname     => $hostname || "",
-         domain       => $domain || "",
-         operatingsystem => $os || "",
-         operating_system => $os || "",
-         operatingsystemrelease => get_operating_system_version(),
-         operating_system_release => get_operating_system_version(),
-         kernelname => [ i_run "uname -s" ]->[0],
+      manufacturer => $bios->get_system_information()->get_manufacturer() || "",
+      hostname     => $hostname                                           || "",
+      domain       => $domain                                             || "",
+      operatingsystem  => $os || "",
+      operating_system => $os || "",
+      operatingsystemrelease   => get_operating_system_version(),
+      operating_system_release => get_operating_system_version(),
+      kernelname               => [ i_run "uname -s" ]->[0],
 
-      };
+    };
 
-      $cache->set($cache_key_name, $data);
+    $cache->set( $cache_key_name, $data );
 
-      return $data;
+    return $data;
 
-   }
-   else {
-      return {
-         operatingsystem => $^O,
-      };
-   }
+  }
+  else {
+    return { operatingsystem => $^O, };
+  }
 
 }
 
 sub get_operating_system {
 
-   my $cache = Rex::get_cache();
-   if($cache->valid("hardware.host")) {
-      my $host_cache = $cache->get("hardware.host");
-      if(exists $host_cache->{operatingsystem}) {
-         return $host_cache->{operatingsystem};
-      }
-   }
-
-   # use lsb_release if available
-   my $is_lsb = can_run("lsb_release");
-
-   if($is_lsb) {
-      if(my $ret = i_run "lsb_release -s -i") {
-         if($ret eq "SUSE LINUX" || $ret eq "openSUSE project") {
-            $ret = "SuSE";
-         }
-         return $ret;
-      }
-   }
-
-   if(is_dir("c:/")) {
-      # windows
-      return "Windows";
-   }
-
-   if(is_file("/etc/debian_version")) {
-      return "Debian";
-   }
-
-   if(is_file("/etc/SuSE-release")) {
-      return "SuSE";
-   }
-
-   if(is_file("/etc/mageia-release")) {
-      return "Mageia";
-   }
-
-   if(is_file("/etc/fedora-release")) {
-      return "Fedora";
-   }
-
-   if(is_file("/etc/gentoo-release")) {
-      return "Gentoo";
-   }
-
-   if(is_file("/etc/altlinux-release")) {
-      return "ALT";
-   }
-
-   if(is_file("/etc/redhat-release")) {
-      my $fh = file_read("/etc/redhat-release");
-      my $content = $fh->read_all;
-      $fh->close;
-      chomp $content;
-
-      if($content =~ m/CentOS/) {
-         return "CentOS";
-      }
-      elsif($content =~ m/Scientific/) {
-         return "Scientific";
-      }
-      else {
-         return "Redhat";
+  my $cache = Rex::get_cache();
+  if ( $cache->valid("hardware.host") ) {
+    my $host_cache = $cache->get("hardware.host");
+    if ( exists $host_cache->{operatingsystem} ) {
+      return $host_cache->{operatingsystem};
+    }
+  }
+
+  # use lsb_release if available
+  my $is_lsb = can_run("lsb_release");
+
+  if ($is_lsb) {
+    if ( my $ret = i_run "lsb_release -s -i" ) {
+      if ( $ret eq "SUSE LINUX" || $ret eq "openSUSE project" ) {
+        $ret = "SuSE";
       }
-   }
-
-   if(is_file("/etc/openwrt_release")) {
-      return "OpenWrt";
-   }
-
-   my $os_string = i_run("uname -s");
-   return $os_string;   # return the plain os
-
+      return $ret;
+    }
+  }
+
+  if ( is_dir("c:/") ) {
+
+    # windows
+    return "Windows";
+  }
+
+  if ( is_file("/etc/debian_version") ) {
+    return "Debian";
+  }
+
+  if ( is_file("/etc/SuSE-release") ) {
+    return "SuSE";
+  }
+
+  if ( is_file("/etc/mageia-release") ) {
+    return "Mageia";
+  }
+
+  if ( is_file("/etc/fedora-release") ) {
+    return "Fedora";
+  }
+
+  if ( is_file("/etc/gentoo-release") ) {
+    return "Gentoo";
+  }
+
+  if ( is_file("/etc/altlinux-release") ) {
+    return "ALT";
+  }
+
+  if ( is_file("/etc/redhat-release") ) {
+    my $fh      = file_read("/etc/redhat-release");
+    my $content = $fh->read_all;
+    $fh->close;
+    chomp $content;
+
+    if ( $content =~ m/CentOS/ ) {
+      return "CentOS";
+    }
+    elsif ( $content =~ m/Scientific/ ) {
+      return "Scientific";
+    }
+    else {
+      return "Redhat";
+    }
+  }
+
+  if ( is_file("/etc/openwrt_release") ) {
+    return "OpenWrt";
+  }
+
+  my $os_string = i_run("uname -s");
+  return $os_string;    # return the plain os
 
 }
 
 sub get_operating_system_version {
-   
-   my $cache = Rex::get_cache();
-   if($cache->valid("hardware.host")) {
-      my $host_cache = $cache->get("hardware.host");
-      if(exists $host_cache->{operatingsystemrelease}) {
-         return $host_cache->{operatingsystemrelease};
-      }
-   }
 
-   my $op = get_operating_system();
+  my $cache = Rex::get_cache();
+  if ( $cache->valid("hardware.host") ) {
+    my $host_cache = $cache->get("hardware.host");
+    if ( exists $host_cache->{operatingsystemrelease} ) {
+      return $host_cache->{operatingsystemrelease};
+    }
+  }
 
-   my $is_lsb = can_run("lsb_release");
+  my $op = get_operating_system();
 
-   # use lsb_release if available
-   if($is_lsb) {
-      if(my $ret = i_run "lsb_release -r -s") {
-         my $os_check = i_run "lsb_release -d";
-         unless($os_check =~ m/SUSE\sLinux\sEnterprise\sServer/) {
-            return $ret;
-         }
+  my $is_lsb = can_run("lsb_release");
+
+  # use lsb_release if available
+  if ($is_lsb) {
+    if ( my $ret = i_run "lsb_release -r -s" ) {
+      my $os_check = i_run "lsb_release -d";
+      unless ( $os_check =~ m/SUSE\sLinux\sEnterprise\sServer/ ) {
+        return $ret;
       }
-   }
+    }
+  }
 
-   if($op eq "Debian") {
+  if ( $op eq "Debian" ) {
 
-      my $fh = file_read("/etc/debian_version");
-      my $content = $fh->read_all;
-      $fh->close;
+    my $fh      = file_read("/etc/debian_version");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      return $content;
+    return $content;
 
-   }
-   elsif($op eq "Ubuntu") {
-      my @l = i_run "lsb_release -r -s";
-      return $l[0];
-   }
-   elsif(lc($op) eq "redhat" 
-            or lc($op) eq "centos"
-            or lc($op) eq "scientific"
-            or lc($op) eq "fedora") {
+  }
+  elsif ( $op eq "Ubuntu" ) {
+    my @l = i_run "lsb_release -r -s";
+    return $l[0];
+  }
+  elsif ( lc($op) eq "redhat"
+    or lc($op) eq "centos"
+    or lc($op) eq "scientific"
+    or lc($op) eq "fedora" )
+  {
 
-      my $fh = file_read("/etc/redhat-release");
-      my $content = $fh->read_all;
-      $fh->close;
+    my $fh      = file_read("/etc/redhat-release");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      $content =~ m/(\d+(\.\d+)?)/;
+    $content =~ m/(\d+(\.\d+)?)/;
 
-      return $1;
+    return $1;
 
-   }
-   elsif($op eq "Mageia") {
-      my $fh = file_read("/etc/mageia-release");
-      my $content = $fh->read_all;
-      $fh->close;
+  }
+  elsif ( $op eq "Mageia" ) {
+    my $fh      = file_read("/etc/mageia-release");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      $content =~ m/(\d+)/;
+    $content =~ m/(\d+)/;
 
-      return $1;
-   }
+    return $1;
+  }
 
-   elsif($op eq "Gentoo") {
-      my $fh = file_read("/etc/gentoo-release");
-      my $content = $fh->read_all;
-      $fh->close;
+  elsif ( $op eq "Gentoo" ) {
+    my $fh      = file_read("/etc/gentoo-release");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      return [ split(/\s+/, $content) ]->[-1];
-   }
+    return [ split( /\s+/, $content ) ]->[-1];
+  }
 
-   elsif($op eq "SuSE") {
-      
-      my ($version,$release);
+  elsif ( $op eq "SuSE" ) {
 
-      my $fh = file_read("/etc/SuSE-release");
-      my $content = $fh->read_all;
-      $fh->close;
+    my ( $version, $release );
 
-      chomp $content;
+    my $fh      = file_read("/etc/SuSE-release");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      if($content =~ m/SUSE\sLinux\sEnterprise\sServer/m) {
-         ($version,$release) = $content =~ m/VERSION\s=\s(\d+)\nPATCHLEVEL\s=\s(\d+)/m;
-         $version = "$version.$release";
-      }
-      else {
-         ($version) = $content =~ m/VERSION = (\d+\.\d+)/m;
-      }
+    chomp $content;
+
+    if ( $content =~ m/SUSE\sLinux\sEnterprise\sServer/m ) {
+      ( $version, $release ) =
+        $content =~ m/VERSION\s=\s(\d+)\nPATCHLEVEL\s=\s(\d+)/m;
+      $version = "$version.$release";
+    }
+    else {
+      ($version) = $content =~ m/VERSION = (\d+\.\d+)/m;
+    }
 
-      return $version;
+    return $version;
 
-   }
-   elsif($op eq "ALT" ) {
-      my $fh = file_read("/etc/altlinux-release");
-      my $content = $fh->read_all;
-      $fh->close;
+  }
+  elsif ( $op eq "ALT" ) {
+    my $fh      = file_read("/etc/altlinux-release");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      $content =~ m/(\d+(\.\d+)*)/;
+    $content =~ m/(\d+(\.\d+)*)/;
 
-      return $1;
+    return $1;
 
-   }
-   elsif($op =~ /BSD/) {
-      my ($version) = grep { $_=$1 if /(\d+\.\d+)/ } i_run "uname -r";
-      return $version;
-   }
-   elsif($op eq "OpenWrt") {
-      my $fh = file_read("/etc/openwrt_version");
-      my $content = $fh->read_all;
-      $fh->close;
+  }
+  elsif ( $op =~ /BSD/ ) {
+    my ($version) = grep { $_ = $1 if /(\d+\.\d+)/ } i_run "uname -r";
+    return $version;
+  }
+  elsif ( $op eq "OpenWrt" ) {
+    my $fh      = file_read("/etc/openwrt_version");
+    my $content = $fh->read_all;
+    $fh->close;
 
-      chomp $content;
+    chomp $content;
 
-      return $content;
-   }
+    return $content;
+  }
 
-   return [ i_run("uname -r") ]->[0];
+  return [ i_run("uname -r") ]->[0];
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Hardware::Kernel;
@@ -16,23 +16,23 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.kernel");
+  my $cache = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.kernel");
 
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
+  if($cache->valid($cache_key_name)) {
+    return $cache->get($cache_key_name);
+  }
 
-   my $data = {
-      architecture   => i_run ("uname -m"),
-      kernel         => i_run ("uname -s"),
-      kernelrelease  => i_run ("uname -r"),
-      kernelversion  => i_run ("uname -v"),
-   };
+  my $data = {
+    architecture  => i_run ("uname -m"),
+    kernel      => i_run ("uname -s"),
+    kernelrelease  => i_run ("uname -r"),
+    kernelversion  => i_run ("uname -v"),
+  };
 
-   $cache->set($cache_key_name, $data);
+  $cache->set($cache_key_name, $data);
 
-   return $data;
+  return $data;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Hardware::Memory;
@@ -18,192 +18,192 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.memory");
-
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
-
-   my $os = Rex::Hardware::Host::get_operating_system();
-
-   my $convert = sub {
-
-      if($_[1] eq "G") {
-         $_[0] = $_[0] * 1024 * 1024 * 1024;
-      }
-      elsif($_[1] eq "M") {
-         $_[0] = $_[0] * 1024 * 1024;
-      }
-      elsif($_[1] eq "K") {
-         $_[0] = $_[0] * 1024;
-      }
-
-   };
-
-   my $data = {};
-
-   if($os eq "Windows") {
-      my $conn = Rex::get_current_connection()->{conn};
-      $data = {
-         used => $conn->post("/os/memory/used")->{used},
-         total => $conn->post("/os/memory/max")->{max},
-         free => $conn->post("/os/memory/free")->{free},
-      };
-   }
-   elsif($os eq "SunOS") {
-      my @data = i_run "echo ::memstat | mdb -k";
-
-      my ($free_cache) = grep { $_=$1 if /^Free \(cache[^\d]+\d+\s+(\d+)/ } @data;
-      my ($free_list)  = grep { $_=$1 if /^Free \(freel[^\d]+\d+\s+(\d+)/ } @data;
-      my ($page_cache) = grep { $_=$1 if /^Free \(freel[^\d]+\d+\s+(\d+)/ } @data;
-
-      my $free = $free_cache + $free_list;
-      #my ($total, $total_e) = grep { $_=$1 if /^Memory Size: (\d+) ([a-z])/i } i_run "prtconf";
-      my ($total) = grep { $_=$1 if /^Total\s+\d+\s+(\d+)/ } @data;
-
-      &$convert($free, "M");
-      &$convert($total, "M");
-      my $used = $total - $free;
-
-      $data = {
-         used => $used,
-         total => $total,
-         free => $free,
+  my $cache = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.memory");
+
+  if($cache->valid($cache_key_name)) {
+    return $cache->get($cache_key_name);
+  }
+
+  my $os = Rex::Hardware::Host::get_operating_system();
+
+  my $convert = sub {
+
+    if($_[1] eq "G") {
+      $_[0] = $_[0] * 1024 * 1024 * 1024;
+    }
+    elsif($_[1] eq "M") {
+      $_[0] = $_[0] * 1024 * 1024;
+    }
+    elsif($_[1] eq "K") {
+      $_[0] = $_[0] * 1024;
+    }
+
+  };
+
+  my $data = {};
+
+  if($os eq "Windows") {
+    my $conn = Rex::get_current_connection()->{conn};
+    $data = {
+      used => $conn->post("/os/memory/used")->{used},
+      total => $conn->post("/os/memory/max")->{max},
+      free => $conn->post("/os/memory/free")->{free},
+    };
+  }
+  elsif($os eq "SunOS") {
+    my @data = i_run "echo ::memstat | mdb -k";
+
+    my ($free_cache) = grep { $_=$1 if /^Free \(cache[^\d]+\d+\s+(\d+)/ } @data;
+    my ($free_list)  = grep { $_=$1 if /^Free \(freel[^\d]+\d+\s+(\d+)/ } @data;
+    my ($page_cache) = grep { $_=$1 if /^Free \(freel[^\d]+\d+\s+(\d+)/ } @data;
+
+    my $free = $free_cache + $free_list;
+    #my ($total, $total_e) = grep { $_=$1 if /^Memory Size: (\d+) ([a-z])/i } i_run "prtconf";
+    my ($total) = grep { $_=$1 if /^Total\s+\d+\s+(\d+)/ } @data;
+
+    &$convert($free, "M");
+    &$convert($total, "M");
+    my $used = $total - $free;
+
+    $data = {
+      used => $used,
+      total => $total,
+      free => $free,
+    };
+
+  }
+  elsif($os eq "OpenBSD") {
+    my $mem_str  = i_run "top -d1 | grep Memory:";
+    my $total_mem = sysctl("hw.physmem");
+
+    my ($phys_mem, $p_m_ent, $virt_mem, $v_m_ent, $free, $f_ent) =
+      ($mem_str =~m/(\d+)([a-z])\/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+
+    &$convert($phys_mem, $p_m_ent);
+    &$convert($virt_mem, $v_m_ent);
+    &$convert($free, $f_ent);
+
+    $data = {
+      used => $phys_mem + $virt_mem,
+      total => $total_mem,
+      free => $free,
+    };
+
+  }
+  elsif($os eq "NetBSD") {
+    my $mem_str  = i_run "top -d1 | grep Memory:";
+    my $total_mem = sysctl("hw.physmem");
+
+    my ($active, $a_ent, $wired, $w_ent, $exec, $e_ent, $file, $f_ent, $free, $fr_ent) = 
+      ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+
+    &$convert($active, $a_ent);
+    &$convert($wired, $w_ent);
+    &$convert($exec, $e_ent);
+    &$convert($file, $f_ent);
+    &$convert($free, $fr_ent);
+
+    $data = {
+      total => $total_mem,
+      used => $active + $exec + $file + $wired,
+      free => $free,
+      file => $file,
+      exec => $exec,
+      wired => $wired,
+    };
+
+  }
+  elsif($os =~ /FreeBSD/) {
+    my $mem_str  = i_run "top -d1 | grep Mem:";
+    my $total_mem = sysctl("hw.physmem");
+
+    my ($active, $a_ent, $inactive, $i_ent, $wired, $w_ent, $cache, $c_ent, $buf, $b_ent, $free, $f_ent) = 
+        ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+
+    if(! $active) {
+      ($active, $a_ent, $inactive, $i_ent, $wired, $w_ent, $buf, $b_ent, $free, $f_ent) = 
+          ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+    }
+
+    &$convert($active, $a_ent);
+    &$convert($inactive, $i_ent);
+    &$convert($wired, $w_ent)    if($wired);
+    &$convert($cache, $c_ent)    if($cache);
+    &$convert($buf, $b_ent)     if($buf);
+    &$convert($free, $f_ent);
+
+    $data = {
+      total => $total_mem,
+      used => $active + $inactive + $wired,
+      free  => $free,
+      cached => $cache,
+      buffers => $buf,
+    };
+  }
+  elsif($os eq "OpenWrt") {
+    my @data = i_run "cat /proc/meminfo";
+
+    my ($total)   = grep { $_=$1 if /^MemTotal:\s+(\d+)/ } @data;
+    my ($free)    = grep { $_=$1 if /^MemFree:\s+(\d+)/ } @data;
+    my ($shared)  = grep { $_=$1 if /^Shmem:\s+(\d+)/ } @data;
+    my ($buffers)  = grep { $_=$1 if /^Buffers:\s+(\d+)/ } @data;
+    my ($cached)  = grep { $_=$1 if /^Cached:\s+(\d+)/ } @data;
+
+    $data = {
+      total => $total,
+      used => $total - $free,
+      free => $free,
+      shared => $shared,
+      buffers => $buffers,
+      cached => $cached
+    };
+  }
+  else {
+    # default for linux
+    if(! can_run("free")) {
+       $data = {
+        total => 0,
+        used  => 0,
+        free  => 0,
+        shared => 0,
+        buffers => 0,
+        cached => 0,
       };
+    }
 
-   }
-   elsif($os eq "OpenBSD") {
-      my $mem_str  = i_run "top -d1 | grep Memory:";
-      my $total_mem = sysctl("hw.physmem");
-
-      my ($phys_mem, $p_m_ent, $virt_mem, $v_m_ent, $free, $f_ent) =
-         ($mem_str =~m/(\d+)([a-z])\/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-
-      &$convert($phys_mem, $p_m_ent);
-      &$convert($virt_mem, $v_m_ent);
-      &$convert($free, $f_ent);
+    my $free_str = [ grep { /^Mem:/ } i_run("free -m") ]->[0];
 
+    if(! $free_str) {
       $data = {
-         used => $phys_mem + $virt_mem,
-         total => $total_mem,
-         free => $free,
+        total => 0,
+        used  => 0,
+        free  => 0,
+        shared => 0,
+        buffers => 0,
+        cached => 0,
       };
+    }
 
-   }
-   elsif($os eq "NetBSD") {
-      my $mem_str  = i_run "top -d1 | grep Memory:";
-      my $total_mem = sysctl("hw.physmem");
-
-      my ($active, $a_ent, $wired, $w_ent, $exec, $e_ent, $file, $f_ent, $free, $fr_ent) = 
-         ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+    else {
 
-      &$convert($active, $a_ent);
-      &$convert($wired, $w_ent);
-      &$convert($exec, $e_ent);
-      &$convert($file, $f_ent);
-      &$convert($free, $fr_ent);
+      my ($total, $used, $free, $shared, $buffers, $cached) = ($free_str =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/);
 
-      $data = {
-         total => $total_mem,
-         used => $active + $exec + $file + $wired,
-         free => $free,
-         file => $file,
-         exec => $exec,
-         wired => $wired,
+      $data = { 
+        total => $total,
+        used  => $used,
+        free  => $free,
+        shared => $shared,
+        buffers => $buffers,
+        cached => $cached
       };
+    }
 
-   }
-   elsif($os =~ /FreeBSD/) {
-      my $mem_str  = i_run "top -d1 | grep Mem:";
-      my $total_mem = sysctl("hw.physmem");
-
-      my ($active, $a_ent, $inactive, $i_ent, $wired, $w_ent, $cache, $c_ent, $buf, $b_ent, $free, $f_ent) = 
-            ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-
-      if(! $active) {
-         ($active, $a_ent, $inactive, $i_ent, $wired, $w_ent, $buf, $b_ent, $free, $f_ent) = 
-               ($mem_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-      }
+  }
 
-      &$convert($active, $a_ent);
-      &$convert($inactive, $i_ent);
-      &$convert($wired, $w_ent)     if($wired);
-      &$convert($cache, $c_ent)     if($cache);
-      &$convert($buf, $b_ent)       if($buf);
-      &$convert($free, $f_ent);
+  $cache->set($cache_key_name, $data);
 
-      $data = {
-         total => $total_mem,
-         used => $active + $inactive + $wired,
-         free  => $free,
-         cached => $cache,
-         buffers => $buf,
-      };
-   }
-   elsif($os eq "OpenWrt") {
-      my @data = i_run "cat /proc/meminfo";
-
-      my ($total)    = grep { $_=$1 if /^MemTotal:\s+(\d+)/ } @data;
-      my ($free)     = grep { $_=$1 if /^MemFree:\s+(\d+)/ } @data;
-      my ($shared)   = grep { $_=$1 if /^Shmem:\s+(\d+)/ } @data;
-      my ($buffers)  = grep { $_=$1 if /^Buffers:\s+(\d+)/ } @data;
-      my ($cached)   = grep { $_=$1 if /^Cached:\s+(\d+)/ } @data;
-
-      $data = {
-         total => $total,
-         used => $total - $free,
-         free => $free,
-         shared => $shared,
-         buffers => $buffers,
-         cached => $cached
-      };
-   }
-   else {
-      # default for linux
-      if(! can_run("free")) {
-          $data = {
-            total => 0,
-            used  => 0,
-            free  => 0,
-            shared => 0,
-            buffers => 0,
-            cached => 0,
-         };
-      }
-
-      my $free_str = [ grep { /^Mem:/ } i_run("free -m") ]->[0];
-
-      if(! $free_str) {
-         $data = {
-            total => 0,
-            used  => 0,
-            free  => 0,
-            shared => 0,
-            buffers => 0,
-            cached => 0,
-         };
-      }
-
-      else {
-
-         my ($total, $used, $free, $shared, $buffers, $cached) = ($free_str =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/);
-
-         $data = { 
-            total => $total,
-            used  => $used,
-            free  => $free,
-            shared => $shared,
-            buffers => $buffers,
-            cached => $cached
-         };
-      }
-
-   }
-
-   $cache->set($cache_key_name, $data);
-
-   return $data;
+  return $data;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hardware::Network::FreeBSD;
-   
+  
 use strict;
 use warnings;
 
@@ -15,188 +15,188 @@ use Rex::Helper::Array;
 
 sub get_network_devices {
 
-   my @device_list = grep { $_=$1 if /^([a-z0-9]+)\:/i } i_run "ifconfig -a";
+  my @device_list = grep { $_=$1 if /^([a-z0-9]+)\:/i } i_run "ifconfig -a";
 
-   @device_list = array_uniq(@device_list);
-   return \@device_list;
+  @device_list = array_uniq(@device_list);
+  return \@device_list;
 
 }
 
 sub get_network_configuration {
-   
-   my $devices = get_network_devices();
+  
+  my $devices = get_network_devices();
 
-   my $device_info = {};
+  my $device_info = {};
 
-   for my $dev (@{$devices}) {
+  for my $dev (@{$devices}) {
 
-      my $ifconfig = i_run("ifconfig $dev");
+    my $ifconfig = i_run("ifconfig $dev");
 
-      $device_info->{$dev} = {
-         ip          => [ ( $ifconfig =~ m/inet (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
-         netmask     => $ifconfig =~ m/(?:netmask 0x|netmask )([a-f0-9]+)/
-            ? sprintf("%d.%d.%d.%d", unpack "C4", pack "H*", $1 )
-            : undef,
-         broadcast   => [ ( $ifconfig =~ m/broadcast (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
-         mac         => [ ( $ifconfig =~ m/(ether|address:|lladdr) (..?:..?:..?:..?:..?:..?)/ ) ]->[1],
-      };
+    $device_info->{$dev} = {
+      ip       => [ ( $ifconfig =~ m/inet (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
+      netmask    => $ifconfig =~ m/(?:netmask 0x|netmask )([a-f0-9]+)/
+        ? sprintf("%d.%d.%d.%d", unpack "C4", pack "H*", $1 )
+        : undef,
+      broadcast  => [ ( $ifconfig =~ m/broadcast (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
+      mac      => [ ( $ifconfig =~ m/(ether|address:|lladdr) (..?:..?:..?:..?:..?:..?)/ ) ]->[1],
+    };
 
-   }
+  }
 
-   return $device_info;
+  return $device_info;
 
 }
 
 sub route {
 
-   my @route = i_run "netstat -nr";  
-   my @ret;
-   if($? != 0) {
-      die("Error running netstat");
-   }
-
-   my ($in_v6, $in_v4);
-   for my $route_entry (@route) {
-      if($route_entry eq "Internet:") {
-         $in_v4 = 1;
-         next;
-      }
-
-      if($route_entry eq "Internet6:") {
-         $in_v6 = 1; $in_v4 = 0;
-         next;
-      }
-
-      if($route_entry =~ m/^$/) {
-         $in_v6 = 0; $in_v4 = 0;
-         next;
-      }
-
-      if($route_entry =~ m/^Destination/) {
-         next;
-      }
-
-      if($in_v4) {
-         my ($dest, $gw, $flags, $refs, $use, $netif, $expire) = split(/\s+/, $route_entry, 7);
-         push(@ret, {
-            destination => $dest,
-            gateway     => $gw,
-            flags       => $flags,
-            iface       => $netif,
-            refs        => $refs,
-            use         => $use,
-            expire      => $expire,
-         });
-
-         next;
-      }
-
-      if($in_v6) {
-         my ($dest, $gw, $flags, $netif, $expire) = split(/\s+/, $route_entry, 5);
-         push(@ret, {
-            destination => $dest,
-            gateway     => $gw,
-            flags       => $flags,
-            iface       => $netif,
-            expire      => $expire,
-         });
-      }
-
-   }
-
-   return @ret;
+  my @route = i_run "netstat -nr";  
+  my @ret;
+  if($? != 0) {
+    die("Error running netstat");
+  }
+
+  my ($in_v6, $in_v4);
+  for my $route_entry (@route) {
+    if($route_entry eq "Internet:") {
+      $in_v4 = 1;
+      next;
+    }
+
+    if($route_entry eq "Internet6:") {
+      $in_v6 = 1; $in_v4 = 0;
+      next;
+    }
+
+    if($route_entry =~ m/^$/) {
+      $in_v6 = 0; $in_v4 = 0;
+      next;
+    }
+
+    if($route_entry =~ m/^Destination/) {
+      next;
+    }
+
+    if($in_v4) {
+      my ($dest, $gw, $flags, $refs, $use, $netif, $expire) = split(/\s+/, $route_entry, 7);
+      push(@ret, {
+        destination => $dest,
+        gateway    => $gw,
+        flags     => $flags,
+        iface     => $netif,
+        refs      => $refs,
+        use      => $use,
+        expire    => $expire,
+      });
+
+      next;
+    }
+
+    if($in_v6) {
+      my ($dest, $gw, $flags, $netif, $expire) = split(/\s+/, $route_entry, 5);
+      push(@ret, {
+        destination => $dest,
+        gateway    => $gw,
+        flags     => $flags,
+        iface     => $netif,
+        expire    => $expire,
+      });
+    }
+
+  }
+
+  return @ret;
 
 }
 
 sub default_gateway {
 
-   my ($class, $new_default_gw) = @_;
-
-   if($new_default_gw) {
-      if(default_gateway()) {
-         i_run "route del default";
-         if($? != 0) {
-            die("Error running route del default");
-         }
-      }
+  my ($class, $new_default_gw) = @_;
 
-      i_run "route add default $new_default_gw";
+  if($new_default_gw) {
+    if(default_gateway()) {
+      i_run "route del default";
       if($? != 0) {
-         die("Error route add default");
+        die("Error running route del default");
       }
+    }
+
+    i_run "route add default $new_default_gw";
+    if($? != 0) {
+      die("Error route add default");
+    }
 
-   }
-   else {
-      my @route = route();
+  }
+  else {
+    my @route = route();
 
-      my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
-      return $default_route->{"gateway"} if $default_route;
-   }
+    my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
+    return $default_route->{"gateway"} if $default_route;
+  }
 }
 
 sub netstat {
 
-   my @ret;
-   my @netstat = i_run "netstat -na";
-
-   if($? != 0) {
-      die("Error running netstat");
-   }
-
-   shift @netstat;
-
-   my ($in_inet, $in_unix) = (0, 0);
-
-   for my $line (@netstat) {
-      if($line =~ m/^Proto\s*Recv/) {
-         $in_inet = 1;
-         next;
-      }
-
-      if($line =~ m/^Active UNIX/) {
-         $in_inet = 0; $in_unix = 1;
-         next;
-      }
-
-      if($line =~ m/^Address\s*Type/) {
-         next;
-      }
-
-      if($in_inet) {
-         my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state) = split(/\s+/, $line, 6);
-         if($proto eq "tcp4") { $proto = "tcp"; }
-         push(@ret, {
-            proto        => $proto,
-            recvq        => $recvq,
-            sendq        => $sendq,
-            local_addr   => $local_addr,
-            foreign_addr => $foreign_addr,
-            state        => $state,
-         });
-         next;
-      }
-
-      if($in_unix) {
-          my ($address, $type, $recvq, $sendq, $inode, $conn, $refs, $nextref, $addr) = split(/\s+/, $line, 9);
-          push(@ret, {
-            proto        => "unix",
-            address      => $address,
-            refcnt       => $refs,
-            type         => $type,
-            inode        => $inode,
-            path         => $addr,
-            recvq        => $recvq,
-            sendq        => $sendq,
-            conn         => $conn,
-            nextref      => $nextref,
-         });
-     
-         next;
-      }
-   }
-
-
-   return @ret;
+  my @ret;
+  my @netstat = i_run "netstat -na";
+
+  if($? != 0) {
+    die("Error running netstat");
+  }
+
+  shift @netstat;
+
+  my ($in_inet, $in_unix) = (0, 0);
+
+  for my $line (@netstat) {
+    if($line =~ m/^Proto\s*Recv/) {
+      $in_inet = 1;
+      next;
+    }
+
+    if($line =~ m/^Active UNIX/) {
+      $in_inet = 0; $in_unix = 1;
+      next;
+    }
+
+    if($line =~ m/^Address\s*Type/) {
+      next;
+    }
+
+    if($in_inet) {
+      my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state) = split(/\s+/, $line, 6);
+      if($proto eq "tcp4") { $proto = "tcp"; }
+      push(@ret, {
+        proto      => $proto,
+        recvq      => $recvq,
+        sendq      => $sendq,
+        local_addr  => $local_addr,
+        foreign_addr => $foreign_addr,
+        state      => $state,
+      });
+      next;
+    }
+
+    if($in_unix) {
+       my ($address, $type, $recvq, $sendq, $inode, $conn, $refs, $nextref, $addr) = split(/\s+/, $line, 9);
+       push(@ret, {
+        proto      => "unix",
+        address    => $address,
+        refcnt     => $refs,
+        type      => $type,
+        inode      => $inode,
+        path      => $addr,
+        recvq      => $recvq,
+        sendq      => $sendq,
+        conn      => $conn,
+        nextref    => $nextref,
+      });
+    
+      next;
+    }
+  }
+
+
+  return @ret;
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hardware::Network::Linux;
-   
+  
 use strict;
 use warnings;
 
@@ -17,295 +17,301 @@ use Data::Dumper;
 
 sub get_network_devices {
 
-   my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
-   my @output = i_run("$command");
+  my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
+  my @output = i_run("$command");
 
-   my $devices = ($command eq 'ip addr show') ? _parse_ip(@output) : _parse_ifconfig(@output);
-   my @device_list = keys %{ $devices };
+  my $devices = ($command eq 'ip addr show') ? _parse_ip(@output) : _parse_ifconfig(@output);
+  my @device_list = keys %{ $devices };
 
-   return \@device_list;
+  return \@device_list;
 }
 
 sub get_network_configuration {
-   
-   my $device_info = {};
+  
+  my $device_info = {};
 
-   my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
-   my @output = i_run("$command");
+  my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
+  my @output = i_run("$command");
 
-   return ($command eq 'ip addr show') ? _parse_ip(@output) : _parse_ifconfig(@output);
+  return ($command eq 'ip addr show') ? _parse_ip(@output) : _parse_ifconfig(@output);
 }
 
 sub _parse_ifconfig {
-   my (@ifconfig) = @_;
+  my (@ifconfig) = @_;
 
-   my $dev = {};
+  my $dev = {};
 
-   my $cur_dev;
-   for my $line (@ifconfig) {
-      if($line =~ m/^([a-zA-Z0-9:\._]+)/) {
-         my $new_dev = $1;
-         $new_dev = substr($new_dev, 0, -1) if($new_dev =~ m/:$/);
-
-         if($cur_dev && $cur_dev ne $new_dev) {
-            $cur_dev = $new_dev;
-         }
-
-         if(! $cur_dev) {
-            $cur_dev = $new_dev;
-         }
-        
-         $dev->{$cur_dev}->{mac} = "";
-         $dev->{$cur_dev}->{ip} = "";
-         $dev->{$cur_dev}->{netmask} = "";
-         $dev->{$cur_dev}->{broadcast} = "";
+  my $cur_dev;
+  for my $line (@ifconfig) {
+    if($line =~ m/^([a-zA-Z0-9:\._]+)/) {
+      my $new_dev = $1;
+      $new_dev = substr($new_dev, 0, -1) if($new_dev =~ m/:$/);
 
+      if($cur_dev && $cur_dev ne $new_dev) {
+        $cur_dev = $new_dev;
       }
 
-      if($line =~ m/(ether|HWaddr) (..:..:..:..:..:..)/) {
-         $dev->{$cur_dev}->{mac} = $2;
+      if(! $cur_dev) {
+        $cur_dev = $new_dev;
       }
+      
+      $dev->{$cur_dev}->{mac} = "";
+      $dev->{$cur_dev}->{ip} = "";
+      $dev->{$cur_dev}->{netmask} = "";
+      $dev->{$cur_dev}->{broadcast} = "";
 
-      if($line =~ m/inet( addr:| )?(\d+\.\d+\.\d+\.\d+)/) {
-         $dev->{$cur_dev}->{ip} = $2;
-      }
+    }
 
-      if($line =~ m/(netmask |Mask:)(\d+\.\d+\.\d+\.\d+)/) {
-         $dev->{$cur_dev}->{netmask} = $2;
-      }
+    if($line =~ m/(ether|HWaddr) (..:..:..:..:..:..)/) {
+      $dev->{$cur_dev}->{mac} = $2;
+    }
 
-      if($line =~ m/(broadcast |Bcast:)(\d+\.\d+\.\d+\.\d+)/) {
-         $dev->{$cur_dev}->{broadcast} = $2;
-      }
+    if($line =~ m/inet( addr:| )?(\d+\.\d+\.\d+\.\d+)/) {
+      $dev->{$cur_dev}->{ip} = $2;
+    }
 
-   }
+    if($line =~ m/(netmask |Mask:)(\d+\.\d+\.\d+\.\d+)/) {
+      $dev->{$cur_dev}->{netmask} = $2;
+    }
 
-   return $dev;
+    if($line =~ m/(broadcast |Bcast:)(\d+\.\d+\.\d+\.\d+)/) {
+      $dev->{$cur_dev}->{broadcast} = $2;
+    }
 
-}
+  }
 
-sub _parse_ip {
-   my (@ip_lines) = @_;
+  return $dev;
 
-   my $dev = {};
-
-   my $cur_dev;
-   for my $line (@ip_lines) {
-      if($line =~ m/^\d+:\s*([^\s]+):/) {
-         my $new_dev = $1;
+}
 
-         if($cur_dev && $cur_dev ne $new_dev) {
-            $cur_dev = $new_dev;
-         }
+sub _parse_ip {
+  my (@ip_lines) = @_;
 
-         if(! $cur_dev) {
-            $cur_dev = $new_dev;
-         }
+  my $dev = {};
 
-         $dev->{$cur_dev}->{ip} = "";
-         $dev->{$cur_dev}->{mac} = "";
-         $dev->{$cur_dev}->{netmask} = "";
-         $dev->{$cur_dev}->{broadcast} = "";
+  my $cur_dev;
+  for my $line (@ip_lines) {
+    if($line =~ m/^\d+:\s*([^\s]+):/) {
+      my $new_dev = $1;
 
-         next;
+      if($cur_dev && $cur_dev ne $new_dev) {
+        $cur_dev = $new_dev;
       }
 
-      if($line =~ m/^\s*link\/ether (..:..:..:..:..:..)/) {
-         $dev->{$cur_dev}->{mac} = $1;
+      if(! $cur_dev) {
+        $cur_dev = $new_dev;
       }
 
-      # loopback
-      if($line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) scope host lo/) {
-         $dev->{$cur_dev}->{ip} = $1;
-         $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($2);
+      $dev->{$cur_dev}->{ip} = "";
+      $dev->{$cur_dev}->{mac} = "";
+      $dev->{$cur_dev}->{netmask} = "";
+      $dev->{$cur_dev}->{broadcast} = "";
+
+      next;
+    }
+
+    if($line =~ m/^\s*link\/ether (..:..:..:..:..:..)/) {
+      $dev->{$cur_dev}->{mac} = $1;
+    }
+
+    # loopback
+    if($line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) scope host lo/) {
+      $dev->{$cur_dev}->{ip} = $1;
+      $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($2);
+    }
+
+    if($line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) brd (\d+\.\d+\.\d+\.\d+) scope ([^\s]+) (.*)$/) {
+      my $ip = $1;
+      my $cidr_prefix = $2;
+      my $broadcast = $3;
+      my $scope = $4;
+      my $dev_name = $5;
+
+      if($scope eq "global" && $dev_name ne $cur_dev) {
+        # this is an alias
+        $dev->{$dev_name}->{ip} = $ip;
+        $dev->{$dev_name}->{broadcast} = $broadcast;
+        $dev->{$dev_name}->{netmask} = _convert_cidr_prefix($cidr_prefix);
+        $dev->{$dev_name}->{mac} = $dev->{$cur_dev}->{mac};
       }
-
-      if($line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) brd (\d+\.\d+\.\d+\.\d+) scope ([^\s]+) (.*)$/) {
-         my $ip = $1;
-         my $cidr_prefix = $2;
-         my $broadcast = $3;
-         my $scope = $4;
-         my $dev_name = $5;
-
-         if($scope eq "global" && $dev_name ne $cur_dev) {
-            # this is an alias
-            $dev->{$dev_name}->{ip} = $ip;
-            $dev->{$dev_name}->{broadcast} = $broadcast;
-            $dev->{$dev_name}->{netmask} = _convert_cidr_prefix($cidr_prefix);
-            $dev->{$dev_name}->{mac} = $dev->{$cur_dev}->{mac};
-         }
-         else {
-            $dev->{$cur_dev}->{ip} = $ip;
-            $dev->{$cur_dev}->{broadcast} = $broadcast;
-            $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($cidr_prefix);
-         }
+      else {
+        $dev->{$cur_dev}->{ip} = $ip;
+        $dev->{$cur_dev}->{broadcast} = $broadcast;
+        $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($cidr_prefix);
       }
-   }
+    }
+
+    # ppp
+    if($line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+) peer (\d+\.\d+\.\d+\.\d+)\/(\d+)/) {
+      $dev->{$cur_dev}->{ip} = $1;
+      $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($3);
+    }
+  }
 
-   return $dev;
+  return $dev;
 
 }
 
 sub route {
 
-   my @ret = ();
+  my @ret = ();
 
-   my @route = i_run "netstat -nr";  
-   if($? != 0) {
-      die("Error running netstat");
-   }
+  my @route = i_run "netstat -nr";  
+  if($? != 0) {
+    die("Error running netstat");
+  }
 
-   shift @route; shift @route; # remove first 2 lines
+  shift @route; shift @route; # remove first 2 lines
 
-   for my $route_entry (@route) {
-      my ($dest, $gw, $genmask, $flags, $mss, $window, $irtt, $iface) = split(/\s+/, $route_entry, 8);
-      push(@ret, {
-         destination => $dest,
-         gateway     => $gw,
-         genmask     => $genmask,
-         flags       => $flags,
-         mss         => $mss,
-         irtt        => $irtt,
-         iface       => $iface,
-      });
-   }
+  for my $route_entry (@route) {
+    my ($dest, $gw, $genmask, $flags, $mss, $window, $irtt, $iface) = split(/\s+/, $route_entry, 8);
+    push(@ret, {
+      destination => $dest,
+      gateway    => $gw,
+      genmask    => $genmask,
+      flags     => $flags,
+      mss      => $mss,
+      irtt      => $irtt,
+      iface     => $iface,
+    });
+  }
 
-   return @ret;
+  return @ret;
 
 }
 
 sub default_gateway {
 
-   my ($class, $new_default_gw) = @_;
-
-   if($new_default_gw) {
-      if(default_gateway()) {
-         i_run "/sbin/route del default";
-         if($? != 0) {
-            die("Error running route del default");
-         }
-      }
+  my ($class, $new_default_gw) = @_;
 
-      i_run "/sbin/route add default gw $new_default_gw";
+  if($new_default_gw) {
+    if(default_gateway()) {
+      i_run "/sbin/route del default";
       if($? != 0) {
-         die("Error route add default");
+        die("Error running route del default");
       }
+    }
+
+    i_run "/sbin/route add default gw $new_default_gw";
+    if($? != 0) {
+      die("Error route add default");
+    }
 
-   }
-   else {
-      my @route = route();
+  }
+  else {
+    my @route = route();
 
-      my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
-      return $default_route->{"gateway"} if $default_route;
-   }
+    my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
+    return $default_route->{"gateway"} if $default_route;
+  }
 }
 
 sub netstat {
 
-   my @ret;
-   my @netstat = i_run "netstat -nap";
-   if($? != 0) {
-      die("Error running netstat");
-   }
-   my ($in_inet, $in_unix) = (0, 0);
-   for my $line (@netstat) {
-      if($in_inet == 1) { ++$in_inet; next; }
-      if($in_unix == 1) { ++$in_unix; next; }
-      if($line =~ m/^Active Internet/) {
-         $in_inet = 1;
-         next;
+  my @ret;
+  my @netstat = i_run "netstat -nap";
+  if($? != 0) {
+    die("Error running netstat");
+  }
+  my ($in_inet, $in_unix) = (0, 0);
+  for my $line (@netstat) {
+    if($in_inet == 1) { ++$in_inet; next; }
+    if($in_unix == 1) { ++$in_unix; next; }
+    if($line =~ m/^Active Internet/) {
+      $in_inet = 1;
+      next;
+    }
+
+    if($line =~ m/^Active UNIX/) {
+      $in_inet = 0;
+      $in_unix = 1;
+      next;
+    }
+
+    if($in_inet) {
+      my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state, $pid_cmd);
+
+      unless($line =~ m/^udp/) {
+        # no state
+        ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state, $pid_cmd) = split(/\s+/, $line, 7);
       }
-
-      if($line =~ m/^Active UNIX/) {
-         $in_inet = 0;
-         $in_unix = 1;
-         next;
+      else {
+        ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $pid_cmd) = split(/\s+/, $line, 6);
       }
 
-      if($in_inet) {
-         my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state, $pid_cmd);
-
-         unless($line =~ m/^udp/) {
-            # no state
-            ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state, $pid_cmd) = split(/\s+/, $line, 7);
-         }
-         else {
-            ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $pid_cmd) = split(/\s+/, $line, 6);
-         }
-
-         $pid_cmd ||= "";
-
-         my ($pid, $cmd) = split(/\//, $pid_cmd, 2);
-         if($pid =~ m/^-/) {
-            $pid = "";
-         }
-         $cmd   ||= "";
-         $state ||= "";
-
-         $cmd =~ s/\s+$//;
-
-         push(@ret, {
-            proto        => $proto,
-            recvq        => $recvq,
-            sendq        => $sendq,
-            local_addr   => $local_addr,
-            foreign_addr => $foreign_addr,
-            state        => $state,
-            pid          => $pid,
-            command      => $cmd,
-         });
-         next;
+      $pid_cmd ||= "";
+
+      my ($pid, $cmd) = split(/\//, $pid_cmd, 2);
+      if($pid =~ m/^-/) {
+        $pid = "";
       }
+      $cmd  ||= "";
+      $state ||= "";
 
-      if($in_unix) {
+      $cmd =~ s/\s+$//;
 
-         my ($proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path);
+      push(@ret, {
+        proto      => $proto,
+        recvq      => $recvq,
+        sendq      => $sendq,
+        local_addr  => $local_addr,
+        foreign_addr => $foreign_addr,
+        state      => $state,
+        pid       => $pid,
+        command    => $cmd,
+      });
+      next;
+    }
+
+    if($in_unix) {
+
+      my ($proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path);
 
-         if($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i) {
-            ($proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path) 
-               = ($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i);
-         }
-         else {
-            ($proto, $refcnt, $flags, $type, $state, $inode, $path) 
-               = ($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+\-\s+(.*)$/i);
+      if($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i) {
+        ($proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path) 
+          = ($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i);
+      }
+      else {
+        ($proto, $refcnt, $flags, $type, $state, $inode, $path) 
+          = ($line =~ m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+\-\s+(.*)$/i);
 
-            $pid = "";
-            $cmd = "";
-         }
+        $pid = "";
+        $cmd = "";
+      }
 
 
-         $state =~ s/^\s|\s$//g if ($state);
-         $flags =~ s/\s+$//;
-         $cmd =~ s/\s+$//;
+      $state =~ s/^\s|\s$//g if ($state);
+      $flags =~ s/\s+$//;
+      $cmd =~ s/\s+$//;
 
-         my $data = {
-            proto        => $proto,
-            refcnt       => $refcnt,
-            flags        => $flags,
-            type         => $type,
-            state        => $state,
-            inode        => $inode,
-            pid          => $pid,
-            command      => $cmd,
-            path         => $path,
-         };
+      my $data = {
+        proto      => $proto,
+        refcnt     => $refcnt,
+        flags      => $flags,
+        type      => $type,
+        state      => $state,
+        inode      => $inode,
+        pid       => $pid,
+        command    => $cmd,
+        path      => $path,
+      };
 
-         push(@ret, $data);
-      }
+      push(@ret, $data);
+    }
 
-   }
+  }
 
-   return @ret;
+  return @ret;
 
 }
 
 sub _convert_cidr_prefix {
-   my ($cidr_prefix) = @_;
-   # convert CIDR prefix to dotted decimal notation
-   my $binary_mask         = '1' x $cidr_prefix . '0' x (32 - $cidr_prefix);
-   my $dotted_decimal_mask = join '.', unpack 'C4', pack 'B32', $binary_mask;
+  my ($cidr_prefix) = @_;
+  # convert CIDR prefix to dotted decimal notation
+  my $binary_mask      = '1' x $cidr_prefix . '0' x (32 - $cidr_prefix);
+  my $dotted_decimal_mask = join '.', unpack 'C4', pack 'B32', $binary_mask;
 
-   return $dotted_decimal_mask;
+  return $dotted_decimal_mask;
 }
 
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hardware::Network::NetBSD;
-   
+  
 use strict;
 use warnings;
 
@@ -16,29 +16,29 @@ use Rex::Hardware::Network::OpenBSD;
 
 sub get_network_devices {
 
-   return Rex::Hardware::Network::OpenBSD::get_network_devices();
+  return Rex::Hardware::Network::OpenBSD::get_network_devices();
 
 }
 
 sub get_network_configuration {
 
-   return Rex::Hardware::Network::OpenBSD::get_network_configuration();
-   
+  return Rex::Hardware::Network::OpenBSD::get_network_configuration();
+  
 }
 
 
 sub route {
-   return Rex::Hardware::Network::OpenBSD->route();
+  return Rex::Hardware::Network::OpenBSD->route();
 }
 
 
 sub default_gateway {
-   shift;
-   return Rex::Hardware::Network::OpenBSD->default_gateway(@_);
+  shift;
+  return Rex::Hardware::Network::OpenBSD->default_gateway(@_);
 }
 
 sub netstat {
-   return Rex::Hardware::Network::OpenBSD->netstat();
+  return Rex::Hardware::Network::OpenBSD->netstat();
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hardware::Network::OpenBSD;
-   
+  
 use strict;
 use warnings;
 
@@ -17,177 +17,177 @@ use Rex::Hardware::Network::FreeBSD;
 
 sub get_network_devices {
 
-   return Rex::Hardware::Network::FreeBSD::get_network_devices();
+  return Rex::Hardware::Network::FreeBSD::get_network_devices();
 
 }
 
 sub get_network_configuration {
 
-   return Rex::Hardware::Network::FreeBSD::get_network_configuration();
-   
+  return Rex::Hardware::Network::FreeBSD::get_network_configuration();
+  
 }
 
 sub route {
 
-   my @route = i_run "netstat -nr";  
-   my @ret;
-   if($? != 0) {
-      die("Error running netstat");
-   }
-
-   my ($in_v6, $in_v4);
-   for my $route_entry (@route) {
-      if($route_entry eq "Internet:") {
-         $in_v4 = 1;
-         next;
-      }
-
-      if($route_entry eq "Internet6:") {
-         $in_v6 = 1; $in_v4 = 0;
-         next;
-      }
-
-      if($route_entry =~ m/^$/) {
-         $in_v6 = 0; $in_v4 = 0;
-         next;
-      }
-
-      if($route_entry =~ m/^AppleTalk/) {
-         # kein appletalk ...
-         next;
-      }
-
-      if($route_entry =~ m/^Destination/) {
-         next;
-      }
-
-      if($in_v4) {
-         my ($dest, $gw, $flags, $refs, $use, $mtu, $prio, $netif) = split(/\s+/, $route_entry, 8);
-         push(@ret, {
-            destination => $dest,
-            gateway     => $gw,
-            flags       => $flags,
-            iface       => $netif,
-            refs        => $refs,
-            mtu         => $mtu,
-            priority    => $prio,
-         });
-
-         next;
-      }
-
-      if($in_v6) {
-         my ($dest, $gw, $flags, $refs, $use, $mtu, $prio, $netif) = split(/\s+/, $route_entry, 8);
-         push(@ret, {
-            destination => $dest,
-            gateway     => $gw,
-            flags       => $flags,
-            iface       => $netif,
-            refs        => $refs,
-            mtu         => $mtu,
-            priority    => $prio,
-         });
-      }
-
-   }
-
-   return @ret;
+  my @route = i_run "netstat -nr";  
+  my @ret;
+  if($? != 0) {
+    die("Error running netstat");
+  }
+
+  my ($in_v6, $in_v4);
+  for my $route_entry (@route) {
+    if($route_entry eq "Internet:") {
+      $in_v4 = 1;
+      next;
+    }
+
+    if($route_entry eq "Internet6:") {
+      $in_v6 = 1; $in_v4 = 0;
+      next;
+    }
+
+    if($route_entry =~ m/^$/) {
+      $in_v6 = 0; $in_v4 = 0;
+      next;
+    }
+
+    if($route_entry =~ m/^AppleTalk/) {
+      # kein appletalk ...
+      next;
+    }
+
+    if($route_entry =~ m/^Destination/) {
+      next;
+    }
+
+    if($in_v4) {
+      my ($dest, $gw, $flags, $refs, $use, $mtu, $prio, $netif) = split(/\s+/, $route_entry, 8);
+      push(@ret, {
+        destination => $dest,
+        gateway    => $gw,
+        flags     => $flags,
+        iface     => $netif,
+        refs      => $refs,
+        mtu      => $mtu,
+        priority   => $prio,
+      });
+
+      next;
+    }
+
+    if($in_v6) {
+      my ($dest, $gw, $flags, $refs, $use, $mtu, $prio, $netif) = split(/\s+/, $route_entry, 8);
+      push(@ret, {
+        destination => $dest,
+        gateway    => $gw,
+        flags     => $flags,
+        iface     => $netif,
+        refs      => $refs,
+        mtu      => $mtu,
+        priority   => $prio,
+      });
+    }
+
+  }
+
+  return @ret;
 
 }
 
 sub default_gateway {
 
-   my ($class, $new_default_gw) = @_;
-
-   if($new_default_gw) {
-      if(default_gateway()) {
-         i_run "route delete default";
-         if($? != 0) {
-            die("Error running route delete default");
-         }
-      }
+  my ($class, $new_default_gw) = @_;
 
-      i_run "route add default $new_default_gw";
+  if($new_default_gw) {
+    if(default_gateway()) {
+      i_run "route delete default";
       if($? != 0) {
-         die("Error route add default");
+        die("Error running route delete default");
       }
+    }
+
+    i_run "route add default $new_default_gw";
+    if($? != 0) {
+      die("Error route add default");
+    }
 
-   }
-   else {
-      my @route = route();
+  }
+  else {
+    my @route = route();
 
-      my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
-      return $default_route->{"gateway"} if $default_route;
-   }
+    my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
+    return $default_route->{"gateway"} if $default_route;
+  }
 }
 
 sub netstat {
 
-   my @ret;
-   my @netstat = i_run "netstat -na";
-
-   if($? != 0) {
-      die("Error running netstat");
-   }
-
-   shift @netstat;
-
-   my ($in_inet, $in_unix) = (0, 0);
-
-   for my $line (@netstat) {
-      if($line =~ m/^Proto\s*Recv/) {
-         $in_inet = 1;
-         next;
-      }
-
-      if($line =~ m/^Active Internet/) {
-         next;
-      }
-
-      if($line =~ m/^Active UNIX/) {
-         $in_inet = 0; $in_unix = 1;
-         next;
-      }
-
-      if($line =~ m/^Address\s*Type/) {
-         next;
-      }
-
-      if($in_inet) {
-         my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state) = split(/\s+/, $line, 6);
-         if($proto eq "tcp4") { $proto = "tcp"; }
-         push(@ret, {
-            proto        => $proto,
-            recvq        => $recvq,
-            sendq        => $sendq,
-            local_addr   => $local_addr,
-            foreign_addr => $foreign_addr,
-            state        => $state,
-         });
-         next;
-      }
-
-      if($in_unix) {
-          my ($address, $type, $recvq, $sendq, $inode, $conn, $refs, $nextref, $addr) = split(/\s+/, $line, 9);
-          push(@ret, {
-            proto        => "unix",
-            address      => $address,
-            refcnt       => $refs,
-            type         => $type,
-            inode        => $inode,
-            path         => $addr,
-            recvq        => $recvq,
-            sendq        => $sendq,
-            conn         => $conn,
-            nextref      => $nextref,
-         });
-     
-         next;
-      }
-   }
-
-
-   return @ret;
+  my @ret;
+  my @netstat = i_run "netstat -na";
+
+  if($? != 0) {
+    die("Error running netstat");
+  }
+
+  shift @netstat;
+
+  my ($in_inet, $in_unix) = (0, 0);
+
+  for my $line (@netstat) {
+    if($line =~ m/^Proto\s*Recv/) {
+      $in_inet = 1;
+      next;
+    }
+
+    if($line =~ m/^Active Internet/) {
+      next;
+    }
+
+    if($line =~ m/^Active UNIX/) {
+      $in_inet = 0; $in_unix = 1;
+      next;
+    }
+
+    if($line =~ m/^Address\s*Type/) {
+      next;
+    }
+
+    if($in_inet) {
+      my ($proto, $recvq, $sendq, $local_addr, $foreign_addr, $state) = split(/\s+/, $line, 6);
+      if($proto eq "tcp4") { $proto = "tcp"; }
+      push(@ret, {
+        proto      => $proto,
+        recvq      => $recvq,
+        sendq      => $sendq,
+        local_addr  => $local_addr,
+        foreign_addr => $foreign_addr,
+        state      => $state,
+      });
+      next;
+    }
+
+    if($in_unix) {
+       my ($address, $type, $recvq, $sendq, $inode, $conn, $refs, $nextref, $addr) = split(/\s+/, $line, 9);
+       push(@ret, {
+        proto      => "unix",
+        address    => $address,
+        refcnt     => $refs,
+        type      => $type,
+        inode      => $inode,
+        path      => $addr,
+        recvq      => $recvq,
+        sendq      => $sendq,
+        conn      => $conn,
+        nextref    => $nextref,
+      });
+    
+      next;
+    }
+  }
+
+
+  return @ret;
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hardware::Network::Solaris;
-   
+  
 use strict;
 use warnings;
 
@@ -16,254 +16,254 @@ use Rex::Helper::Array;
 
 sub get_network_devices {
 
-   my @device_list = grep { $_=$1 if /^([a-z0-9]+)\:/i } i_run "ifconfig -a";
+  my @device_list = grep { $_=$1 if /^([a-z0-9]+)\:/i } i_run "ifconfig -a";
 
-   @device_list = array_uniq(@device_list);
-   return \@device_list;
+  @device_list = array_uniq(@device_list);
+  return \@device_list;
 
 }
 
 sub get_network_configuration {
-   
-   my $devices = get_network_devices();
+  
+  my $devices = get_network_devices();
 
-   my $device_info = {};
+  my $device_info = {};
 
-   for my $dev (@{$devices}) {
+  for my $dev (@{$devices}) {
 
-      my $ifconfig = i_run("ifconfig $dev");
+    my $ifconfig = i_run("ifconfig $dev");
 
-      $device_info->{$dev} = {
-         ip          => [ ( $ifconfig =~ m/inet (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
-         netmask     => [ ( $ifconfig =~ m/(netmask 0x|netmask )([a-f0-9]+)/ ) ]->[1],
-         broadcast   => [ ( $ifconfig =~ m/broadcast (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
-         mac         => [ ( $ifconfig =~ m/(ether|address:|lladdr) (..?:..?:..?:..?:..?:..?)/ ) ]->[1],
-      };
+    $device_info->{$dev} = {
+      ip       => [ ( $ifconfig =~ m/inet (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
+      netmask    => [ ( $ifconfig =~ m/(netmask 0x|netmask )([a-f0-9]+)/ ) ]->[1],
+      broadcast  => [ ( $ifconfig =~ m/broadcast (\d+\.\d+\.\d+\.\d+)/ ) ]->[0],
+      mac      => [ ( $ifconfig =~ m/(ether|address:|lladdr) (..?:..?:..?:..?:..?:..?)/ ) ]->[1],
+    };
 
-   }
+  }
 
-   return $device_info;
+  return $device_info;
 
 }
 
 sub route {
 
-   my @ret = ();
+  my @ret = ();
 
-   my @route = i_run "netstat -nr";  
-   if($? != 0) {
-      die("Error running netstat");
-   }
+  my @route = i_run "netstat -nr";  
+  if($? != 0) {
+    die("Error running netstat");
+  }
 
-   shift @route; shift @route; # remove first 2 lines
-   shift @route; shift @route; # remove first 2 lines
+  shift @route; shift @route; # remove first 2 lines
+  shift @route; shift @route; # remove first 2 lines
 
-   for my $route_entry (@route) {
+  for my $route_entry (@route) {
 
-      if(
-         $route_entry =~ m/^$/
-         || $route_entry =~ m/^Routing Table:/
-         || $route_entry =~ m/^\s+Destination/
-         || $route_entry =~ m/^---------/
-      ) {
-         next;
-      }
+    if(
+      $route_entry =~ m/^$/
+      || $route_entry =~ m/^Routing Table:/
+      || $route_entry =~ m/^\s+Destination/
+      || $route_entry =~ m/^---------/
+    ) {
+      next;
+    }
 
-      my ($dest, $gw, $flags, $ref, $use, $iface) = split(/\s+/, $route_entry, 6);
-      push(@ret, {
-         destination => $dest,
-         gateway     => $gw,
-         flags       => $flags,
-         ref         => $ref,
-         use         => $use,
-         iface       => $iface,
-      });
-   }
+    my ($dest, $gw, $flags, $ref, $use, $iface) = split(/\s+/, $route_entry, 6);
+    push(@ret, {
+      destination => $dest,
+      gateway    => $gw,
+      flags     => $flags,
+      ref      => $ref,
+      use      => $use,
+      iface     => $iface,
+    });
+  }
 
-   return @ret;
+  return @ret;
 
 }
 
 sub default_gateway {
 
-   my ($class, $new_default_gw) = @_;
-
-   if($new_default_gw) {
-      if(default_gateway()) {
-         i_run "route delete default " . default_gateway();
-         if($? != 0) {
-            die("Error running route del default");
-         }
-      }
+  my ($class, $new_default_gw) = @_;
 
-      i_run "route add default $new_default_gw";
+  if($new_default_gw) {
+    if(default_gateway()) {
+      i_run "route delete default " . default_gateway();
       if($? != 0) {
-         die("Error route add default");
+        die("Error running route del default");
       }
+    }
 
-   }
-   else {
-      my @route = route();
+    i_run "route add default $new_default_gw";
+    if($? != 0) {
+      die("Error route add default");
+    }
 
-      my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
-      return $default_route->{"gateway"} if $default_route;
-   }
+  }
+  else {
+    my @route = route();
+
+    my ($default_route) = grep { $_->{"flags"} =~ m/UG/ && ( $_->{"destination"} eq "0.0.0.0" || $_->{"destination"} eq "default" ) } @route;
+    return $default_route->{"gateway"} if $default_route;
+  }
 }
 
 sub netstat {
 
-   my @ret;
-   my @netstat = i_run "netstat -na -f inet -f inet6";
-   if($? != 0) {
-      die("Error running netstat");
-   }
-
-
-   my ($proto, $udp_v4, $udp_v6, $tcp_v4, $tcp_v6, $sctp);
-   for my $line (@netstat) {
-
-      if(
-         $line =~ m/^$/
-         || $line =~ m/^\s+Local/
-         || $line =~ m/^--------/
-      ) {
-         next;
-      }
-
-      if($line =~ m/^UDP: IPv4/) {
-         $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
-         $udp_v4 = 1;
-         $proto = "udp";
-         next;
-      }
-
-      if($line =~ m/^UDP: IPv6/) {
-         $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
-         $udp_v6 = 1;
-         $proto = "udp6";
-         next;
-      }
-
-      if($line =~ m/^TCP: IPv4/) {
-         $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
-         $tcp_v4 = 1;
-         $proto = "tcp";
-         next;
-      }
-
-      if($line =~ m/^TCP: IPv6/) {
-         $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
-         $tcp_v6 = 1;
-         $proto = "tcp6";
-         next;
-      }
-
-      if($line =~ m/^SCTP:/) {
-         $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
-         $sctp = 1;
-         $proto = "sctp";
-         next;
-      }
-
-      $line =~ s/^\s+//;
-
-      if($udp_v4) {
-         $line = " $line";
-         my ($local_addr, $remote_addr, $state) = ($line =~ m/\s+?([^\s]+)\s+([^\s]+)?\s+([^\s]+)/);
-         push(@ret, {
-            proto => $proto,
-            local_addr => $local_addr,
-            foreign_addr => $remote_addr,
-            state => $state,
-         });
-         next;
-      }
+  my @ret;
+  my @netstat = i_run "netstat -na -f inet -f inet6";
+  if($? != 0) {
+    die("Error running netstat");
+  }
+
+
+  my ($proto, $udp_v4, $udp_v6, $tcp_v4, $tcp_v6, $sctp);
+  for my $line (@netstat) {
+
+    if(
+      $line =~ m/^$/
+      || $line =~ m/^\s+Local/
+      || $line =~ m/^--------/
+    ) {
+      next;
+    }
+
+    if($line =~ m/^UDP: IPv4/) {
+      $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
+      $udp_v4 = 1;
+      $proto = "udp";
+      next;
+    }
+
+    if($line =~ m/^UDP: IPv6/) {
+      $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
+      $udp_v6 = 1;
+      $proto = "udp6";
+      next;
+    }
+
+    if($line =~ m/^TCP: IPv4/) {
+      $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
+      $tcp_v4 = 1;
+      $proto = "tcp";
+      next;
+    }
+
+    if($line =~ m/^TCP: IPv6/) {
+      $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
+      $tcp_v6 = 1;
+      $proto = "tcp6";
+      next;
+    }
+
+    if($line =~ m/^SCTP:/) {
+      $udp_v4 = 0; $udp_v6 = 0; $tcp_v4 = 0; $tcp_v6 = 0; $sctp = 0;
+      $sctp = 1;
+      $proto = "sctp";
+      next;
+    }
+
+    $line =~ s/^\s+//;
+
+    if($udp_v4) {
+      $line = " $line";
+      my ($local_addr, $remote_addr, $state) = ($line =~ m/\s+?([^\s]+)\s+([^\s]+)?\s+([^\s]+)/);
+      push(@ret, {
+        proto => $proto,
+        local_addr => $local_addr,
+        foreign_addr => $remote_addr,
+        state => $state,
+      });
+      next;
+    }
 
-      if($udp_v6) {
-         $line = " $line";
-         my ($local_addr, $remote_addr, $state, $if) = ($line =~ m/\s+?([^\s]+)\s+([^\s]+)?\s+([^\s]+)\s+([^\s]+)/);
-         push(@ret, {
-            proto => $proto,
-            local_addr => $local_addr,
-            foreign_addr => $remote_addr,
-            state => $state,
-            if => $if,
-         });
-         next;
-      }
+    if($udp_v6) {
+      $line = " $line";
+      my ($local_addr, $remote_addr, $state, $if) = ($line =~ m/\s+?([^\s]+)\s+([^\s]+)?\s+([^\s]+)\s+([^\s]+)/);
+      push(@ret, {
+        proto => $proto,
+        local_addr => $local_addr,
+        foreign_addr => $remote_addr,
+        state => $state,
+        if => $if,
+      });
+      next;
+    }
 
-      if($tcp_v4) {
-         my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $state) = split(/\s+/, $line, 7);
-         push(@ret, {
-            proto => $proto,
-            local_addr => $local_addr,
-            foreign_addr => $remote_addr,
-            swind => $swind,
-            sendq => $sendq,
-            rwind => $rwind,
-            recvq => $recvq,
-            state => $state,
-         });
-         next;
-      }
+    if($tcp_v4) {
+      my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $state) = split(/\s+/, $line, 7);
+      push(@ret, {
+        proto => $proto,
+        local_addr => $local_addr,
+        foreign_addr => $remote_addr,
+        swind => $swind,
+        sendq => $sendq,
+        rwind => $rwind,
+        recvq => $recvq,
+        state => $state,
+      });
+      next;
+    }
 
-      if($tcp_v6) {
-         my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $state, $if) = split(/\s+/, $line, 8);
-         push(@ret, {
-            proto => $proto,
-            local_addr => $local_addr,
-            foreign_addr => $remote_addr,
-            swind => $swind,
-            sendq => $sendq,
-            rwind => $rwind,
-            recvq => $recvq,
-            state => $state,
-            if => $if,
-         });
-         next;
-      }
+    if($tcp_v6) {
+      my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $state, $if) = split(/\s+/, $line, 8);
+      push(@ret, {
+        proto => $proto,
+        local_addr => $local_addr,
+        foreign_addr => $remote_addr,
+        swind => $swind,
+        sendq => $sendq,
+        rwind => $rwind,
+        recvq => $recvq,
+        state => $state,
+        if => $if,
+      });
+      next;
+    }
 
-      if($sctp) {
-         my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $strs, $state) = split(/\s+/, $line, 8);
-         push(@ret, {
-            proto => $proto,
-            local_addr => $local_addr,
-            foreign_addr => $remote_addr,
-            swind => $swind,
-            sendq => $sendq,
-            rwind => $rwind,
-            recvq => $recvq,
-            state => $state,
-            strsio => $strs,
-         });
-         next;
-      }
+    if($sctp) {
+      my ($local_addr, $remote_addr, $swind, $sendq, $rwind, $recvq, $strs, $state) = split(/\s+/, $line, 8);
+      push(@ret, {
+        proto => $proto,
+        local_addr => $local_addr,
+        foreign_addr => $remote_addr,
+        swind => $swind,
+        sendq => $sendq,
+        rwind => $rwind,
+        recvq => $recvq,
+        state => $state,
+        strsio => $strs,
+      });
+      next;
+    }
 
 
 
-   }
+  }
 
 
-   @netstat = i_run "netstat -na -f unix";
-   shift @netstat; shift @netstat; shift @netstat;
+  @netstat = i_run "netstat -na -f unix";
+  shift @netstat; shift @netstat; shift @netstat;
 
-   for my $line (@netstat) {
-      my ($address, $type, $vnode, $conn, $local_addr, $remote_addr) = split(/\s+/, $line, 7);
+  for my $line (@netstat) {
+    my ($address, $type, $vnode, $conn, $local_addr, $remote_addr) = split(/\s+/, $line, 7);
 
-      my $data = {
-         proto        => "unix",
-         address      => $address,
-         type         => $type,
-         nvnode       => $vnode,
-         conn         => $conn,
-         path         => $local_addr,
-      };
+    my $data = {
+      proto      => "unix",
+      address    => $address,
+      type      => $type,
+      nvnode     => $vnode,
+      conn      => $conn,
+      path      => $local_addr,
+    };
 
-      push(@ret, $data);
+    push(@ret, $data);
 
-   }
+  }
 
-   return @ret;
+  return @ret;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Hardware::Network;
@@ -18,59 +18,59 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.network");
+  my $cache = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.network");
 
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
+  if($cache->valid($cache_key_name)) {
+    return $cache->get($cache_key_name);
+  }
 
-   my $hw_class = _get_class();
+  my $hw_class = _get_class();
 
-   unless($hw_class) {
-      return {};
-   }
+  unless($hw_class) {
+    return {};
+  }
 
-   my $data = {
+  my $data = {
  
-      networkdevices => $hw_class->get_network_devices(),
-      networkconfiguration => $hw_class->get_network_configuration(),
+    networkdevices => $hw_class->get_network_devices(),
+    networkconfiguration => $hw_class->get_network_configuration(),
 
-   };
+  };
 
-   $cache->set($cache_key_name, $data);
+  $cache->set($cache_key_name, $data);
 
-   return $data;
+  return $data;
 
 }
 
 sub route {
-   return _get_class()->route();
+  return _get_class()->route();
 }
 
 sub default_gateway {
-   return _get_class()->default_gateway(@_);
+  return _get_class()->default_gateway(@_);
 }
 
 sub netstat {
-   return _get_class()->netstat();
+  return _get_class()->netstat();
 }
 
 sub _get_class {
-   my $os_type = Rex::Commands::Gather::get_operating_system();
+  my $os_type = Rex::Commands::Gather::get_operating_system();
 
-   $os_type = "Linux"   if Rex::Commands::Gather::is_linux();
-   $os_type = "Solaris" if Rex::Commands::Gather::is_solaris();
+  $os_type = "Linux"  if Rex::Commands::Gather::is_linux();
+  $os_type = "Solaris" if Rex::Commands::Gather::is_solaris();
 
-   my $hw_class = "Rex::Hardware::Network::$os_type";
-   eval "use $hw_class;";
+  my $hw_class = "Rex::Hardware::Network::$os_type";
+  eval "use $hw_class;";
 
-   if($@) {
-      Rex::Logger::debug("No network information on $os_type");
-      return;
-   }
+  if($@) {
+    Rex::Logger::debug("No network information on $os_type");
+    return;
+  }
 
-   return $hw_class;
+  return $hw_class;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Hardware::Swap;
@@ -17,149 +17,149 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.swap");
-
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
-
-   my $os = Rex::Hardware::Host::get_operating_system();
-
-   my $convert = sub {
-
-      if($_[1] eq "G") {
-         $_[0] = $_[0] * 1024 * 1024 * 1024;
-      }
-      elsif($_[1] eq "M") {
-         $_[0] = $_[0] * 1024 * 1024;
-      }
-      elsif($_[1] eq "K") {
-         $_[0] = $_[0] * 1024;
-      }
-
-   };
-
-
-   my $data = {};
-
-   if($os eq "Windows") {
-      my $conn = Rex::get_current_connection()->{conn};
-      $data = {
-         used => $conn->post("/os/swap/used")->{used},
-         total => $conn->post("/os/swap/max")->{max},
-         free => $conn->post("/os/swap/free")->{free},
+  my $cache = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.swap");
+
+  if($cache->valid($cache_key_name)) {
+    return $cache->get($cache_key_name);
+  }
+
+  my $os = Rex::Hardware::Host::get_operating_system();
+
+  my $convert = sub {
+
+    if($_[1] eq "G") {
+      $_[0] = $_[0] * 1024 * 1024 * 1024;
+    }
+    elsif($_[1] eq "M") {
+      $_[0] = $_[0] * 1024 * 1024;
+    }
+    elsif($_[1] eq "K") {
+      $_[0] = $_[0] * 1024;
+    }
+
+  };
+
+
+  my $data = {};
+
+  if($os eq "Windows") {
+    my $conn = Rex::get_current_connection()->{conn};
+    $data = {
+      used => $conn->post("/os/swap/used")->{used},
+      total => $conn->post("/os/swap/max")->{max},
+      free => $conn->post("/os/swap/free")->{free},
+    };
+  }
+  elsif($os eq "SunOS") {
+    my ($swap_str) = i_run("swap -s");
+
+    my ($used, $u_ent, $avail, $a_ent) = ($swap_str =~ m/(\d+)([a-z]) used, (\d+)([a-z]) avail/);
+
+    &$convert($used, uc($u_ent));
+    &$convert($avail, uc($a_ent));
+
+    $data = {
+      total => $used + $avail,
+      used => $used,
+      free => $avail,
+    };
+  }
+  elsif($os eq "OpenBSD") {
+    my $swap_str = i_run "top -d1 | grep Swap:";
+
+    my ($used, $u_ent, $total, $t_ent) = ($swap_str =~ m/Swap: (\d+)([a-z])\/(\d+)([a-z])/i);
+
+    &$convert($used, $u_ent);
+    &$convert($total, $t_ent);
+
+    $data = {
+      total => $total,
+      used  => $used,
+      free  => $total - $used,
+    };
+  }
+  elsif($os eq "NetBSD") {
+    my $swap_str = i_run "top -d1 | grep Swap:";
+
+    my ($total, $t_ent, $free, $f_ent) = 
+        ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+
+    &$convert($total, $t_ent);
+    &$convert($free, $f_ent);
+
+    $data = {
+      total => $total,
+      used => $total-$free,
+      free => $free,
+    };
+
+  }
+  elsif($os =~ /FreeBSD/) {
+    my $swap_str = i_run "top -d1 | grep Swap:";
+
+    my ($total, $t_ent, $used, $u_ent, $free, $f_ent) = 
+        ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+
+    if(! $total) {
+      ($total, $t_ent, $free, $f_ent) = 
+        ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
+    }
+
+    &$convert($total, $t_ent);
+    &$convert($used, $u_ent)    if($used);
+    &$convert($free, $f_ent);
+
+    if(! $used) {
+      $used = $total - $free;
+    }
+
+    $data = {
+      total => $total,
+      used => $used,
+      free => $free,
+    };
+  }
+  else {
+    # linux as default
+    if(! can_run("free")) {
+       $data = {
+        total => 0,
+        used  => 0,
+        free  => 0,
+        shared => 0,
+        buffers => 0,
+        cached => 0,
       };
-   }
-   elsif($os eq "SunOS") {
-      my ($swap_str) = i_run("swap -s");
-
-      my ($used, $u_ent, $avail, $a_ent) = ($swap_str =~ m/(\d+)([a-z]) used, (\d+)([a-z]) avail/);
-
-      &$convert($used, uc($u_ent));
-      &$convert($avail, uc($a_ent));
+    }
 
+    my $free_str = [ grep { /^Swap:/ } i_run("free -m") ]->[0];
+    if(! $free_str) {
       $data = {
-         total => $used + $avail,
-         used => $used,
-         free => $avail,
+        total => 0,
+        used  => 0,
+        free  => 0,
       };
-   }
-   elsif($os eq "OpenBSD") {
-      my $swap_str = i_run "top -d1 | grep Swap:";
+    }
 
-      my ($used, $u_ent, $total, $t_ent) = ($swap_str =~ m/Swap: (\d+)([a-z])\/(\d+)([a-z])/i);
+    else {
 
-      &$convert($used, $u_ent);
-      &$convert($total, $t_ent);
+      $free_str =~ s/\r//g;
+      my ($total, $used, $free) = ($free_str =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/);
 
-      $data = {
-         total => $total,
-         used  => $used,
-         free  => $total - $used,
-      };
-   }
-   elsif($os eq "NetBSD") {
-      my $swap_str = i_run "top -d1 | grep Swap:";
-
-      my ($total, $t_ent, $free, $f_ent) = 
-            ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-
-      &$convert($total, $t_ent);
-      &$convert($free, $f_ent);
-
-      $data = {
-         total => $total,
-         used => $total-$free,
-         free => $free,
+      $data = { 
+        total => $total,
+        used  => $used,
+        free  => $free,
       };
 
-   }
-   elsif($os =~ /FreeBSD/) {
-      my $swap_str = i_run "top -d1 | grep Swap:";
-
-      my ($total, $t_ent, $used, $u_ent, $free, $f_ent) = 
-            ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-
-      if(! $total) {
-         ($total, $t_ent, $free, $f_ent) = 
-            ($swap_str =~ m/(\d+)([a-z])[^\d]+(\d+)([a-z])/i);
-      }
+    }
 
-      &$convert($total, $t_ent);
-      &$convert($used, $u_ent)     if($used);
-      &$convert($free, $f_ent);
+  }
 
-      if(! $used) {
-         $used = $total - $free;
-      }
+  $cache->set($cache_key_name, $data);
 
-      $data = {
-         total => $total,
-         used => $used,
-         free => $free,
-      };
-   }
-   else {
-      # linux as default
-      if(! can_run("free")) {
-          $data = {
-            total => 0,
-            used  => 0,
-            free  => 0,
-            shared => 0,
-            buffers => 0,
-            cached => 0,
-         };
-      }
-
-      my $free_str = [ grep { /^Swap:/ } i_run("free -m") ]->[0];
-      if(! $free_str) {
-         $data = {
-            total => 0,
-            used  => 0,
-            free  => 0,
-         };
-      }
-
-      else {
-
-         $free_str =~ s/\r//g;
-         my ($total, $used, $free) = ($free_str =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/);
-
-         $data = { 
-            total => $total,
-            used  => $used,
-            free  => $free,
-         };
-
-      }
-
-   }
-
-   $cache->set($cache_key_name, $data);
-
-   return $data;
+  return $data;
 }
 
 
@@ -16,123 +16,123 @@ require Rex::Hardware;
 
 sub get {
 
-   my $cache = Rex::get_cache();
-   my $cache_key_name = $cache->gen_key_name("hardware.virt_info");
+  my $cache = Rex::get_cache();
+  my $cache_key_name = $cache->gen_key_name("hardware.virt_info");
 
-   if($cache->valid($cache_key_name)) {
-      return $cache->get($cache_key_name);
-   }
+  if($cache->valid($cache_key_name)) {
+    return $cache->get($cache_key_name);
+  }
 
-   if(Rex::is_ssh || $^O !~ m/^MSWin/i) {
+  if(Rex::is_ssh || $^O !~ m/^MSWin/i) {
 
-      my ($product_name,$bios_vendor,$sys_vendor,$self_status,$cpuinfo,$modules) = ('','','','','','');
+    my ($product_name,$bios_vendor,$sys_vendor,$self_status,$cpuinfo,$modules) = ('','','','','','');
 
-      $product_name = i_run "cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null";
-      $bios_vendor  = i_run "cat /sys/devices/virtual/dmi/id/bios_vendor 2>/dev/null";
-      $sys_vendor   = i_run "cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null";
+    $product_name = i_run "cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null";
+    $bios_vendor  = i_run "cat /sys/devices/virtual/dmi/id/bios_vendor 2>/dev/null";
+    $sys_vendor  = i_run "cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null";
 
-      $self_status  = i_run "cat /proc/self/status 2>/dev/null";
-      $cpuinfo      = i_run "cat /proc/cpuinfo 2>/dev/null";
-      $modules      = i_run "cat /proc/modules 2>/dev/null";
+    $self_status  = i_run "cat /proc/self/status 2>/dev/null";
+    $cpuinfo    = i_run "cat /proc/cpuinfo 2>/dev/null";
+    $modules    = i_run "cat /proc/modules 2>/dev/null";
 
-      my ($virtualization_type, $virtualization_role) = ('','');
+    my ($virtualization_type, $virtualization_role) = ('','');
 
-      if (is_dir("/proc/xen")) {
-         $virtualization_type = "xen";
-         $virtualization_role = "guest";
+    if (is_dir("/proc/xen")) {
+      $virtualization_type = "xen";
+      $virtualization_role = "guest";
 
-         my $string = i_run "cat /proc/xen/capabilities 2>/dev/null";
-         if ($string =~ /control_d/){
-            $virtualization_role = "host";
-         }
+      my $string = i_run "cat /proc/xen/capabilities 2>/dev/null";
+      if ($string =~ /control_d/){
+        $virtualization_role = "host";
       }
+    }
 
-      elsif (is_dir("/proc/vz")) {
-         $virtualization_type = "openvz";
-         $virtualization_role = "guest";
+    elsif (is_dir("/proc/vz")) {
+      $virtualization_type = "openvz";
+      $virtualization_role = "guest";
 
-         if (is_dir("/proc/bc")) {
-            $virtualization_role = "host";
-         }
+      if (is_dir("/proc/bc")) {
+        $virtualization_role = "host";
       }
-
-      elsif ($product_name =~ /KVM|Bochs/) {
-         $virtualization_type = "kvm";
-         $virtualization_role = "guest";
-      }
-
-      elsif ($product_name =~ /VMware Virtual Platform/) {
-         $virtualization_type = "vmware";
-         $virtualization_role = "guest";
-      }
-
-      elsif ($bios_vendor =~ /Xen/) {
-         $virtualization_type = "xen";
-         $virtualization_role = "guest";
-      }
-
-      elsif ($bios_vendor =~ /innotek GmbH/) {
-         $virtualization_type = "virtualbox";
-         $virtualization_role = "guest";
-      }
-
-      elsif ($sys_vendor =~ /Microsoft Corporation/) {
-         $virtualization_type = "VirtualPC";
-         $virtualization_role = "guest";
-      }
-
-      elsif ($sys_vendor =~ /Parallels Software International Inc/) {
-         $virtualization_type = "parallels";
-         $virtualization_role = "guest";
+    }
+
+    elsif ($product_name =~ /KVM|Bochs/) {
+      $virtualization_type = "kvm";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($product_name =~ /VMware Virtual Platform/) {
+      $virtualization_type = "vmware";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($bios_vendor =~ /Xen/) {
+      $virtualization_type = "xen";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($bios_vendor =~ /innotek GmbH/) {
+      $virtualization_type = "virtualbox";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($sys_vendor =~ /Microsoft Corporation/) {
+      $virtualization_type = "VirtualPC";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($sys_vendor =~ /Parallels Software International Inc/) {
+      $virtualization_type = "parallels";
+      $virtualization_role = "guest";
+    }
+
+    elsif ($self_status =~ /VxID: \d+/) {
+      $virtualization_type = "linux_vserver";
+      $virtualization_role = "guest";
+
+      if ($self_status =~ /VxID: 0/) {
+        $virtualization_role = "host";
       }
+    }
 
-      elsif ($self_status =~ /VxID: \d+/) {
-         $virtualization_type = "linux_vserver";
-         $virtualization_role = "guest";
-
-        if ($self_status =~ /VxID: 0/) {
-           $virtualization_role = "host";
-        }
-      }
-
-      elsif ($cpuinfo =~ /model name.*QEMU Virtual CPU/) {
-         $virtualization_type = "kvm";
-         $virtualization_role = "guest";
-      }
+    elsif ($cpuinfo =~ /model name.*QEMU Virtual CPU/) {
+      $virtualization_type = "kvm";
+      $virtualization_role = "guest";
+    }
 
-      elsif ($cpuinfo =~ /vendor_id.*User Mode Linux|model name.*UML/) {
-         $virtualization_type = "uml";
-         $virtualization_role = "guest";
-      }
+    elsif ($cpuinfo =~ /vendor_id.*User Mode Linux|model name.*UML/) {
+      $virtualization_type = "uml";
+      $virtualization_role = "guest";
+    }
 
-      elsif ($cpuinfo =~ /vendor_id.*PowerVM Lx86/) {
-         $virtualization_type = "powervm_lx86";
-         $virtualization_role = "guest";
-      }
+    elsif ($cpuinfo =~ /vendor_id.*PowerVM Lx86/) {
+      $virtualization_type = "powervm_lx86";
+      $virtualization_role = "guest";
+    }
 
-      elsif ($cpuinfo =~ /vendor_id.*IBM\/S390/) {
-         $virtualization_type = "ibm_systemz";
-         $virtualization_role = "guest";
-      }
+    elsif ($cpuinfo =~ /vendor_id.*IBM\/S390/) {
+      $virtualization_type = "ibm_systemz";
+      $virtualization_role = "guest";
+    }
 
-      elsif ($modules =~ /kvm/) {
-         $virtualization_type = "kvm";
-         $virtualization_role = "host";
-      }
+    elsif ($modules =~ /kvm/) {
+      $virtualization_type = "kvm";
+      $virtualization_role = "host";
+    }
 
-      elsif ($modules =~ /vboxdrv/) {
-         $virtualization_type = "virtualbox";
-         $virtualization_role = "host";
-      }
+    elsif ($modules =~ /vboxdrv/) {
+      $virtualization_type = "virtualbox";
+      $virtualization_role = "host";
+    }
 
-      my $data = {
-         virtualization_type => $virtualization_type,
-         virtualization_role => $virtualization_role,
-      };
+    my $data = {
+      virtualization_type => $virtualization_type,
+      virtualization_role => $virtualization_role,
+    };
 
-      $cache->set($cache_key_name, $data);
+    $cache->set($cache_key_name, $data);
 
-      return $data;
+    return $data;
 
-   }
+  }
 }
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -41,13 +41,13 @@ require Rex::Args;
 Returns a hash with the wanted information.
 
  task "get-info", "server1", sub {
-    %hw_info = Rex::Hardware->get(qw/ Host Network /);
+   %hw_info = Rex::Hardware->get(qw/ Host Network /);
  };
 
 Or if you want to get all information
 
  task "get-all-info", "server1", sub {
-    %hw_info = Rex::Hardware->get(qw/ All /);
+   %hw_info = Rex::Hardware->get(qw/ All /);
  };
 
 Available modules:
@@ -72,48 +72,48 @@ Available modules:
 
 my %HW_PROVIDER;
 sub register_hardware_provider {
-   my ($class, $service_name, $service_class) = @_;
-   $HW_PROVIDER{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $HW_PROVIDER{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub get {
-   my($class, @modules) = @_;
+  my($class, @modules) = @_;
 
-   my %hardware_information;
+  my %hardware_information;
 
-   if("all" eq "\L$modules[0]") {
+  if("all" eq "\L$modules[0]") {
 
-      @modules = qw(Host Kernel Memory Network Swap VirtInfo);
-      push(@modules, keys(%HW_PROVIDER));
-   
-   }
+    @modules = qw(Host Kernel Memory Network Swap VirtInfo);
+    push(@modules, keys(%HW_PROVIDER));
+  
+  }
 
-   for my $mod_string (@modules) {
+  for my $mod_string (@modules) {
 
-      Rex::Commands::profiler()->start("hardware: $mod_string");
+    Rex::Commands::profiler()->start("hardware: $mod_string");
 
-      my $mod = "Rex::Hardware::$mod_string";
-      if(exists $HW_PROVIDER{$mod_string}) {
-         $mod = $HW_PROVIDER{$mod_string};
-      }
+    my $mod = "Rex::Hardware::$mod_string";
+    if(exists $HW_PROVIDER{$mod_string}) {
+      $mod = $HW_PROVIDER{$mod_string};
+    }
 
-      Rex::Logger::debug("Loading $mod");
-      eval "use $mod";
+    Rex::Logger::debug("Loading $mod");
+    eval "use $mod";
 
-      if($@) {
-         Rex::Logger::info("$mod not found.");
-         Rex::Logger::debug("$@");
-         next;
-      }
+    if($@) {
+      Rex::Logger::info("$mod not found.");
+      Rex::Logger::debug("$@");
+      next;
+    }
 
-      $hardware_information{$mod_string} = $mod->get();
+    $hardware_information{$mod_string} = $mod->get();
 
-      Rex::Commands::profiler()->end("hardware: $mod_string");
+    Rex::Commands::profiler()->end("hardware: $mod_string");
 
-   }
+  }
 
-   return %hardware_information;
+  return %hardware_information;
 }
 
 =back
@@ -1,41 +1,41 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::Array;
-   
+  
 use strict;
 use warnings;
 
 require Exporter;
 use base qw(Exporter);
 use vars qw(@EXPORT);
-    
+   
 @EXPORT = qw(array_uniq in_array);
 
 sub array_uniq {
-   my (@array) = @_;
+  my (@array) = @_;
 
-   my %all = ();
-   @all{@array} = 1;
-   return keys %all;
+  my %all = ();
+  @all{@array} = 1;
+  return keys %all;
 }
 
 sub in_array {
-   my ($needle, @haystack) = @_;
+  my ($needle, @haystack) = @_;
 
-   my ($ret) = grep {
-      if(ref $needle eq "RegExp" && $_ =~ $needle) {
-         return $_;
-      }
-      elsif($_ eq $needle) {
-         return $_;
-      }
-   } @haystack;
+  my ($ret) = grep {
+    if(ref $needle eq "RegExp" && $_ =~ $needle) {
+      return $_;
+    }
+    elsif($_ eq $needle) {
+      return $_;
+    }
+  } @haystack;
 
-   return $ret;
+  return $ret;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::Encode;
 
 use strict;
@@ -16,64 +16,64 @@ use vars qw(@EXPORT);
 
 my %escapes;
 for (0..255) {
-   $escapes{chr($_)} = sprintf("%%%02X", $_);
+  $escapes{chr($_)} = sprintf("%%%02X", $_);
 }
 
 sub url_encode{
-   my ($txt)=@_;
-   $txt =~ s/([^A-Za-z0-9_])/$escapes{$1}/g;
-   return $txt;
+  my ($txt)=@_;
+  $txt =~ s/([^A-Za-z0-9_])/$escapes{$1}/g;
+  return $txt;
 }
 
 sub url_decode{
-   my ($txt)=@_;
-   $txt=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
-   return $txt;
+  my ($txt)=@_;
+  $txt=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+  return $txt;
 }
 
 sub func_to_json {
 
-   return q|
-   sub to_json {
-      my ($ref) = @_;
+  return q|
+  sub to_json {
+    my ($ref) = @_;
 
-      my $s = "";
+    my $s = "";
 
-      if(ref $ref eq "ARRAY") {
-         $s .= "[";
-         for my $itm (@{ $ref }) {
-            if(substr($s, -1) ne "[") {
-               $s .= ",";
-            }
-            $s .= to_json($itm);
-         }
-         return $s . "]";
+    if(ref $ref eq "ARRAY") {
+      $s .= "[";
+      for my $itm (@{ $ref }) {
+        if(substr($s, -1) ne "[") {
+          $s .= ",";
+        }
+        $s .= to_json($itm);
       }
-      elsif(ref $ref eq "HASH") {
-         $s .= "{";
-         for my $key (keys %{ $ref }) {
-            if(substr($s, -1) ne "{") {
-               $s .= ",";
-            }
-            $s .= "\"$key\": " . to_json($ref->{$key});
-         }
-         return $s . "}";
+      return $s . "]";
+    }
+    elsif(ref $ref eq "HASH") {
+      $s .= "{";
+      for my $key (keys %{ $ref }) {
+        if(substr($s, -1) ne "{") {
+          $s .= ",";
+        }
+        $s .= "\"$key\": " . to_json($ref->{$key});
+      }
+      return $s . "}";
+    }
+    else {
+      if($ref =~ /^0\d+/) {
+        return "\"$ref\"";
+      }
+      elsif($ref =~ /^\d+$/) {
+        return $ref;
       }
       else {
-         if($ref =~ /^0\d+/) {
-            return "\"$ref\"";
-         }
-         elsif($ref =~ /^\d+$/) {
-            return $ref;
-         }
-         else {
-            $ref =~ s/'/\\\'/g;
-            return "\"$ref\"";
-         }
+        $ref =~ s/'/\\\'/g;
+        return "\"$ref\"";
       }
-   }
+    }
+  }
 
-   |;
+  |;
 
 }
 
@@ -1,53 +1,53 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::Hash;
-   
+  
 use strict;
 use warnings;
 
 require Exporter;
 use base qw(Exporter);
 use vars qw(@EXPORT);
-    
+   
 @EXPORT = qw(hash_flatten);
 
 sub hash_flatten {
-   my ($in, $out, $sep, @super_keys) = @_;
+  my ($in, $out, $sep, @super_keys) = @_;
 
-   if(ref($in) eq "HASH") {
-      for my $key (keys %{$in}) {
-         push @super_keys, $key;
-         if(ref($in->{$key})) {
-            hash_flatten($in->{$key}, $out, $sep, @super_keys);
-         }
-         else {
-            my $new_key_name = join($sep, @super_keys);
-            $new_key_name =~ s/[^A-Za-z0-9_]/_/g;
-            $out->{$new_key_name} = $in->{$key};
-         }
-         pop @super_keys;
+  if(ref($in) eq "HASH") {
+    for my $key (keys %{$in}) {
+      push @super_keys, $key;
+      if(ref($in->{$key})) {
+        hash_flatten($in->{$key}, $out, $sep, @super_keys);
+      }
+      else {
+        my $new_key_name = join($sep, @super_keys);
+        $new_key_name =~ s/[^A-Za-z0-9_]/_/g;
+        $out->{$new_key_name} = $in->{$key};
+      }
+      pop @super_keys;
+    }
+  }
+  elsif(ref($in) eq "ARRAY") {
+    my $counter = 0;
+    for my $val (@{$in}) {
+      if(ref($val)) {
+        push @super_keys, $counter;
+        hash_flatten($val, $out, $sep, @super_keys);
+        pop @super_keys;
       }
-   }
-   elsif(ref($in) eq "ARRAY") {
-      my $counter = 0;
-      for my $val (@{$in}) {
-         if(ref($val)) {
-            push @super_keys, $counter;
-            hash_flatten($val, $out, $sep, @super_keys);
-            pop @super_keys;
-         }
-         else {
-            my $new_key_name = join($sep, @super_keys) . "_$counter";
-            $new_key_name =~ s/[^A-Za-z0-9_]/_/g;
-            $out->{$new_key_name} = $val;
-         }
-         $counter++;
+      else {
+        my $new_key_name = join($sep, @super_keys) . "_$counter";
+        $new_key_name =~ s/[^A-Za-z0-9_]/_/g;
+        $out->{$new_key_name} = $val;
       }
-   }
+      $counter++;
+    }
+  }
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::INI;
 
 use strict;
@@ -13,92 +13,92 @@ use String::Escape 'string2hash';
 
 
 sub parse {
-   my (@lines) = @_;
-   my $ini;
-
-   my $section;
-   for (@lines) {
-      chomp;
-      s/\n|\r//g;
-
-      (/^#|^;|^\s*$/) && (next);
-
-      if(/^\[(.*)\]/) {
-         # check for inheritance
-         $section = $1;
-         $ini->{$section} = {};
-
-         if($section =~ /</) {
-            delete $ini->{$section};
-            my @inherit = split(/</, $section);
-            s/^\s*|\s*$//g for @inherit;
-            $section = shift @inherit;
-
-            for my $is (@inherit) {
-               for my $ik (keys %{ $ini->{$is} }) {
-                  $ini->{$section}->{$ik} = $ini->{$is}->{$ik};
-               }
-            }
-         }
-
-         next;
+  my (@lines) = @_;
+  my $ini;
+
+  my $section;
+  for (@lines) {
+    chomp;
+    s/\n|\r//g;
+
+    (/^#|^;|^\s*$/) && (next);
+
+    if(/^\[(.*)\]/) {
+      # check for inheritance
+      $section = $1;
+      $ini->{$section} = {};
+
+      if($section =~ /</) {
+        delete $ini->{$section};
+        my @inherit = split(/</, $section);
+        s/^\s*|\s*$//g for @inherit;
+        $section = shift @inherit;
+
+        for my $is (@inherit) {
+          for my $ik (keys %{ $ini->{$is} }) {
+            $ini->{$section}->{$ik} = $ini->{$is}->{$ik};
+          }
+        }
       }
 
-      my ($key, $val) = split(/[= ]/, $_, 2);
-      $key =~ s/^\s*|\s*$//g if $key;
-      $val =~ s/^\s*|\s*$//g if $val;
+      next;
+    }
 
+    my ($key, $val) = split(/[= ]/, $_, 2);
+    $key =~ s/^\s*|\s*$//g if $key;
+    $val =~ s/^\s*|\s*$//g if $val;
 
-      my @splitted;
-      if(! $val) {
-         $val = $key;
-         @splitted = ($key);
-      }
-      # commented out due to #184
-      else {
-         #@splitted = split(/\./, $key);
-         @splitted = ($key);
-      }
 
-      my $ref = $ini->{$section};
-      my $last = pop @splitted;
-      for my $sub (@splitted) {
+    my @splitted;
+    if(! $val) {
+      $val = $key;
+      @splitted = ($key);
+    }
+    # commented out due to #184
+    else {
+      #@splitted = split(/\./, $key);
+      @splitted = ($key);
+    }
 
-         unless(exists $ini->{$section}->{$sub}) {
-            $ini->{$section}->{$sub} = {};
-         }
-
-         $ref = $ini->{$section}->{$sub};
-      }
+    my $ref = $ini->{$section};
+    my $last = pop @splitted;
+    for my $sub (@splitted) {
 
-      # include other group
-      if($key =~ m/^\@(.*)/) {
-         for my $ik (keys %{ $ini->{$1} }) {
-            $ini->{$section}->{$ik} = $ini->{$1}->{$ik};
-         }
-         next;
+      unless(exists $ini->{$section}->{$sub}) {
+        $ini->{$section}->{$sub} = {};
       }
 
-      if($val =~ m/\$\{(.*)\}/) {
-         my $var_name = $1;
-         my $ref = $ini;
-         my @splitted = split(/\./, $var_name);
-         for my $s (@splitted) {
-            $ref = $ref->{$s};
-         }
+      $ref = $ini->{$section}->{$sub};
+    }
 
-         $val = $ref;
+    # include other group
+    if($key =~ m/^\@(.*)/) {
+      for my $ik (keys %{ $ini->{$1} }) {
+        $ini->{$section}->{$ik} = $ini->{$1}->{$ik};
       }
-
-      if($val =~ m/=/) {
-         $val = { string2hash($val) };
+      next;
+    }
+
+    if($val =~ m/\$\{(.*)\}/) {
+      my $var_name = $1;
+      my $ref = $ini;
+      my @splitted = split(/\./, $var_name);
+      for my $s (@splitted) {
+        $ref = $ref->{$s};
       }
 
-      $ref->{$last} = $val;
+      $val = $ref;
+    }
+
+    if($val =~ m/=/) {
+      $val = { string2hash($val) };
+    }
+
+    $ref->{$last} = $val;
 
-   }
+  }
 
-   return $ini;
+  return $ini;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::Path;
 
 use strict;
@@ -29,131 +29,131 @@ use Rex::Interface::Exec;
 # RETURNS: module file
 #
 sub get_file_path {
-   my ($file_name, $caller_package, $caller_file) = @_;
+  my ($file_name, $caller_package, $caller_file) = @_;
 
-   $file_name = resolv_path($file_name);
+  $file_name = resolv_path($file_name);
 
 
-   if(! $caller_package) {
-      ($caller_package, $caller_file) = caller();
-   }
+  if(! $caller_package) {
+    ($caller_package, $caller_file) = caller();
+  }
 
-   # check if a file in $BASE overwrites the module file
-   # first get the absoltue path to the rexfile
+  # check if a file in $BASE overwrites the module file
+  # first get the absoltue path to the rexfile
 
-   $::rexfile ||= $0;
+  $::rexfile ||= $0;
 
-   my @path_parts;
-   if($^O =~ m/^MSWin/ && ! Rex::is_ssh()) {
-      @path_parts = split(/\//, $::rexfile);
-   }
-   else {
-      @path_parts = split(/\//, realpath($::rexfile));
-   }
-   pop @path_parts;
+  my @path_parts;
+  if($^O =~ m/^MSWin/ && ! Rex::is_ssh()) {
+    @path_parts = split(/\//, $::rexfile);
+  }
+  else {
+    @path_parts = split(/\//, realpath($::rexfile));
+  }
+  pop @path_parts;
 
-   my $real_path = join('/', @path_parts);
+  my $real_path = join('/', @path_parts);
 
-   if(-e $file_name) {
-      return $file_name;
-   }
-
-   if(-e $real_path . '/' . $file_name) {
-      return $real_path . '/' . $file_name;
-   }
-
-   # walk down the wire to find the file...
-   my ($old_caller_file) = $caller_file;
-   my $i = 0;
-   while($caller_package && $i <= 50) {
-      ($caller_package, $caller_file) = caller($i);
-      if(! $caller_package) {
-         last;
-      }
+  if(-e $file_name) {
+    return $file_name;
+  }
 
-      my $module_path = Rex::get_module_path($caller_package);
-      if(-e "$module_path/$file_name") {
-         $file_name = "$module_path/$file_name";
-         return $file_name;
-      }
+  if(-e $real_path . '/' . $file_name) {
+    return $real_path . '/' . $file_name;
+  }
 
-      $i++;
-   }
+  # walk down the wire to find the file...
+  my ($old_caller_file) = $caller_file;
+  my $i = 0;
+  while($caller_package && $i <= 50) {
+    ($caller_package, $caller_file) = caller($i);
+    if(! $caller_package) {
+      last;
+    }
 
-   $file_name = dirname($old_caller_file) . "/" . $file_name;
+    my $module_path = Rex::get_module_path($caller_package);
+    if(-e "$module_path/$file_name") {
+      $file_name = "$module_path/$file_name";
+      return $file_name;
+    }
 
-   return $file_name;
-}
+    $i++;
+  }
 
-sub get_tmp_file {
-   my $rnd_file;
-
-   if(Rex::is_ssh()) {
-      $rnd_file = Rex::Config->get_tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp";
-   }
-   elsif($^O =~ m/^MSWin/) {
-      my $tmp_dir = Rex::Config->get_tmp_dir;
-      if($tmp_dir eq "/tmp") {
-         $tmp_dir = $ENV{TMP};
-      }
+  $file_name = dirname($old_caller_file) . "/" . $file_name;
 
-      $rnd_file = $tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp"
-   }
-   else {
-      $rnd_file = Rex::Config->get_tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp";
-   }
+  return $file_name;
+}
 
-   return $rnd_file;
+sub get_tmp_file {
+  my $rnd_file;
+
+  if(Rex::is_ssh()) {
+    $rnd_file = Rex::Config->get_tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp";
+  }
+  elsif($^O =~ m/^MSWin/) {
+    my $tmp_dir = Rex::Config->get_tmp_dir;
+    if($tmp_dir eq "/tmp") {
+      $tmp_dir = $ENV{TMP};
+    }
+
+    $rnd_file = $tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp"
+  }
+  else {
+    $rnd_file = Rex::Config->get_tmp_dir . "/" . Rex::Commands::get_random(12, 'a' .. 'z') . ".tmp";
+  }
+
+  return $rnd_file;
 }
 
 sub resolv_path {
-   my ($path, $local) = @_;
-
-   if($path !~ m/^~/) {
-      # path starts not with ~ so we don't need to expand $HOME.
-      # just return it.
-      return $path;
-   }
-
-   my $home_path;
-   require Rex::User;
-   my $user_o = Rex::User->get;
-
-   if($local) {
-      if($^O =~ m/^MSWin/) {
-         # windows path:
-         $home_path = $ENV{'USERPROFILE'};
-      }
-      else {
-         if($path =~ m/^~([a-zA-Z0-9_][^\/]+)\//) {
-            my $user_name = $1;
-            my %user_info = $user_o->get_user($user_name);
-            $home_path = $user_info{home};
-            $path =~ s/^~$user_name/$home_path/;
-         }
-         else {
-            $home_path = $ENV{'HOME'};
-            $path =~ s/^~/$home_path/;
-         }
-      }
-   }
-   else {
+  my ($path, $local) = @_;
+
+  if($path !~ m/^~/) {
+    # path starts not with ~ so we don't need to expand $HOME.
+    # just return it.
+    return $path;
+  }
+
+  my $home_path;
+  require Rex::User;
+  my $user_o = Rex::User->get;
+
+  if($local) {
+    if($^O =~ m/^MSWin/) {
+      # windows path:
+      $home_path = $ENV{'USERPROFILE'};
+    }
+    else {
       if($path =~ m/^~([a-zA-Z0-9_][^\/]+)\//) {
-         my $user_name = $1;
-         my %user_info = $user_o->get_user($user_name);
-         $home_path = $user_info{home};
-         $path =~ s/^~$user_name/$home_path/;
+        my $user_name = $1;
+        my %user_info = $user_o->get_user($user_name);
+        $home_path = $user_info{home};
+        $path =~ s/^~$user_name/$home_path/;
       }
       else {
-         my $exec = Rex::Interface::Exec->create;
-         my $remote_home = $exec->exec("echo \$HOME");
-         $remote_home =~ s/[\r\n]//gms;
-         $home_path = $remote_home;
-         $path =~ s/^~/$home_path/;
+        $home_path = $ENV{'HOME'};
+        $path =~ s/^~/$home_path/;
       }
-   }
-
-   return $path;
+    }
+  }
+  else {
+    if($path =~ m/^~([a-zA-Z0-9_][^\/]+)\//) {
+      my $user_name = $1;
+      my %user_info = $user_o->get_user($user_name);
+      $home_path = $user_info{home};
+      $path =~ s/^~$user_name/$home_path/;
+    }
+    else {
+      my $exec = Rex::Interface::Exec->create;
+      my $remote_home = $exec->exec("echo \$HOME");
+      $remote_home =~ s/[\r\n]//gms;
+      $home_path = $remote_home;
+      $path =~ s/^~/$home_path/;
+    }
+  }
+
+  return $path;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::Run;
 
 use strict;
@@ -22,64 +22,64 @@ require Rex::Config;
 @EXPORT = qw(upload_and_run i_run);
 
 sub upload_and_run {
-   my ($template, %option) = @_;
+  my ($template, %option) = @_;
 
-   my $rnd_file = get_tmp_file;
+  my $rnd_file = get_tmp_file;
 
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write($template);
-   $fh->close;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write($template);
+  $fh->close;
 
-   my $fs = Rex::Interface::Fs->create;
-   $fs->chmod(755, $rnd_file);
+  my $fs = Rex::Interface::Fs->create;
+  $fs->chmod(755, $rnd_file);
 
-   my @argv;
-   my $command = $rnd_file;
+  my @argv;
+  my $command = $rnd_file;
 
-   if(exists $option{with}) {
-      $command = Rex::Config->get_executor_for($option{with}) . " $command";
-   }
+  if(exists $option{with}) {
+    $command = Rex::Config->get_executor_for($option{with}) . " $command";
+  }
 
-   if(exists $option{args}) {
-      $command .= join(" ", @{ $option{args} });
-   }
+  if(exists $option{args}) {
+    $command .= join(" ", @{ $option{args} });
+  }
 
-   return i_run("$command 2>&1");
+  return i_run("$command 2>&1");
 }
 
 # internal run command, doesn't get reported
 sub i_run {
-   my $cmd = shift;
-   my ($code, $option);
-   if(ref $_[0] eq "CODE") {
-      $code = shift;
-   }
-   elsif(scalar @_ > 0) {
-      $option = { @_ };
-   }
+  my $cmd = shift;
+  my ($code, $option);
+  if(ref $_[0] eq "CODE") {
+    $code = shift;
+  }
+  elsif(scalar @_ > 0) {
+    $option = { @_ };
+  }
 
-   my $path = join(":", Rex::Config->get_path());
+  my $path = join(":", Rex::Config->get_path());
 
-   my $exec = Rex::Interface::Exec->create;
-   my ($out, $err) = $exec->exec($cmd, $path, $option);
-   chomp $out if $out;
-   chomp $err if $err;
+  my $exec = Rex::Interface::Exec->create;
+  my ($out, $err) = $exec->exec($cmd, $path, $option);
+  chomp $out if $out;
+  chomp $err if $err;
 
-   $Rex::Commands::Run::LAST_OUTPUT = [$out, $err];
+  $Rex::Commands::Run::LAST_OUTPUT = [$out, $err];
 
-   $out ||= "";
-   $err ||= "";
+  $out ||= "";
+  $err ||= "";
 
-   if($code) {
-      return &$code($out, $err);
-   }
+  if($code) {
+    return &$code($out, $err);
+  }
 
-   if(wantarray) {
-      return split(/\r?\n/, $out);
-   }
+  if(wantarray) {
+    return split(/\r?\n/, $out);
+  }
 
-   return $out;
+  return $out;
 }
 
 1;
@@ -1,6 +1,6 @@
 #
 # (c) 2011 Jan Gehring <jan.gehring@gmail.com>
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 #
 
@@ -25,27 +25,27 @@ L<Net::SSH2>
 =head1 SYNOPSIS
 
  use Rex::Helper::SSH2::Expect;
-       
+     
  my $exp = Rex::Helper::SSH2::Expect->new($ssh2);
  $exp->spawn("passwd");
  $exp->expect($timeout, [
-                           qr/Enter new UNIX password:/ => sub {
-                                                              my ($exp, $line) = @_;
-                                                              $exp->send($new_password);
-                                                           }
-                        ],
-                        [
-                           qr/Retype new UNIX password:/ => sub {
-                                                              my ($exp, $line) = @_;
-                                                              $exp->send($new_password);
-                                                           }
-                        ],
-                        [
-                           qr/passwd: password updated successfully/ => sub {
-                                                                           my ($exp, $line) = @_;
-                                                                           $exp->hard_close;
-                                                                        }
-                        ]);
+                  qr/Enter new UNIX password:/ => sub {
+                                          my ($exp, $line) = @_;
+                                          $exp->send($new_password);
+                                        }
+                ],
+                [
+                  qr/Retype new UNIX password:/ => sub {
+                                          my ($exp, $line) = @_;
+                                          $exp->send($new_password);
+                                        }
+                ],
+                [
+                  qr/passwd: password updated successfully/ => sub {
+                                                  my ($exp, $line) = @_;
+                                                  $exp->hard_close;
+                                                }
+                ]);
 
 =head1 CLASS METHODS
 
@@ -69,20 +69,20 @@ Constructor: You need to parse an connected Net::SSH2 Object.
 our $Log_Stdout = 1;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = {};
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = {};
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{"__shell"} = $_[0]->channel();
-   $self->{"__shell"}->pty("vt100");
-   $self->{"__shell"}->shell;
+  $self->{"__shell"} = $_[0]->channel();
+  $self->{"__shell"}->pty("vt100");
+  $self->{"__shell"}->shell;
 
-   $self->{"__log_stdout"} = $Rex::Helper::SSH2::Expect::Log_Stdout;
-   $self->{"__log_to"} = sub {};
+  $self->{"__log_stdout"} = $Rex::Helper::SSH2::Expect::Log_Stdout;
+  $self->{"__log_to"} = sub {};
 
-   return $self;
+  return $self;
 }
 
 =item log_stdout(0|1)
@@ -91,8 +91,8 @@ Log on STDOUT.
 
 =cut
 sub log_stdout {
-   my ($self, $log) = @_;
-   $self->{"__log_stdout"} = $log;
+  my ($self, $log) = @_;
+  $self->{"__log_stdout"} = $log;
 }
 
 =item log_file($file)
@@ -101,13 +101,13 @@ Log everything to a file. $file can be a filename, a filehandle or a subRef.
 
 =cut
 sub log_file {
-   my ($self, $file) = @_;
-   $self->{"__log_to"} = $file;
+  my ($self, $file) = @_;
+  $self->{"__log_to"} = $file;
 }
 
 sub shell {
-   my ($self) = @_;
-   return $self->{"__shell"};
+  my ($self) = @_;
+  return $self->{"__shell"};
 }
 
 =item spawn($command, @parameters)
@@ -116,10 +116,10 @@ Spawn $command with @parameters as parameters.
 
 =cut
 sub spawn {
-   my ($self, $command, @parameters) = @_;
+  my ($self, $command, @parameters) = @_;
 
-   my $cmd = "$command " . join(" ", @parameters);
-   $self->shell->write("$cmd\n");
+  my $cmd = "$command " . join(" ", @parameters);
+  $self->shell->write("$cmd\n");
 }
 
 =item soft_close()
@@ -129,8 +129,8 @@ Currently only an alias to hard_close();
 =cut
 
 sub soft_close {
-   my ($self) = @_;
-   $self->hard_close;
+  my ($self) = @_;
+  $self->hard_close;
 }
 
 =item hard_close();
@@ -140,8 +140,8 @@ Stops the execution of the process.
 =cut
 
 sub hard_close {
-   my ($self) = @_;
-   die;
+  my ($self) = @_;
+  die;
 }
 
 =item expect($timeout, @match_patters)
@@ -151,29 +151,29 @@ This method controls the execution of your process.
 =cut
 
 sub expect {
-   my ($self, $timeout, @match_patterns) = @_;
-
-   eval {
-      local $SIG{'ALRM'} = sub { die; };
-      alarm $timeout;
-
-      my $line = "";
-      while(1) {
-         my $buf;
-         $self->shell->read($buf, 1);
-
-         # log to stdout if wanted
-         print $buf if $self->{"__log_stdout"};
-         $self->_log($buf);
-
-         if($self->_check_patterns($line, @match_patterns)) {
-            $line = "";
-            alarm $timeout;
-            next;
-         }
-         $line .= $buf;
+  my ($self, $timeout, @match_patterns) = @_;
+
+  eval {
+    local $SIG{'ALRM'} = sub { die; };
+    alarm $timeout;
+
+    my $line = "";
+    while(1) {
+      my $buf;
+      $self->shell->read($buf, 1);
+
+      # log to stdout if wanted
+      print $buf if $self->{"__log_stdout"};
+      $self->_log($buf);
+
+      if($self->_check_patterns($line, @match_patterns)) {
+        $line = "";
+        alarm $timeout;
+        next;
       }
-   };
+      $line .= $buf;
+    }
+  };
 }
 
 =item send($string)
@@ -183,39 +183,39 @@ Send a string to the running command.
 =cut
 
 sub send {
-   my ($self, $str) = @_;
-   $self->shell->write($str);
+  my ($self, $str) = @_;
+  $self->shell->write($str);
 }
 
 sub _check_patterns {
-   my ($self, $line, @match_patterns) = @_;
-
-   for my $pattern (@match_patterns) {
-      if($line =~ $pattern->[0]) {
-         my $code = $pattern->[1];
-         &$code($self, $line);
-         return 1;
-      }
-   }
+  my ($self, $line, @match_patterns) = @_;
+
+  for my $pattern (@match_patterns) {
+    if($line =~ $pattern->[0]) {
+      my $code = $pattern->[1];
+      &$code($self, $line);
+      return 1;
+    }
+  }
 }
 
 sub _log {
-   my ($self, $str) = @_;
-
-   my $log_to = $self->{"__log_to"};
-
-   if(ref($log_to) eq "CODE") {
-      &$log_to($str);
-   }
-   elsif(ref($log_to) eq "GLOB") {
-      print $log_to $str;
-   }
-   else {
-      # log to a file
-      open(my $fh, ">>", $log_to) or die($!);
-      print $fh $str;
-      close($fh);
-   }
+  my ($self, $str) = @_;
+
+  my $log_to = $self->{"__log_to"};
+
+  if(ref($log_to) eq "CODE") {
+    &$log_to($str);
+  }
+  elsif(ref($log_to) eq "GLOB") {
+    print $log_to $str;
+  }
+  else {
+    # log to a file
+    open(my $fh, ">>", $log_to) or die($!);
+    print $fh $str;
+    close($fh);
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Helper::SSH2;
@@ -22,85 +22,85 @@ our $READ_STDERR = 1;
 our $EXEC_AND_SLEEP = 0;
 
 sub net_ssh2_exec {
-   my ($ssh, $cmd, $callback) = @_;
+  my ($ssh, $cmd, $callback) = @_;
 
-   my $chan = $ssh->channel;
+  my $chan = $ssh->channel;
 
-   # REQUIRE_TTY can be turned off by feature no_tty
-   if(! Rex::Config->get_no_tty) {
-      $chan->pty("xterm");    # set to xterm, due to problems with vt100.
-                              # if vt100 sometimes the restart of services doesn't work and need a sleep .000001 after the command...
-                              # strange bug...
-      $chan->pty_size(4000, 80);
-   }
-   $chan->blocking(1);
+  # REQUIRE_TTY can be turned off by feature no_tty
+  if(! Rex::Config->get_no_tty) {
+    $chan->pty("xterm");   # set to xterm, due to problems with vt100.
+                    # if vt100 sometimes the restart of services doesn't work and need a sleep .000001 after the command...
+                    # strange bug...
+    $chan->pty_size(4000, 80);
+  }
+  $chan->blocking(1);
 
-   $chan->exec($cmd);
+  $chan->exec($cmd);
 
-   my $in;
-   my $in_err = "";
+  my $in;
+  my $in_err = "";
 
-   my $rex_int_conf = Rex::Commands::get("rex_internals") || {};
-   my $buffer_size = 20;
-   if(exists $rex_int_conf->{read_buffer_size}) {
-      $buffer_size = $rex_int_conf->{read_buffer_size};
-   }
+  my $rex_int_conf = Rex::Commands::get("rex_internals") || {};
+  my $buffer_size = 20;
+  if(exists $rex_int_conf->{read_buffer_size}) {
+    $buffer_size = $rex_int_conf->{read_buffer_size};
+  }
 
-   while ( my $len = $chan->read(my $buf, $buffer_size) ) {
+  while ( my $len = $chan->read(my $buf, $buffer_size) ) {
 		$in .= $buf;
 
-      if($callback) {
-         &$callback($buf);
-      } 
-   }
+    if($callback) {
+      &$callback($buf);
+    } 
+  }
 
-   while ( my $len = $chan->read(my $buf_err, $buffer_size, 1) ) {
-	    $in_err .= $buf_err;
-   }
+  while ( my $len = $chan->read(my $buf_err, $buffer_size, 1) ) {
+	   $in_err .= $buf_err;
+  }
 
-   $chan->close;
-   $? = $chan->exit_status;
+  $chan->close;
+  $? = $chan->exit_status;
 
-   # if used with $chan->pty() we have to remove \r
-   if(! Rex::Config->get_no_tty) {
-      $in =~ s/\r//g if $in;
-      $in_err =~ s/\r//g if $in_err;
-   }
+  # if used with $chan->pty() we have to remove \r
+  if(! Rex::Config->get_no_tty) {
+    $in =~ s/\r//g if $in;
+    $in_err =~ s/\r//g if $in_err;
+  }
 
-   if(wantarray) {
-      return ($in, $in_err);
-   }
+  if(wantarray) {
+    return ($in, $in_err);
+  }
 
-   return $in;
+  return $in;
 }
 
 sub net_ssh2_exec_output {
-   my ($ssh, $cmd, $callback) = @_;
+  my ($ssh, $cmd, $callback) = @_;
 
-   my $chan = $ssh->channel;
-   $chan->blocking(1);
+  my $chan = $ssh->channel;
+  $chan->blocking(1);
 
-   $chan->exec($cmd);
+  $chan->exec($cmd);
 
-   while(1) {
-      my $buf;
-      my $buf_err;
-      $chan->read($buf, 15);
-      $chan->read($buf_err, 15);
+  while(1) {
+    my $buf;
+    my $buf_err;
+    $chan->read($buf, 15);
+    $chan->read($buf_err, 15);
 
-      if($callback) {
-         &$callback($buf, $buf_err);
-      } 
-      else {
-         print $buf;
-         print $buf_err;
-      }
+    if($callback) {
+      &$callback($buf, $buf_err);
+    } 
+    else {
+      print $buf;
+      print $buf_err;
+    }
 
-      last unless $buf;
-   }
+    last unless $buf;
+  }
 
-   $chan->close;
-   $? = $chan->exit_status;
+  $chan->close;
+  $? = $chan->exit_status;
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Helper::System;
-   
+  
 use strict;
 use warnings;
 
@@ -13,38 +13,38 @@ use Rex::Helper::Hash;
 
 sub info {
 
-   return eval {
-      my %merge1 = ();
-      my %merge2 = Rex::Hardware->get(qw/ All /);
-      my %template_vars = (%merge1, %merge2);
+  return eval {
+    my %merge1 = ();
+    my %merge2 = Rex::Hardware->get(qw/ All /);
+    my %template_vars = (%merge1, %merge2);
 
-      for my $info_key (qw(Network Host Kernel Memory Swap)) {
+    for my $info_key (qw(Network Host Kernel Memory Swap)) {
 
-         my $flatten_info = {};
+      my $flatten_info = {};
 
-         if($info_key eq "Memory") {
-            hash_flatten($merge2{$info_key}, $flatten_info, "_", "memory");
-         }
-         elsif($info_key eq "Swap") {
-            hash_flatten($merge2{$info_key}, $flatten_info, "_", "swap");
-         }
-         elsif($info_key eq "Network") {
-            hash_flatten($merge2{$info_key}->{"networkconfiguration"}, $flatten_info, "_");
-         }
-         else {
-            hash_flatten($merge2{$info_key}, $flatten_info, "_");
-         }
-
-         for my $key (keys %{$flatten_info}) {
-            $template_vars{$key} = $flatten_info->{$key};
-         }
+      if($info_key eq "Memory") {
+        hash_flatten($merge2{$info_key}, $flatten_info, "_", "memory");
+      }
+      elsif($info_key eq "Swap") {
+        hash_flatten($merge2{$info_key}, $flatten_info, "_", "swap");
+      }
+      elsif($info_key eq "Network") {
+        hash_flatten($merge2{$info_key}->{"networkconfiguration"}, $flatten_info, "_");
+      }
+      else {
+        hash_flatten($merge2{$info_key}, $flatten_info, "_");
+      }
 
+      for my $key (keys %{$flatten_info}) {
+        $template_vars{$key} = $flatten_info->{$key};
       }
 
-      return %template_vars;
-   } or do {
-      return ();
-   };
+    }
+
+    return %template_vars;
+  } or do {
+    return ();
+  };
 }
 
 
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Hook;
 
 use strict;
@@ -18,33 +18,33 @@ use vars qw(@EXPORT);
 my $__hooks = {};
 
 sub register_function_hooks {
-   my ($hooks) = @_;
+  my ($hooks) = @_;
 
-   for my $state (keys %{ $hooks }) {
-      for my $func (keys %{ $hooks->{$state} }) {
-         if(! exists $__hooks->{$state}->{$func}) {
-            $__hooks->{$state}->{$func} = [];
-         }
-
-         push @{ $__hooks->{$state}->{$func} }, $hooks->{$state}->{$func};
+  for my $state (keys %{ $hooks }) {
+    for my $func (keys %{ $hooks->{$state} }) {
+      if(! exists $__hooks->{$state}->{$func}) {
+        $__hooks->{$state}->{$func} = [];
       }
-   }
+
+      push @{ $__hooks->{$state}->{$func} }, $hooks->{$state}->{$func};
+    }
+  }
 }
 
 sub run_hook {
-   my ($command, $state, @args) = @_;
+  my ($command, $state, @args) = @_;
 
-   if(! exists $__hooks->{$state}->{$command}) {
-      return;
-   }
+  if(! exists $__hooks->{$state}->{$command}) {
+    return;
+  }
 
-   my $func_arr = $__hooks->{$state}->{$command};
+  my $func_arr = $__hooks->{$state}->{$command};
 
-   for my $func (@{ $func_arr }) {
-      @args = $func->(@args);
-   }
+  for my $func (@{ $func_arr }) {
+    @args = $func->(@args);
+  }
 
-   return @args;
+  return @args;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Cache::Base;
 
 use strict;
@@ -14,61 +14,61 @@ use Rex::Logger;
 use Rex;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub gen_key_name {
-   my ($self, $key_name) = @_;
-   return $key_name if $key_name;
+  my ($self, $key_name) = @_;
+  return $key_name if $key_name;
 
-   my ($package, $filename, $line, $subroutine) = caller(1);
+  my ($package, $filename, $line, $subroutine) = caller(1);
 
-   $package =~ s/::/_/g;
+  $package =~ s/::/_/g;
 
-   my $gen_key_name = "\L${package}_\L${subroutine}";
+  my $gen_key_name = "\L${package}_\L${subroutine}";
 
-   return $gen_key_name;
+  return $gen_key_name;
 }
 
 sub set {
-   my ($self, $key, $val, $timeout) = @_;
+  my ($self, $key, $val, $timeout) = @_;
 
-   if(Rex::Config->get_use_cache) {
-      $self->{__data__}->{$key} = $val;
-   }
+  if(Rex::Config->get_use_cache) {
+    $self->{__data__}->{$key} = $val;
+  }
 }
 
 sub valid {
-   my ($self, $key) = @_;
-   return exists $self->{__data__}->{$key};
+  my ($self, $key) = @_;
+  return exists $self->{__data__}->{$key};
 }
 
 sub get {
-   my ($self, $key) = @_;
-   return $self->{__data__}->{$key};
+  my ($self, $key) = @_;
+  return $self->{__data__}->{$key};
 }
 
 sub reset {
-   my ($self) = @_;
-   $self->{__data__} = {};
+  my ($self) = @_;
+  $self->{__data__} = {};
 }
 
 # have to be overwritten by subclass
 sub save {
-   my ($self) = @_;
-   return 1;
+  my ($self) = @_;
+  return 1;
 }
 
 # have to be overwritten by subclass
 sub load {
-   my ($self) = @_;
-   return 0;
+  my ($self) = @_;
+  return 0;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Cache::YAML;
 
 use Rex::Interface::Cache::Base;
@@ -14,54 +14,54 @@ require Rex::Commands::Fs;
 require YAML;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub save {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $path = Rex::Commands::get("cache_path") || ".cache";
+  my $path = Rex::Commands::get("cache_path") || ".cache";
 
-   if(exists $ENV{REX_CACHE_PATH}) {
-      $path = $ENV{REX_CACHE_PATH};
-   }
+  if(exists $ENV{REX_CACHE_PATH}) {
+    $path = $ENV{REX_CACHE_PATH};
+  }
 
-   if(! -d $path) {
-      Rex::Commands::LOCAL(sub { mkdir $path });
-   }
+  if(! -d $path) {
+    Rex::Commands::LOCAL(sub { mkdir $path });
+  }
 
-   open(my $fh, ">", "$path/" . Rex::Commands::connection->server . ".yml") or die($!);
-   print $fh YAML::Dump($self->{__data__});
-   close($fh);
+  open(my $fh, ">", "$path/" . Rex::Commands::connection->server . ".yml") or die($!);
+  print $fh YAML::Dump($self->{__data__});
+  close($fh);
 }
 
 sub load {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $path = Rex::Commands::get("cache_path") || ".cache";
+  my $path = Rex::Commands::get("cache_path") || ".cache";
 
-   if(exists $ENV{REX_CACHE_PATH}) {
-      $path = $ENV{REX_CACHE_PATH};
-   }
+  if(exists $ENV{REX_CACHE_PATH}) {
+    $path = $ENV{REX_CACHE_PATH};
+  }
 
-   my $file_name = "$path/" . Rex::Commands::connection->server . ".yml";
+  my $file_name = "$path/" . Rex::Commands::connection->server . ".yml";
 
-   if(! -f $file_name) {
-      # no cache found
-      return;
-   }
+  if(! -f $file_name) {
+    # no cache found
+    return;
+  }
 
-   my $yaml = eval { local(@ARGV, $/) = ($file_name); <>; };
+  my $yaml = eval { local(@ARGV, $/) = ($file_name); <>; };
 
-   $yaml .= "\n";
+  $yaml .= "\n";
 
-   $self->{__data__} = YAML::Load($yaml);
+  $self->{__data__} = YAML::Load($yaml);
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Cache;
 
 use strict;
@@ -11,17 +11,17 @@ use warnings;
 
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      $type = Rex::Config->get_cache_type;
-   }
+  unless($type) {
+    $type = Rex::Config->get_cache_type;
+  }
 
-   my $class_name = "Rex::Interface::Cache::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading connection interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::Cache::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading connection interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::Base;
-   
+  
 use strict;
 use warnings;
 
@@ -13,13 +13,13 @@ use Rex::Interface::Fs;
 use Rex::Interface::Exec;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub error { die("Must be implemented by Interface Class"); };
@@ -32,41 +32,41 @@ sub get_connection_type { die("Must be implemented by Interface Class") };
 sub reconnect {};
 
 sub get_fs_connection_object {
-   my ($self) = @_;
-   return $self;
+  my ($self) = @_;
+  return $self;
 }
 
 sub get_fs {
-   my $fs = Rex::Interface::Fs->create;
-   return $fs;
+  my $fs = Rex::Interface::Fs->create;
+  return $fs;
 }
 
 sub get_exec {
-   my $exec = Rex::Interface::Exec->create;
-   return $exec;
+  my $exec = Rex::Interface::Exec->create;
+  return $exec;
 }
 
 sub server {
-   my ($self) = @_;
-   return $self->{server};
+  my ($self) = @_;
+  return $self->{server};
 }
 
 sub get_auth_user {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{__auth_info__}) {
-      return $self->{__auth_info__}->{user};
-   }
+  if(exists $self->{__auth_info__}) {
+    return $self->{__auth_info__}->{user};
+  }
 
-   return "";
+  return "";
 }
 
 sub get_auth {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(exists $self->{__auth_info__}) {
-      return $self->{__auth_info__};
-   }
+  if(exists $self->{__auth_info__}) {
+    return $self->{__auth_info__};
+  }
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::Fake;
-   
+  
 use strict;
 use warnings;
 
@@ -14,19 +14,19 @@ use Rex::Interface::Connection::Base;
 use base qw(Rex::Interface::Connection::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub error { };
 sub connect {
-   my ($self, %option) = @_;
-   $self->{server} = $option{server};
+  my ($self, %option) = @_;
+  $self->{server} = $option{server};
 }
 
 sub disconnect { };
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::HTTP;
-   
+  
 use strict;
 use warnings;
 
@@ -17,61 +17,61 @@ use Data::Dumper;
 use base qw(Rex::Interface::Connection::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   # activate caching
-   Rex::Config->set_use_cache(1);
+  # activate caching
+  Rex::Config->set_use_cache(1);
 
-   return $self;
+  return $self;
 }
 
 sub error { };
 sub connect {
-   my ($self, %option) = @_;
-   my ($user, $pass, $server, $port, $timeout);
-
-   $user    = $option{user};
-   $pass    = $option{password};
-   $server  = $option{server};
-   $port    = $self->_get_port($option{port});
-   $timeout = $option{timeout};
-
-   $self->{server} = $server;
-   $self->{port} = $port;
-
-   if($server =~ m/([^:]+):(\d+)/) {
-      $server = $self->{server} = $1;
-      $port   = $self->{port}   = $2;
-   }
-
-   $self->{__user} = $user;
-   $self->{__pass} = $pass;
-
-   if( ! Rex::Config->has_user && Rex::Config->get_ssh_config_username(server => $server) ) {
-      $user = Rex::Config->get_ssh_config_username(server => $server);
-   }
-
-   $self->ua->credentials(
-      "$server:$port",
-      "Rex::Endpoint::HTTP",
-      $user => $pass,
-   );
-
-   my $resp = $self->post("/login");
-   if($resp->{ok}) {
-      Rex::Logger::info("Connected to $server, trying to authenticate.");
-   }
-   else {
-      Rex::Logger::info("Can't connect to $server", "warn");
-      $self->{connected} = 0;
-      return;
-   }
-
-   Rex::Logger::info("Connecting to $server:$port (" . $user . ")");
+  my ($self, %option) = @_;
+  my ($user, $pass, $server, $port, $timeout);
+
+  $user   = $option{user};
+  $pass   = $option{password};
+  $server  = $option{server};
+  $port   = $self->_get_port($option{port});
+  $timeout = $option{timeout};
+
+  $self->{server} = $server;
+  $self->{port} = $port;
+
+  if($server =~ m/([^:]+):(\d+)/) {
+    $server = $self->{server} = $1;
+    $port  = $self->{port}  = $2;
+  }
+
+  $self->{__user} = $user;
+  $self->{__pass} = $pass;
+
+  if( ! Rex::Config->has_user && Rex::Config->get_ssh_config_username(server => $server) ) {
+    $user = Rex::Config->get_ssh_config_username(server => $server);
+  }
+
+  $self->ua->credentials(
+    "$server:$port",
+    "Rex::Endpoint::HTTP",
+    $user => $pass,
+  );
+
+  my $resp = $self->post("/login");
+  if($resp->{ok}) {
+    Rex::Logger::info("Connected to $server, trying to authenticate.");
+  }
+  else {
+    Rex::Logger::info("Can't connect to $server", "warn");
+    $self->{connected} = 0;
+    return;
+  }
+
+  Rex::Logger::info("Connecting to $server:$port (" . $user . ")");
 
 }
 
@@ -82,75 +82,75 @@ sub is_connected { return 1; };
 sub is_authenticated { return 1; };
 
 sub exec {
-   my ($self, $cmd) = @_;
+  my ($self, $cmd) = @_;
 }
 
 sub ua { 
-   my ($self) = @_;
-   return $self->{ua} if $self->{ua};
+  my ($self) = @_;
+  return $self->{ua} if $self->{ua};
 
-   $self->{ua} = LWP::UserAgent->new;
+  $self->{ua} = LWP::UserAgent->new;
 }
 
 sub upload {
-   my ($self, $data) = @_;
-
-   my $res = $self->ua->post($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "/fs/upload",
-               Content_Type => "multipart/form-data",
-               Content => $data);
-
-   if($res->is_success) {
-      return decode_json($res->decoded_content);
-   }
-   else {
-      die("Error requesting /fs/upload.");
-   }
+  my ($self, $data) = @_;
+
+  my $res = $self->ua->post($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "/fs/upload",
+          Content_Type => "multipart/form-data",
+          Content => $data);
+
+  if($res->is_success) {
+    return decode_json($res->decoded_content);
+  }
+  else {
+    die("Error requesting /fs/upload.");
+  }
 }
 
 sub post {
-   my ($self, $service, $data, $header) = @_;
+  my ($self, $service, $data, $header) = @_;
 
-   $header ||= {};
-   $data ||= {};
+  $header ||= {};
+  $data ||= {};
 
-   if(! ref($data)) {
-      die("Invalid 2nd argument. must be arrayRef or hashRef!\npost(\$service, \$ref)");
-   }
+  if(! ref($data)) {
+    die("Invalid 2nd argument. must be arrayRef or hashRef!\npost(\$service, \$ref)");
+  }
 
-   my $res = $self->ua->post($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "$service", %{$header}, Content => encode_json($data));
+  my $res = $self->ua->post($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "$service", %{$header}, Content => encode_json($data));
 
-   if($res->is_success) {
-      return decode_json($res->decoded_content);
-   }
-   else {
-      die("Error requesting $service.\n\nError: " . $res->{_content});
-   }
+  if($res->is_success) {
+    return decode_json($res->decoded_content);
+  }
+  else {
+    die("Error requesting $service.\n\nError: " . $res->{_content});
+  }
 
 }
 
 sub get {
-   my ($self, $service) = @_;
+  my ($self, $service) = @_;
 
-   my $res = $self->ua->get($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "$service");
+  my $res = $self->ua->get($self->_get_proto . "://" . $self->{server} . ":" . $self->{port} . "$service");
 
-   if($res->is_success) {
-      return decode_json($res->decoded_content);
-   }
-   else {
-      die("Error requesting $service.");
-   }
+  if($res->is_success) {
+    return decode_json($res->decoded_content);
+  }
+  else {
+    die("Error requesting $service.");
+  }
 
 }
 
 sub get_connection_type { return "HTTP"; }
 
 sub _get_proto {
-   return "http";
+  return "http";
 }
 
 sub _get_port {
-   my ($self, $port) = @_;
-   return $port || 8080;
+  my ($self, $port) = @_;
+  return $port || 8080;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::HTTPS;
 
 
@@ -13,54 +13,54 @@ use base qw(Rex::Interface::Connection::HTTP);
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 
 sub get_connection_type { return "HTTP"; }
 
 sub _get_proto {
-   return "https";
+  return "https";
 }
 
 sub _get_port {
-   my ($self, $port) = @_;
-   return $port || 8443;
+  my ($self, $port) = @_;
+  return $port || 8443;
 }
 
 sub ua { 
-   my ($self) = @_;
-   return $self->{ua} if $self->{ua};
-
-   my $ssl_opts = {};
-
-   if(Rex::Config->get_ca) {
-      Rex::Logger::debug("SSL: Verifying Hostname");
-      $ssl_opts->{verify_hostname} = 1;
-      $ssl_opts->{SSL_ca_file} = Rex::Config->get_ca;
-   }
-   else {
-      Rex::Logger::debug("SSL: NOT Verifying Hostname");
-      $ssl_opts->{verify_hostname} = 0;
-   }
-
-   if(Rex::Config->get_ca_cert) {
-      $ssl_opts->{SSL_cert_file} = Rex::Config->get_ca_cert;
-   }
-
-   if(Rex::Config->get_ca_key) {
-      $ssl_opts->{SSL_key_file} = Rex::Config->get_ca_key;
-   }
-
-   $self->{ua} = LWP::UserAgent->new(
-      ssl_opts => $ssl_opts,
-   );
+  my ($self) = @_;
+  return $self->{ua} if $self->{ua};
+
+  my $ssl_opts = {};
+
+  if(Rex::Config->get_ca) {
+    Rex::Logger::debug("SSL: Verifying Hostname");
+    $ssl_opts->{verify_hostname} = 1;
+    $ssl_opts->{SSL_ca_file} = Rex::Config->get_ca;
+  }
+  else {
+    Rex::Logger::debug("SSL: NOT Verifying Hostname");
+    $ssl_opts->{verify_hostname} = 0;
+  }
+
+  if(Rex::Config->get_ca_cert) {
+    $ssl_opts->{SSL_cert_file} = Rex::Config->get_ca_cert;
+  }
+
+  if(Rex::Config->get_ca_key) {
+    $ssl_opts->{SSL_key_file} = Rex::Config->get_ca_key;
+  }
+
+  $self->{ua} = LWP::UserAgent->new(
+    ssl_opts => $ssl_opts,
+  );
 }
 
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::Local;
-   
+  
 use strict;
 use warnings;
 
@@ -15,15 +15,15 @@ use Rex::Group::Entry::Server;
 use base qw(Rex::Interface::Connection::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   $self->{server} = Rex::Group::Entry::Server->new(name => "<local>");
+  $self->{server} = Rex::Group::Entry::Server->new(name => "<local>");
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub error { };
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Connection::OpenSSH;
-   
+
 use strict;
 use warnings;
 
@@ -15,167 +15,169 @@ use Net::OpenSSH;
 use base qw(Rex::Interface::Connection::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub connect {
-   my ($self, %option) = @_;
-
-   my ($user, $pass, $private_key, $public_key, $server, $port, $timeout, $auth_type, $is_sudo);
+  my ( $self, %option ) = @_;
 
-   Rex::Logger::debug("Using Net::OpenSSH for connection");
+  my (
+    $user, $pass,    $private_key, $public_key, $server,
+    $port, $timeout, $auth_type,   $is_sudo
+  );
 
-   $user    = $option{user};
-   $pass    = $option{password};
-   $server  = $option{server};
-   $port    = $option{port};
-   $timeout = $option{timeout};
-   $public_key = $option{public_key};
-   $private_key = $option{private_key};
-   $auth_type   = $option{auth_type};
-   $is_sudo     = $option{sudo};
+  Rex::Logger::debug("Using Net::OpenSSH for connection");
 
-   $self->{is_sudo} = $is_sudo;
+  $user        = $option{user};
+  $pass        = $option{password};
+  $server      = $option{server};
+  $port        = $option{port};
+  $timeout     = $option{timeout};
+  $public_key  = $option{public_key};
+  $private_key = $option{private_key};
+  $auth_type   = $option{auth_type};
+  $is_sudo     = $option{sudo};
 
-   $self->{__auth_info__} = \%option;
+  $self->{is_sudo} = $is_sudo;
 
-   Rex::Logger::debug("Using user: " . $user);
-   Rex::Logger::debug("Using password: " . ($pass?"***********":"<no password>"));
+  $self->{__auth_info__} = \%option;
 
-   $self->{server} = $server;
+  Rex::Logger::debug( "Using user: " . $user );
+  Rex::Logger::debug(
+    "Using password: " . ( $pass ? "***********" : "<no password>" ) );
 
+  $self->{server} = $server;
 
-   my $fail_connect = 0;
+  my $fail_connect = 0;
 
-   $port    ||= Rex::Config->get_port(server => $server) || 22;
-   $timeout ||= Rex::Config->get_timeout(server => $server) || 3;
+  $port ||= Rex::Config->get_port( server => $server ) || 22;
+  $timeout ||= Rex::Config->get_timeout( server => $server ) || 3;
 
-   $server  = Rex::Config->get_ssh_config_hostname(server => $server) || $server;
+  $server =
+    Rex::Config->get_ssh_config_hostname( server => $server ) || $server;
 
-   if($server =~ m/^(.*?):(\d+)$/) {
-      $server = $1;
-      $port   = $2;
-   }
-   Rex::Logger::info("Connecting to $server:$port (" . $user . ")");
+  if ( $server =~ m/^(.*?):(\d+)$/ ) {
+    $server = $1;
+    $port   = $2;
+  }
+  Rex::Logger::info( "Connecting to $server:$port (" . $user . ")" );
 
-   my %ssh_opts = Rex::Config->get_openssh_opt();
-   my $ssh_opts_line = "";
+  my %ssh_opts = Rex::Config->get_openssh_opt();
+  my @ssh_opts_line;
 
-   for my $key (keys %ssh_opts) {
-      $ssh_opts_line .= $key . "=" . $ssh_opts{$key} . " ";
-   }
+  for my $key ( keys %ssh_opts ) {
+    push @ssh_opts_line, "-o" => $key . "=" . $ssh_opts{$key};
+  }
 
-   my @connection_props = ($server, user => $user, port => $port);
-   push @connection_props, master_opts => [
-                              -o => $ssh_opts_line,
-                           ] if $ssh_opts_line;
-   push @connection_props, default_ssh_opts => [
-                              -o => $ssh_opts_line,
-                           ] if $ssh_opts_line;
+  my @connection_props = ( $server, user => $user, port => $port );
+  push @connection_props, master_opts      => \@ssh_opts_line if @ssh_opts_line;
+  push @connection_props, default_ssh_opts => \@ssh_opts_line if @ssh_opts_line;
 
-   if($auth_type && $auth_type eq "pass") {
-      Rex::Logger::debug("OpenSSH: pass_auth: $server:$port - $user - ******");
-      push @connection_props, password => $pass;
-   }
-   elsif($auth_type && $auth_type eq "krb5") {
-      Rex::Logger::debug("OpenSSH: krb5_auth: $server:$port - $user");
-      # do nothing here
-   }
-   else { # for key auth, and others
-      Rex::Logger::debug("OpenSSH: key_auth or not defined: $server:$port - $user");
-      push @connection_props, key_path => $private_key;
-      if($pass) {
-         push @connection_props, passphrase => $pass;
-      }
-   }
+  if ( $auth_type && $auth_type eq "pass" ) {
+    Rex::Logger::debug("OpenSSH: pass_auth: $server:$port - $user - ******");
+    push @connection_props, password => $pass;
+  }
+  elsif ( $auth_type && $auth_type eq "krb5" ) {
+    Rex::Logger::debug("OpenSSH: krb5_auth: $server:$port - $user");
 
-   $self->{ssh} = Net::OpenSSH->new(@connection_props);
+    # do nothing here
+  }
+  else {    # for key auth, and others
+    Rex::Logger::debug(
+      "OpenSSH: key_auth or not defined: $server:$port - $user");
+    push @connection_props, key_path => $private_key;
+    if ($pass) {
+      push @connection_props, passphrase => $pass;
+    }
+  }
 
-   if($self->{ssh} && $self->{ssh}->error) {
-      Rex::Logger::info("Can't connect to $server (" . $self->{ssh}->error() . ")", "warn");
-      $self->{connected} = 0;
+  $self->{ssh} = Net::OpenSSH->new(@connection_props);
 
-      return;
-   }
+  if ( $self->{ssh} && $self->{ssh}->error ) {
+    Rex::Logger::info(
+      "Can't connect to $server (" . $self->{ssh}->error() . ")", "warn" );
+    $self->{connected} = 0;
 
+    return;
+  }
 
-   if(! $self->{ssh}) {
-      Rex::Logger::info("Can't connect to $server", "warn");
-      $self->{connected} = 0;
+  if ( !$self->{ssh} ) {
+    Rex::Logger::info( "Can't connect to $server", "warn" );
+    $self->{connected} = 0;
 
-      return;
-   }
+    return;
+  }
 
-   Rex::Logger::debug("Current Error-Code: " . $self->{ssh}->error());
-   Rex::Logger::info("Connected and authenticated to $server.");
+  Rex::Logger::debug( "Current Error-Code: " . $self->{ssh}->error() );
+  Rex::Logger::info("Connected and authenticated to $server.");
 
-   $self->{connected} = 1;
-   $self->{auth_ret}  = 1;
+  $self->{connected} = 1;
+  $self->{auth_ret}  = 1;
 
-   $self->{sftp} = $self->{ssh}->sftp;
+  $self->{sftp} = $self->{ssh}->sftp;
 }
 
 sub reconnect {
-   my ($self) = @_;
-   Rex::Logger::debug("Reconnecting SSH");
+  my ($self) = @_;
+  Rex::Logger::debug("Reconnecting SSH");
 
-   $self->connect(%{ $self->{__auth_info__} });
+  $self->connect( %{ $self->{__auth_info__} } );
 }
 
 sub disconnect {
-   my ($self) = @_;
-   undef $self->{ssh};
-   return 1;
+  my ($self) = @_;
+  undef $self->{ssh};
+  return 1;
 }
 
 sub error {
-   my ($self) = @_;
-   return $self->get_connection_object->error;
+  my ($self) = @_;
+  return $self->get_connection_object->error;
 }
 
 sub get_connection_object {
-   my ($self) = @_;
-   return $self->{ssh};
+  my ($self) = @_;
+  return $self->{ssh};
 }
 
 sub get_fs_connection_object {
-   my ($self) = @_;
-   return $self->{sftp};
+  my ($self) = @_;
+  return $self->{sftp};
 }
 
 sub is_connected {
-   my ($self) = @_;
-   return $self->{connected};
+  my ($self) = @_;
+  return $self->{connected};
 }
 
 sub is_authenticated {
-   my ($self) = @_;
-   return $self->{auth_ret};
+  my ($self) = @_;
+  return $self->{auth_ret};
 }
 
 sub get_connection_type {
-   my ($self) = @_;
-
-   my $type = "OpenSSH";
-
-   if($self->{is_sudo} && $self->{is_sudo} == 1) {
-      return "Sudo";
-   }
-
-   if(Rex::is_ssh() && ! Rex::is_sudo()) {
-      $type = "OpenSSH";
-   }
-   elsif(Rex::is_sudo()) {
-      $type = "Sudo";
-   }
- 
-   return $type;
+  my ($self) = @_;
+
+  my $type = "OpenSSH";
+
+  if ( $self->{is_sudo} && $self->{is_sudo} == 1 ) {
+    return "Sudo";
+  }
+
+  if ( Rex::is_ssh() && !Rex::is_sudo() ) {
+    $type = "OpenSSH";
+  }
+  elsif ( Rex::is_sudo() ) {
+    $type = "Sudo";
+  }
+
+  return $type;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection::SSH;
-   
+  
 use strict;
 use warnings;
 
@@ -14,162 +14,162 @@ use Rex::Interface::Connection::Base;
 use base qw(Rex::Interface::Connection::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub connect {
-   my ($self, %option) = @_;
+  my ($self, %option) = @_;
 
-   my ($user, $pass, $private_key, $public_key, $server, $port, $timeout, $auth_type, $is_sudo);
+  my ($user, $pass, $private_key, $public_key, $server, $port, $timeout, $auth_type, $is_sudo);
 
-   Rex::Logger::debug("Using Net::SSH2 for connection");
+  Rex::Logger::debug("Using Net::SSH2 for connection");
 
-   $user    = $option{user};
-   $pass    = $option{password};
-   $server  = $option{server};
-   $port    = $option{port};
-   $timeout = $option{timeout};
-   $public_key = $option{public_key};
-   $private_key = $option{private_key};
-   $auth_type   = $option{auth_type};
-   $is_sudo     = $option{sudo};
+  $user   = $option{user};
+  $pass   = $option{password};
+  $server  = $option{server};
+  $port   = $option{port};
+  $timeout = $option{timeout};
+  $public_key = $option{public_key};
+  $private_key = $option{private_key};
+  $auth_type  = $option{auth_type};
+  $is_sudo    = $option{sudo};
 
-   $self->{is_sudo} = $is_sudo;
+  $self->{is_sudo} = $is_sudo;
 
-   $self->{__auth_info__} = \%option;
+  $self->{__auth_info__} = \%option;
 
-   Rex::Logger::debug("Using user: " . $user);
-   Rex::Logger::debug("Using password: " . ($pass?"***********":"<no password>"));
+  Rex::Logger::debug("Using user: " . $user);
+  Rex::Logger::debug("Using password: " . ($pass?"***********":"<no password>"));
 
-   $self->{server} = $server;
+  $self->{server} = $server;
 
-   $self->{ssh} = Net::SSH2->new;
+  $self->{ssh} = Net::SSH2->new;
 
-   my $fail_connect = 0;
+  my $fail_connect = 0;
 
-   CON_SSH:
-      $port    ||= Rex::Config->get_port(server => $server) || 22;
-      $timeout ||= Rex::Config->get_timeout(server => $server) || 3;
+  CON_SSH:
+    $port   ||= Rex::Config->get_port(server => $server) || 22;
+    $timeout ||= Rex::Config->get_timeout(server => $server) || 3;
 
-      $server  = Rex::Config->get_ssh_config_hostname(server => $server) || $server;
+    $server  = Rex::Config->get_ssh_config_hostname(server => $server) || $server;
 
-      if($server =~ m/^(.*?):(\d+)$/) {
-         $server = $1;
-         $port   = $2;
-      }
-      Rex::Logger::info("Connecting to $server:$port (" . $user . ")");
-      unless($self->{ssh}->connect($server, $port, Timeout => $timeout)) {
-         ++$fail_connect;
-         sleep 1;
-         goto CON_SSH if($fail_connect < Rex::Config->get_max_connect_fails(server => $server)); # try connecting 3 times
+    if($server =~ m/^(.*?):(\d+)$/) {
+      $server = $1;
+      $port  = $2;
+    }
+    Rex::Logger::info("Connecting to $server:$port (" . $user . ")");
+    unless($self->{ssh}->connect($server, $port, Timeout => $timeout)) {
+      ++$fail_connect;
+      sleep 1;
+      goto CON_SSH if($fail_connect < Rex::Config->get_max_connect_fails(server => $server)); # try connecting 3 times
 
-         Rex::Logger::info("Can't connect to $server", "warn");
+      Rex::Logger::info("Can't connect to $server", "warn");
 
-         $self->{connected} = 0;
+      $self->{connected} = 0;
 
-         return;
-      }
+      return;
+    }
 
-   Rex::Logger::debug("Current Error-Code: " . $self->{ssh}->error());
-   Rex::Logger::info("Connected to $server, trying to authenticate.");
+  Rex::Logger::debug("Current Error-Code: " . $self->{ssh}->error());
+  Rex::Logger::info("Connected to $server, trying to authenticate.");
 
-   $self->{connected} = 1;
+  $self->{connected} = 1;
 
-   if($auth_type && $auth_type eq "pass") {
-      Rex::Logger::debug("Using password authentication.");
-      $self->{auth_ret} = $self->{ssh}->auth_password($user, $pass);
-      if(! $self->{auth_ret}) {
-         # try guessing
-         $self->{auth_ret} = $self->{ssh}->auth(
-                                'username' => $user,
-                                'password' => $pass);
-
-      }
-   }
-   elsif($auth_type && $auth_type eq "key") {
-      Rex::Logger::debug("Using key authentication.");
-      $self->{auth_ret} = $self->{ssh}->auth_publickey($user,
-                              $public_key,
-                              $private_key,
-                              $pass);
-   }
-   else {
-      Rex::Logger::debug("Trying to guess the authentication method.");
+  if($auth_type && $auth_type eq "pass") {
+    Rex::Logger::debug("Using password authentication.");
+    $self->{auth_ret} = $self->{ssh}->auth_password($user, $pass);
+    if(! $self->{auth_ret}) {
+      # try guessing
       $self->{auth_ret} = $self->{ssh}->auth(
-                             'username' => $user,
-                             'password' => $pass,
-                             'publickey' => $public_key || "",
-                             'privatekey' => $private_key || "");
-   }
-
-   $self->{sftp} = $self->{ssh}->sftp;
+                      'username' => $user,
+                      'password' => $pass);
+
+    }
+  }
+  elsif($auth_type && $auth_type eq "key") {
+    Rex::Logger::debug("Using key authentication.");
+    $self->{auth_ret} = $self->{ssh}->auth_publickey($user,
+                    $public_key,
+                    $private_key,
+                    $pass);
+  }
+  else {
+    Rex::Logger::debug("Trying to guess the authentication method.");
+    $self->{auth_ret} = $self->{ssh}->auth(
+                    'username' => $user,
+                    'password' => $pass,
+                    'publickey' => $public_key || "",
+                    'privatekey' => $private_key || "");
+  }
+
+  $self->{sftp} = $self->{ssh}->sftp;
 }
 
 sub reconnect {
-   my ($self) = @_;
-   Rex::Logger::debug("Reconnecting SSH");
+  my ($self) = @_;
+  Rex::Logger::debug("Reconnecting SSH");
 
-   $self->connect(%{ $self->{__auth_info__} });
+  $self->connect(%{ $self->{__auth_info__} });
 }
 
 sub disconnect {
-   my ($self) = @_;
-   $self->get_connection_object->disconnect;
+  my ($self) = @_;
+  $self->get_connection_object->disconnect;
 }
 
 sub error {
-   my ($self) = @_;
-   return $self->get_connection_object->error;
+  my ($self) = @_;
+  return $self->get_connection_object->error;
 }
 
 sub get_connection_object {
-   my ($self) = @_;
-   return $self->{ssh};
+  my ($self) = @_;
+  return $self->{ssh};
 }
 
 sub get_fs_connection_object {
-   my ($self) = @_;
-   if(! defined $self->{sftp}) {
-      Rex::Logger::info("It seems that you haven't installed or configured sftp on your server.", "warn");
-      Rex::Logger::info("Rex needs sftp for file operations, so please install one.", "warn");
-      die("No SFTP server found on remote host.");
-   }
-   return $self->{sftp};
+  my ($self) = @_;
+  if(! defined $self->{sftp}) {
+    Rex::Logger::info("It seems that you haven't installed or configured sftp on your server.", "warn");
+    Rex::Logger::info("Rex needs sftp for file operations, so please install one.", "warn");
+    die("No SFTP server found on remote host.");
+  }
+  return $self->{sftp};
 }
 
 sub is_connected {
-   my ($self) = @_;
-   return $self->{connected};
+  my ($self) = @_;
+  return $self->{connected};
 }
 
 sub is_authenticated {
-   my ($self) = @_;
-   return $self->{auth_ret};
+  my ($self) = @_;
+  return $self->{auth_ret};
 }
 
 sub get_connection_type {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $type = "SSH";
+  my $type = "SSH";
 
-   if($self->{is_sudo} && $self->{is_sudo} == 1) {
-      return "Sudo";
-   }
+  if($self->{is_sudo} && $self->{is_sudo} == 1) {
+    return "Sudo";
+  }
 
-   if(Rex::is_ssh() && ! Rex::is_sudo()) {
-      $type = "SSH";
-   }
-   elsif(Rex::is_sudo()) {
-      $type = "Sudo";
-   }
+  if(Rex::is_ssh() && ! Rex::is_sudo()) {
+    $type = "SSH";
+  }
+  elsif(Rex::is_sudo()) {
+    $type = "Sudo";
+  }
  
-   return $type;
+  return $type;
 }
 
 1;
@@ -1,26 +1,26 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Connection;
-   
+  
 use strict;
 use warnings;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      $type = "SSH";
-   }
+  unless($type) {
+    $type = "SSH";
+  }
 
-   my $class_name = "Rex::Interface::Connection::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading connection interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::Connection::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading connection interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 }
 
 1;
@@ -1,24 +1,24 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::Base;
-   
+
 use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
-sub exec { die("Must be implemented by Interface Class"); };
+sub exec { die("Must be implemented by Interface Class"); }
 
 1;
@@ -1,70 +1,71 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::HTTP;
-   
+
 use strict;
 use warnings;
 use Rex::Commands;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub exec {
-   my ($self, $cmd, $path, $option) = @_;
+  my ( $self, $cmd, $path, $option ) = @_;
 
-   Rex::Logger::debug("Executing: $cmd");
+  Rex::Logger::debug("Executing: $cmd");
 
-   if(exists $option->{path}) {
-      $path = $option->{path};
-   }
+  if ( exists $option->{path} ) {
+    $path = $option->{path};
+  }
 
-   if($path) { $path = "PATH=$path" }
-   $path ||= "";
+  if ($path) { $path = "PATH=$path" }
+  $path ||= "";
 
-   # let the other side descide if LC_ALL=C should be used
-   # for example, this will not work on windows
-   #$cmd = "LC_ALL=C $path " . $cmd;
+  # let the other side descide if LC_ALL=C should be used
+  # for example, this will not work on windows
+  #$cmd = "LC_ALL=C $path " . $cmd;
 
-   Rex::Commands::profiler()->start("exec: $cmd");
+  Rex::Commands::profiler()->start("exec: $cmd");
 
-   my $new_cmd = $cmd;
-   if(Rex::Config->get_source_global_profile) {
-      $new_cmd = ". /etc/profile >/dev/null 2>&1; $new_cmd";
-   }
+  my $new_cmd = $cmd;
+  if ( Rex::Config->get_source_global_profile ) {
+    $new_cmd = ". /etc/profile >/dev/null 2>&1; $new_cmd";
+  }
 
-   my $resp = connection->post("/execute", {exec => $new_cmd, options => $option});
-   Rex::Commands::profiler()->end("exec: $cmd");
+  my $resp =
+    connection->post( "/execute", { exec => $new_cmd, options => $option } );
+  Rex::Commands::profiler()->end("exec: $cmd");
 
-   if($resp->{ok}) {
-      $? = $resp->{retval};
-      my ($out, $err) =  ($resp->{output}, "");
+  if ( $resp->{ok} ) {
+    $? = $resp->{retval};
+    my ( $out, $err ) = ( $resp->{output}, "" );
 
-      Rex::Logger::debug($out);
+    Rex::Logger::debug($out);
 
-      if($err) {
-         Rex::Logger::debug("========= ERR ============");
-         Rex::Logger::debug($err);
-         Rex::Logger::debug("========= ERR ============");
-      }
+    if ($err) {
+      Rex::Logger::debug("========= ERR ============");
+      Rex::Logger::debug($err);
+      Rex::Logger::debug("========= ERR ============");
+    }
 
-      if(wantarray) { return ($out, $err); }
+    if (wantarray) { return ( $out, $err ); }
 
-      return $out;
-   }
-   else {
-      $? = 1;
-   }
+    return $out;
+  }
+  else {
+    $? = 1;
+  }
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::Local;
-   
+
 use strict;
 use warnings;
 
@@ -16,88 +16,108 @@ use Symbol 'gensym';
 use IPC::Open3;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
+
+  bless( $self, $proto );
 
-   bless($self, $proto);
+  return $self;
+}
+
+sub set_env {
+  my ( $self, $env ) = @_;
+  my $cmd = undef;
 
-   return $self;
+  die("Error: env must be a hash")
+    if ( ref $env ne "HASH" );
+
+  while ( my ( $k, $v ) = each(%$env) ) {
+    $cmd .= "export $k='$v'; ";
+  }
+  $self->{env} = $cmd;
 }
 
 sub exec {
-   my ($self, $cmd, $path, $option) = @_;
+  my ( $self, $cmd, $path, $option ) = @_;
+
+  my ( $out, $err );
 
+  if ( exists $option->{cwd} ) {
+    $cmd = "cd " . $option->{cwd} . " && $cmd";
+  }
 
-   my ($out, $err);
+  if ( exists $option->{path} ) {
+    $path = $option->{path};
+  }
 
-   if(exists $option->{cwd}) {
-      $cmd = "cd " . $option->{cwd} . " && $cmd";
-   }
+  if ( exists $option->{env} ) {
+    $self->set_env( $option->{env} );
+  }
 
-   if(exists $option->{path}) {
-      $path = $option->{path};
-   }
+  if ( exists $option->{format_cmd} ) {
+    $option->{format_cmd} =~ s/{{CMD}}/$cmd/;
+    $cmd = $option->{format_cmd};
+  }
 
-   if(exists $option->{format_cmd}) {
-      $option->{format_cmd} =~ s/{{CMD}}/$cmd/;
-      $cmd = $option->{format_cmd};
-   }
+  Rex::Commands::profiler()->start("exec: $cmd");
+  if ( $^O !~ m/^MSWin/ ) {
+    if ($path) { $path = "PATH=$path" }
+    $path ||= "";
 
-   Rex::Logger::debug("Executing: $cmd");
+    my $new_cmd = "LC_ALL=C $cmd";
+    if ($path) {
+      $new_cmd = "export $path ; $new_cmd";
+    }
 
-   Rex::Commands::profiler()->start("exec: $cmd");
-   if($^O !~ m/^MSWin/) {
-      if($path) { $path = "PATH=$path" }
-      $path ||= "";
+    if ( $self->{env} ) {
+      $new_cmd = $self->{env} . " $new_cmd";
+    }
 
-      my $new_cmd = "LC_ALL=C $cmd";
-      if($path) {
-         $new_cmd = "export $path ; $new_cmd";
-      }
+    if ( Rex::Config->get_source_global_profile ) {
+      $new_cmd = ". /etc/profile >/dev/null 2>&1; $new_cmd";
+    }
 
-      if(Rex::Config->get_source_global_profile) {
-         $new_cmd = ". /etc/profile >/dev/null 2>&1; $new_cmd";
-      }
+    $cmd = $new_cmd;
+  }
 
-      $cmd = $new_cmd;
-   }
+  Rex::Logger::debug("Executing: $cmd");
 
-   my($writer, $reader, $error);
-   $error = gensym;
+  my ( $writer, $reader, $error );
+  $error = gensym;
 
-   if(Rex::Config->get_no_tty) {
-      my $pid = open3($writer, $reader, $error, $cmd);
+  if ( Rex::Config->get_no_tty ) {
+    my $pid = open3( $writer, $reader, $error, $cmd );
 
-      while(my $output = <$reader>) {
-         $out .= $output;
-      }
+    while ( my $output = <$reader> ) {
+      $out .= $output;
+    }
 
-      while(my $errout = <$error>) {
-         $err .= $errout;
-      }
+    while ( my $errout = <$error> ) {
+      $err .= $errout;
+    }
 
-      waitpid($pid, 0) or die($!);
-   }
-   else {
-      $cmd .= " 2>&1";
-      $out = qx{$cmd};
-   }
+    waitpid( $pid, 0 ) or die($!);
+  }
+  else {
+    $cmd .= " 2>&1";
+    $out = qx{$cmd};
+  }
 
-   $? >>= 8;
+  $? >>= 8;
 
-   Rex::Logger::debug($out) if($out);
-   if($err) {
-      Rex::Logger::debug("========= ERR ============");
-      Rex::Logger::debug($err);
-      Rex::Logger::debug("========= ERR ============");
-   }
+  Rex::Logger::debug($out) if ($out);
+  if ($err) {
+    Rex::Logger::debug("========= ERR ============");
+    Rex::Logger::debug($err);
+    Rex::Logger::debug("========= ERR ============");
+  }
 
-   Rex::Commands::profiler()->end("exec: $cmd");
+  Rex::Commands::profiler()->end("exec: $cmd");
 
-   if(wantarray) { return ($out, $err); }
+  if (wantarray) { return ( $out, $err ); }
 
-   return $out;
+  return $out;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::OpenSSH;
-   
+
 use strict;
 use warnings;
 
@@ -16,24 +16,22 @@ use Rex::Interface::Exec::SSH;
 use base qw(Rex::Interface::Exec::SSH);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub _exec {
-   my ($self, $exec) = @_;
-   
-   my $ssh = Rex::is_ssh();
-   my ($out, $err) = $ssh->capture2($exec);
+  my ( $self, $exec ) = @_;
 
-   return ($out, $err);
+  my $ssh = Rex::is_ssh();
+  my ( $out, $err ) = $ssh->capture2($exec);
+
+  return ( $out, $err );
 }
 
 1;
-
-
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::SSH;
-   
+
 use strict;
 use warnings;
 
@@ -15,74 +15,106 @@ use Rex::Interface::Shell;
 require Rex::Commands;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
+}
+
+sub direct_exec {
+  my ($self, $exec, $option) = @_;
+
+  Rex::Commands::profiler()->start("direct_exec: $exec");
+
+  Rex::Logger::debug("SSH/executing: $exec");
+  my ( $out, $err ) = $self->_exec( $exec, $option );
+
+  Rex::Commands::profiler()->end("direct_exec: $exec");
+
+  Rex::Logger::debug($out) if ($out);
+  if ($err) {
+    Rex::Logger::debug("========= ERR ============");
+    Rex::Logger::debug($err);
+    Rex::Logger::debug("========= ERR ============");
+  }
+
+  if (wantarray) { return ( $out, $err ); }
+
+  return $out;
 }
 
 sub exec {
-   my ($self, $cmd, $path, $option) = @_;
+  my ( $self, $cmd, $path, $option ) = @_;
+
+  Rex::Logger::debug("Executing: $cmd");
 
-   Rex::Logger::debug("Executing: $cmd");
+  Rex::Commands::profiler()->start("exec: $cmd");
 
-   Rex::Commands::profiler()->start("exec: $cmd");
+  my $used_shell = $self->_get_shell();
 
-   my $used_shell = $self->_get_shell();
+  my $shell;
 
-   my $shell = Rex::Interface::Shell->create($used_shell);
+  if ( $option->{_force_sh} ) {
+    $shell = Rex::Interface::Shell->create("Sh");
+  }
+  else {
+    $shell = Rex::Interface::Shell->create($used_shell);
+  }
 
-   $shell->set_locale("C");
-   $shell->path($path);
+  $shell->set_locale("C");
+  $shell->path($path);
 
-   if(Rex::Config->get_source_global_profile) {
-       $shell->source_global_profile(1);
-   }
+  if ( Rex::Config->get_source_global_profile ) {
+    $shell->source_global_profile(1);
+  }
 
-   if(Rex::Config->get_source_profile) {
-       $shell->source_profile(1);
-   }
+  if ( Rex::Config->get_source_profile ) {
+    $shell->source_profile(1);
+  }
 
-   my $exec = $shell->exec($cmd, $option);
-   Rex::Logger::debug("SSH/executing: $exec");
-   my ($out, $err) = $self->_exec($exec, $option);
+  if(exists $option->{env}) {
+    $shell->set_environment($option->{env});
+  }
 
-   Rex::Commands::profiler()->end("exec: $cmd");
+  my $exec = $shell->exec( $cmd, $option );
+  Rex::Logger::debug("SSH/executing: $exec");
+  my ( $out, $err ) = $self->_exec( $exec, $option );
 
-   Rex::Logger::debug($out) if ($out);
-   if($err) {
-      Rex::Logger::debug("========= ERR ============");
-      Rex::Logger::debug($err);
-      Rex::Logger::debug("========= ERR ============");
-   }
+  Rex::Commands::profiler()->end("exec: $cmd");
 
-   if(wantarray) { return ($out, $err); }
+  Rex::Logger::debug($out) if ($out);
+  if ($err) {
+    Rex::Logger::debug("========= ERR ============");
+    Rex::Logger::debug($err);
+    Rex::Logger::debug("========= ERR ============");
+  }
 
-   return $out;
+  if (wantarray) { return ( $out, $err ); }
+
+  return $out;
 }
 
 sub _exec {
-   my ($self, $exec, $option) = @_;
+  my ( $self, $exec, $option ) = @_;
+
+  my $callback = $option->{continuous_read} || undef;
 
-   my $callback = $option->{continuous_read} || undef;
-   
-   my $ssh = Rex::is_ssh();
-   my ($out, $err) = net_ssh2_exec($ssh, $exec, $callback);
+  my $ssh = Rex::is_ssh();
+  my ( $out, $err ) = net_ssh2_exec( $ssh, $exec, $callback );
 
-   return ($out, $err);
+  return ( $out, $err );
 }
 
 sub _get_shell {
-   my ($self) = @_;
-
-   my ($shell_path) = $self->_exec("echo \$SHELL");
-   chomp $shell_path;
-   my $used_shell = basename($shell_path);
+  my ($self) = @_;
 
-   return $used_shell;
+  my ($shell_path) = $self->_exec("echo \$SHELL");
+  chomp $shell_path;
+  my $used_shell = basename($shell_path);
+  return $used_shell;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Exec::Sudo;
-   
+
 use strict;
 use warnings;
 
@@ -20,56 +20,62 @@ use Rex::Commands;
 use Rex::Helper::Path;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub exec {
-   my ($self, $cmd, $path, $option) = @_;
-
-   if(exists $option->{cwd}) {
-      $cmd = "cd " . $option->{cwd} . " && $cmd";
-   }
-
-   if(exists $option->{path}) {
-      $path = $option->{path};
-   }
-
-   my ($exec, $file);
-   if(my $ssh = Rex::is_ssh()) {
-      if(ref $ssh eq "Net::OpenSSH") {
-         $exec = Rex::Interface::Exec->create("OpenSSH");
-         $file = Rex::Interface::File->create("OpenSSH");
-      }
-      else {
-         $exec = Rex::Interface::Exec->create("SSH");
-         $file = Rex::Interface::File->create("SSH");
-      }
-   }
-   else {
-      $exec = Rex::Interface::Exec->create("Local");
-      $file = Rex::Interface::File->create("Local");
-   }
-
-   my $sudo_password = task->get_sudo_password;
-   my $enc_pw;
-   my $random_file = "";
-
-   Rex::Logger::debug("Sudo: Executing: $cmd");
-
-   if($sudo_password) {
-      my $random_string = get_random(length($sudo_password), 'a' .. 'z');
-      my $crypt = $sudo_password ^ $random_string;
-
-      $random_file = get_tmp_file;
-
-      $file->open('>', $random_file);
-      $file->write(<<EOF);
+  my ( $self, $cmd, $path, $option ) = @_;
+
+  if ( exists $option->{cwd} ) {
+    $cmd = "cd " . $option->{cwd} . " && $cmd";
+  }
+
+  if ( exists $option->{path} ) {
+    $path = $option->{path};
+  }
+
+  my ( $exec, $file, $shell );
+  if ( my $ssh = Rex::is_ssh() ) {
+    if ( ref $ssh eq "Net::OpenSSH" ) {
+      $exec = Rex::Interface::Exec->create("OpenSSH");
+      $file = Rex::Interface::File->create("OpenSSH");
+    }
+    else {
+      $exec = Rex::Interface::Exec->create("SSH");
+      $file = Rex::Interface::File->create("SSH");
+    }
+  }
+  else {
+    $exec = Rex::Interface::Exec->create("Local");
+    $file = Rex::Interface::File->create("Local");
+  }
+  $shell = Rex::Interface::Shell->create("Sh");    # we're using sh for sudo
+
+######## envs setzen. aber erst nachdem wir wissen ob wir sh forcen duerfen
+  # if(exists $option->{env}) {
+  #   $shell->set_environment($option->{env});
+  # }
+
+  my $sudo_password = task->get_sudo_password;
+  my $enc_pw;
+  my $random_file = "";
+
+  Rex::Logger::debug("Sudo: Executing: $cmd");
+
+  if ($sudo_password) {
+    my $random_string = get_random( length($sudo_password), 'a' .. 'z' );
+    my $crypt = $sudo_password ^ $random_string;
+
+    $random_file = get_tmp_file;
+
+    $file->open( '>', $random_file );
+    $file->write(<<EOF);
 #!/usr/bin/perl
 unlink \$0;
 
@@ -87,61 +93,105 @@ print "\\n"
 
 EOF
 
+    $file->close;
 
-      $file->close;
-
-
-      $enc_pw = Rex::Helper::Encode::url_encode($crypt);
-   }
-   else {
-      $enc_pw = "";
-   }
-
-   my $sudo_options = Rex::get_current_connection()->{sudo_options};
-   my $sudo_options_str = "";
-   if(exists $sudo_options->{user}) {
-      $sudo_options_str .= " -u " . $sudo_options->{user};
-   }
-
-   if(Rex::Config->get_sudo_without_locales()) {
-      Rex::Logger::debug("Using sudo without locales. If the locale is NOT C or en_US it will break many things!");
-      $option->{no_locales} = 1;
-   }
-
-   
-   if(Rex::Config->get_sudo_without_sh()) {
-      Rex::Logger::debug("Using sudo without sh will break things like file editing.");
-      $option->{no_sh} = 1;
-      if($enc_pw) {
-         $option->{format_cmd} = "perl $random_file '$enc_pw' | sudo $sudo_options_str -p '' -S {{CMD}}";
-      }
-      else {
-         $option->{format_cmd} = "sudo $sudo_options_str {{CMD}}";
-      }
-   }
-   else {
-      # escape some special shell things
-      $option->{preprocess_command} = sub {
-         my ($_cmd) = @_;
-         $_cmd =~ s/\\/\\\\/gms;
-         $_cmd =~ s/"/\\"/gms;
-         $_cmd =~ s/\$/\\\$/gms;
-
-         return $_cmd;
-      };
-
-      if($enc_pw) {
-         $option->{format_cmd} = "perl $random_file '$enc_pw' | sudo $sudo_options_str -p '' -S sh -c \"{{CMD}}\"";
-      }
-      else {
-         $option->{format_cmd} = "sudo $sudo_options_str -p '' -S sh -c \"{{CMD}}\"";
-      }
-
-   }
-
-   return $exec->exec($cmd, $path, $option);
-}
+    $enc_pw = Rex::Helper::Encode::url_encode($crypt);
+  }
+  else {
+    $enc_pw = "";
+  }
 
-1;
+  my $sudo_options     = Rex::get_current_connection()->{sudo_options};
+  my $sudo_options_str = "";
+  if ( exists $sudo_options->{user} ) {
+    $sudo_options_str .= " -u " . $sudo_options->{user};
+  }
+
+  if ( Rex::Config->get_sudo_without_locales() ) {
+    Rex::Logger::debug(
+      "Using sudo without locales. If the locale is NOT C or en_US it will break many things!"
+    );
+    $option->{no_locales} = 1;
+  }
+
+  my $sudo_command = "sudo $sudo_options_str -p '' -S";
+
+  if ( Rex::Config->get_sudo_without_sh() ) {
+    Rex::Logger::debug(
+      "Using sudo without sh will break things like file editing.");
+
+    # $option->{no_sh} = 1;
+    $shell->set_inner_shell(0);
+    $shell->set_sudo_env(1);
+
+    if ( exists $option->{env} ) {
+      $shell->set_environment( $option->{env} );
+    }
+
+    if ($enc_pw) {
+
+    # $option->{format_cmd} =
+    #   "perl $random_file '$enc_pw' | sudo $sudo_options_str -p '' -S {{CMD}}";
+      $sudo_command = "perl $random_file '$enc_pw' | $sudo_command";
+    }
+
+    # else {
+    #   $option->{format_cmd} = "sudo $sudo_options_str -p '' -S {{CMD}}";
+    # }
+  }
+  else {
+
+    $shell->set_locale("C");
+    $shell->path($path);
 
+    if ( Rex::Config->get_source_global_profile ) {
+      $shell->source_global_profile(1);
+    }
 
+    if ( Rex::Config->get_source_profile ) {
+      $shell->source_profile(1);
+    }
+
+    if ( exists $option->{env} ) {
+      $shell->set_environment( $option->{env} );
+    }
+
+    # escape some special shell things
+    # $option->{preprocess_command} = sub {
+    #   my ($_cmd) = @_;
+    #   $_cmd =~ s/\\/\\\\/gms;
+    #   $_cmd =~ s/"/\\"/gms;
+    #   $_cmd =~ s/\$/\\\$/gms;
+    # };
+
+    $shell->set_inner_shell(1);
+
+    # $cmd =~ s/\\/\\\\/gms;
+    # $cmd =~ s/"/\\"/gms;
+    # $cmd =~ s/\$/\\\$/gms;
+
+# Calling sudo with sh(1) in this case we don't need to respect current user shell, pass _force_sh flag to ssh layer
+# $option->{_force_sh} = 1;
+
+    if ($enc_pw) {
+      $sudo_command = "perl $random_file '$enc_pw' | $sudo_command";
+
+# $option->{format_cmd} =
+#   "perl $random_file '$enc_pw' | sudo $sudo_options_str -p '' -S sh -c \"{{CMD}}\"";
+    }
+
+    # else {
+    #   $option->{format_cmd} =
+    #     "sudo $sudo_options_str -p '' -S sh -c \"{{CMD}}\"";
+    # }
+  }
+
+  $option->{prepend_command} = $sudo_command;
+
+  my $real_exec = $shell->exec( $cmd, $option );
+  Rex::Logger::debug("sudo: exec: $real_exec");
+
+  return $exec->direct_exec( $real_exec, $option );
+}
+
+1;
@@ -1,28 +1,28 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Exec;
-   
+  
 use strict;
 use warnings;
 
 use Rex;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
-   }
+  unless($type) {
+    $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
+  }
 
-   my $class_name = "Rex::Interface::Exec::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading exec interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::Exec::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading exec interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 }
 
 1;
@@ -1,29 +1,29 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Executor::Base;
-   
+  
 use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub exec { die("Should be implemented by interface class."); }
 
 sub set_task {
-   my ($self, $task) = @_;
-   $self->{task} = $task;
+  my ($self, $task) = @_;
+  $self->{task} = $task;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Executor::Default;
-   
+  
 use strict;
 use warnings;
 
@@ -19,46 +19,46 @@ use base qw(Rex::Interface::Executor::Base);
 require Rex::Args;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub exec {
-   my ($self, $opts) = @_;
+  my ($self, $opts) = @_;
 
-   $opts ||= { Rex::Args->get };
+  $opts ||= { Rex::Args->get };
 
-   my $task = $self->{task};
+  my $task = $self->{task};
 
-   Rex::Logger::debug("Executing " . $task->name);
+  Rex::Logger::debug("Executing " . $task->name);
 
-   my $ret;
-   eval {
-      my $code = $task->code;
-      $ret = &$code($opts);
-   };
+  my $ret;
+  eval {
+    my $code = $task->code;
+    $ret = &$code($opts);
+  };
 
-   if($@) {
-      if(Rex::Output->get) {
-         Rex::Output->get->add($task->name, error => 1, msg => $@);
-      }
-      else {
-         Rex::Logger::info("Error executing task: $@", "error");
-         die($@);
-      }
-   }
-   else {
-      if(Rex::Output->get) {
-         Rex::Output->get->add($task->name);
-      }
-   }
+  if($@) {
+    if(Rex::Output->get) {
+      Rex::Output->get->add($task->name, error => 1, msg => $@);
+    }
+    else {
+      Rex::Logger::info("Error executing task: $@", "error");
+      die($@);
+    }
+  }
+  else {
+    if(Rex::Output->get) {
+      Rex::Output->get->add($task->name);
+    }
+  }
 
-   return $ret;
+  return $ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Interface::Executor;
@@ -12,17 +12,17 @@ use warnings;
 use Data::Dumper;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      $type = "Default";
-   }
+  unless($type) {
+    $type = "Default";
+  }
 
-   my $class_name = "Rex::Interface::Executor::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading file interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::Executor::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading file interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 
 }
 
@@ -1,23 +1,23 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::Base;
-   
+  
 use strict;
 use warnings;
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open  { die("Must be implemented by Interface Class."); }
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::HTTP;
-   
+  
 use strict;
 use warnings;
 
@@ -17,79 +17,79 @@ use Rex::Interface::File::Base;
 use base qw(Rex::Interface::File::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open {
-   my ($self, $mode, $file) = @_;
-
-   $self->{__file} = $file;
-   $self->{__current_pos} = 0;
-
-   if($mode eq ">>") {
-      my $fs = Rex::Interface::Fs->create;
-      eval {
-         my %stat = $fs->stat($file);
-         $self->{__current_pos} = $stat{size};
-      };
-   }
-
-   Rex::Logger::debug("Opening $file with mode: $mode");
-   my $resp = connection->post("/file/open", {path => $file, mode => $mode});
-   return $resp->{ok};
+  my ($self, $mode, $file) = @_;
+
+  $self->{__file} = $file;
+  $self->{__current_pos} = 0;
+
+  if($mode eq ">>") {
+    my $fs = Rex::Interface::Fs->create;
+    eval {
+      my %stat = $fs->stat($file);
+      $self->{__current_pos} = $stat{size};
+    };
+  }
+
+  Rex::Logger::debug("Opening $file with mode: $mode");
+  my $resp = connection->post("/file/open", {path => $file, mode => $mode});
+  return $resp->{ok};
 }
 
 sub read {
-   my ($self, $len) = @_;
+  my ($self, $len) = @_;
 
-   my $resp = connection->post("/file/read", {
-      path => $self->{__file},
-      start => $self->{__current_pos},
-      len => $len,
-   });
+  my $resp = connection->post("/file/read", {
+    path => $self->{__file},
+    start => $self->{__current_pos},
+    len => $len,
+  });
 
-   if($resp->{ok}) {
-      my $buf = decode_base64($resp->{buf});
-      $self->{__current_pos} += length($buf);
-      return $buf;
-   }
+  if($resp->{ok}) {
+    my $buf = decode_base64($resp->{buf});
+    $self->{__current_pos} += length($buf);
+    return $buf;
+  }
 
-   return;
+  return;
 }
 
 sub write {
-   my ($self, $buf) = @_;
+  my ($self, $buf) = @_;
 
-   my $resp = connection->post("/file/write_fh", {
-      path => $self->{__file},
-      start => $self->{__current_pos},
-      buf => encode_base64($buf),
-   });
+  my $resp = connection->post("/file/write_fh", {
+    path => $self->{__file},
+    start => $self->{__current_pos},
+    buf => encode_base64($buf),
+  });
 
-   if($resp->{ok}) {
-      $self->{__current_pos} += length($buf);
-      return length($buf);
-   }
+  if($resp->{ok}) {
+    $self->{__current_pos} += length($buf);
+    return length($buf);
+  }
 
-   return;
+  return;
 }
 
 sub seek {
-   my ($self, $pos) = @_;
-   $self->{__current_pos} = $pos;
+  my ($self, $pos) = @_;
+  $self->{__current_pos} = $pos;
 }
 
 sub close {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   delete $self->{__current_pos};
-   delete $self->{__file};
+  delete $self->{__current_pos};
+  delete $self->{__file};
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::Local;
-   
+  
 use strict;
 use warnings;
 
@@ -13,54 +13,54 @@ use Rex::Interface::File::Base;
 use base qw(Rex::Interface::File::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open {
-   my ($self, $mode, $file) = @_;
+  my ($self, $mode, $file) = @_;
 
-   Rex::Logger::debug("Opening $file with mode: $mode");
+  Rex::Logger::debug("Opening $file with mode: $mode");
 
-   open($self->{fh}, $mode, $file) or return;
+  open($self->{fh}, $mode, $file) or return;
 
-   return 1;
+  return 1;
 }
 
 sub read {
-   my ($self, $len) = @_;
+  my ($self, $len) = @_;
 
-   my $buf;
-   read($self->{fh}, $buf, $len);
-   return $buf;
+  my $buf;
+  read($self->{fh}, $buf, $len);
+  return $buf;
 }
 
 sub write {
-   my ($self, $buf) = @_;
+  my ($self, $buf) = @_;
 
-   my $fh = $self->{fh};
-   print $fh $buf;
+  my $fh = $self->{fh};
+  print $fh $buf;
 }
 
 sub seek {
-   my ($self, $pos) = @_;
+  my ($self, $pos) = @_;
 
-   my $fh = $self->{fh};
-   seek($fh, $pos, 0);
+  my $fh = $self->{fh};
+  seek($fh, $pos, 0);
 }
 
 sub close {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $fh = $self->{fh};
-   close $fh if $fh;
-   $self->{fh} = undef;
-   $self = undef;
+  my $fh = $self->{fh};
+  close $fh if $fh;
+  $self->{fh} = undef;
+  $self = undef;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::OpenSSH;
-   
+  
 use strict;
 use warnings;
 
@@ -16,61 +16,61 @@ use Net::SFTP::Foreign::Constants qw(:flags :fxp);
 use base qw(Rex::Interface::File::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open {
-   my ($self, $mode, $file) = @_;
+  my ($self, $mode, $file) = @_;
 
-   Rex::Logger::debug("Opening $file with mode: $mode");
+  Rex::Logger::debug("Opening $file with mode: $mode");
 
-   my $sftp = Rex::get_sftp();
-   if($mode eq ">") {
-      $self->{fh} = $sftp->open($file, SSH2_FXF_WRITE | SSH2_FXF_CREAT | SSH2_FXF_TRUNC );
-   }
-   elsif($mode eq ">>") {
-      $self->{fh} = $sftp->open($file,  SSH2_FXF_WRITE | SSH2_FXF_APPEND );
-      my $fs = Rex::Interface::Fs->create;
-      my %stat = $fs->stat($file);
-      $self->{fh}->seek($stat{size}, 0);
-   }
-   elsif($mode eq "<") {
-      $self->{fh} = $sftp->open($file, SSH2_FXF_READ);
-   }
+  my $sftp = Rex::get_sftp();
+  if($mode eq ">") {
+    $self->{fh} = $sftp->open($file, SSH2_FXF_WRITE | SSH2_FXF_CREAT | SSH2_FXF_TRUNC );
+  }
+  elsif($mode eq ">>") {
+    $self->{fh} = $sftp->open($file,  SSH2_FXF_WRITE | SSH2_FXF_APPEND );
+    my $fs = Rex::Interface::Fs->create;
+    my %stat = $fs->stat($file);
+    $self->{fh}->seek($stat{size}, 0);
+  }
+  elsif($mode eq "<") {
+    $self->{fh} = $sftp->open($file, SSH2_FXF_READ);
+  }
 
-   return $self->{fh};
+  return $self->{fh};
 }
 
 sub read {
-   my ($self, $len) = @_;
+  my ($self, $len) = @_;
 
-   my $sftp = Rex::get_sftp();
-   my $buf = $sftp->read($self->{fh}, $len);
-   return $buf;
+  my $sftp = Rex::get_sftp();
+  my $buf = $sftp->read($self->{fh}, $len);
+  return $buf;
 }
 
 sub write {
-   my ($self, $buf) = @_;
-   my $sftp = Rex::get_sftp();
-   $sftp->write($self->{fh}, $buf);
+  my ($self, $buf) = @_;
+  my $sftp = Rex::get_sftp();
+  $sftp->write($self->{fh}, $buf);
 }
 
 sub seek {
-   my ($self, $pos) = @_;
-   my $sftp = Rex::get_sftp();
-   $sftp->seek($self->{fh}, $pos, 0);
+  my ($self, $pos) = @_;
+  my $sftp = Rex::get_sftp();
+  $sftp->seek($self->{fh}, $pos, 0);
 }
 
 sub close {
-   my ($self) = @_;
-   my $sftp = Rex::get_sftp();
-   $sftp->close($self->{fh});
+  my ($self) = @_;
+  my $sftp = Rex::get_sftp();
+  $sftp->close($self->{fh});
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::SSH;
-   
+  
 use strict;
 use warnings;
 
@@ -15,59 +15,59 @@ use Rex::Interface::File::Base;
 use base qw(Rex::Interface::File::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open {
-   my ($self, $mode, $file) = @_;
+  my ($self, $mode, $file) = @_;
 
-   Rex::Logger::debug("Opening $file with mode: $mode");
+  Rex::Logger::debug("Opening $file with mode: $mode");
 
-   my $sftp = Rex::get_sftp();
-   if($mode eq ">") {
-      $self->{fh} = $sftp->open($file, O_WRONLY | O_CREAT | O_TRUNC );
-   }
-   elsif($mode eq ">>") {
-      $self->{fh} = $sftp->open($file, O_WRONLY | O_APPEND );
-      my $fs = Rex::Interface::Fs->create;
-      my %stat = $fs->stat($file);
-      $self->{fh}->seek($stat{size});
-   }
-   elsif($mode eq "<") {
-      $self->{fh} = $sftp->open($file, O_RDONLY);
-   }
+  my $sftp = Rex::get_sftp();
+  if($mode eq ">") {
+    $self->{fh} = $sftp->open($file, O_WRONLY | O_CREAT | O_TRUNC );
+  }
+  elsif($mode eq ">>") {
+    $self->{fh} = $sftp->open($file, O_WRONLY | O_APPEND );
+    my $fs = Rex::Interface::Fs->create;
+    my %stat = $fs->stat($file);
+    $self->{fh}->seek($stat{size});
+  }
+  elsif($mode eq "<") {
+    $self->{fh} = $sftp->open($file, O_RDONLY);
+  }
 
-   return $self->{fh};
+  return $self->{fh};
 }
 
 sub read {
-   my ($self, $len) = @_;
+  my ($self, $len) = @_;
 
-   my $buf;
-   $self->{fh}->read($buf, $len);
-   return $buf;
+  my $buf;
+  $self->{fh}->read($buf, $len);
+  return $buf;
 }
 
 sub write {
-   my ($self, $buf) = @_;
-   $self->{fh}->write($buf);
+  my ($self, $buf) = @_;
+  $self->{fh}->write($buf);
 }
 
 sub seek {
-   my ($self, $pos) = @_;
-   $self->{fh}->seek($pos);
+  my ($self, $pos) = @_;
+  $self->{fh}->seek($pos);
 }
 
 sub close {
-   my ($self) = @_;
-   $self->{fh} = undef;
-   $self = undef;
+  my ($self) = @_;
+  $self->{fh} = undef;
+  $self = undef;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File::Sudo;
-   
+  
 use strict;
 use warnings;
 
@@ -18,101 +18,101 @@ use Rex::Helper::Path;
 use base qw(Rex::Interface::File::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub open {
-   my ($self, $mode, $file) = @_;
-
-   if(my $ssh = Rex::is_ssh()) {
-      if(ref $ssh eq "Net::OpenSSH") {
-         $self->{fh} = Rex::Interface::File->create("OpenSSH");
+  my ($self, $mode, $file) = @_;
+
+  if(my $ssh = Rex::is_ssh()) {
+    if(ref $ssh eq "Net::OpenSSH") {
+      $self->{fh} = Rex::Interface::File->create("OpenSSH");
+    }
+    else {
+      $self->{fh} = Rex::Interface::File->create("SSH");
+    }
+  }
+  else {
+    $self->{fh} = Rex::Interface::File->create("Local");
+  }
+
+  $self->{mode} = $mode;
+  $self->{file} = $file;
+  $self->{rndfile} = get_tmp_file;
+  if($self->_fs->is_file($file)) {
+    # resolving symlinks
+    while(my $link = $self->_fs->readlink($file)) {
+      if($link !~ m/^\//) {
+        $file = dirname($file) . "/" . $link;
       }
       else {
-         $self->{fh} = Rex::Interface::File->create("SSH");
-      }
-   }
-   else {
-      $self->{fh} = Rex::Interface::File->create("Local");
-   }
-
-   $self->{mode} = $mode;
-   $self->{file} = $file;
-   $self->{rndfile} = get_tmp_file;
-   if($self->_fs->is_file($file)) {
-      # resolving symlinks
-      while(my $link = $self->_fs->readlink($file)) {
-         if($link !~ m/^\//) {
-            $file = dirname($file) . "/" . $link;
-         }
-         else {
-            $file = $link;
-         }
-         $link = $self->_fs->readlink($link);
+        $file = $link;
       }
-      $self->{file_stat} = { $self->_fs->stat($self->{file}) };
+      $link = $self->_fs->readlink($link);
+    }
+    $self->{file_stat} = { $self->_fs->stat($self->{file}) };
 
-      $self->_fs->cp($file, $self->{rndfile});
-      $self->_fs->chmod(600, $self->{rndfile});
-      $self->_fs->chown(Rex::Commands::connection->get_auth_user, $self->{rndfile});
-   }
+    $self->_fs->cp($file, $self->{rndfile});
+    $self->_fs->chmod(600, $self->{rndfile});
+    $self->_fs->chown(Rex::Commands::connection->get_auth_user, $self->{rndfile});
+  }
 
-   $self->{fh}->open($mode, $self->{rndfile});
+  $self->{fh}->open($mode, $self->{rndfile});
 
-   return $self->{fh};
+  return $self->{fh};
 }
 
 sub read {
-   my ($self, $len) = @_;
+  my ($self, $len) = @_;
 
-   return $self->{fh}->read($len);
+  return $self->{fh}->read($len);
 }
 
 sub write {
-   my ($self, $buf) = @_;
-   $self->{fh}->write($buf);
+  my ($self, $buf) = @_;
+  $self->{fh}->write($buf);
 }
 
 sub seek {
-   my ($self, $pos) = @_;
-   $self->{fh}->seek($pos);
+  my ($self, $pos) = @_;
+  $self->{fh}->seek($pos);
 }
 
 sub close {
-   my ($self) = @_;
-
-   return unless $self->{fh};
-
-   if(exists $self->{mode} && ( $self->{mode} eq ">" || $self->{mode} eq ">>") ) {
-      my $exec = Rex::Interface::Exec->create;
-      if($self->{file_stat}) {
-         my %stat = $self->_fs->stat($self->{file});
-         $self->_fs->chmod($stat{mode}, $self->{rndfile});
-         $self->_fs->chown($stat{uid}, $self->{rndfile});
-         $self->_fs->chgrp($stat{gid}, $self->{rndfile});
-      }
-      $self->_fs->rename($self->{rndfile}, $self->{file});
-
-      #$exec->exec("cat " . $self->{rndfile} . " >'" . $self->{file} . "'");
-   }
-   
-   $self->{fh}->close;
-   $self->{fh} = undef;
-   
-   $self->_fs->unlink($self->{rndfile});
-
-   $self = undef;
+  my ($self) = @_;
+
+  return unless $self->{fh};
+
+  if(exists $self->{mode} && ( $self->{mode} eq ">" || $self->{mode} eq ">>") ) {
+    my $exec = Rex::Interface::Exec->create;
+    if($self->{file_stat}) {
+      my %stat = $self->_fs->stat($self->{file});
+      $self->_fs->chmod($stat{mode}, $self->{rndfile});
+      $self->_fs->chown($stat{uid}, $self->{rndfile});
+      $self->_fs->chgrp($stat{gid}, $self->{rndfile});
+    }
+    $self->_fs->rename($self->{rndfile}, $self->{file});
+
+    #$exec->exec("cat " . $self->{rndfile} . " >'" . $self->{file} . "'");
+  }
+  
+  $self->{fh}->close;
+  $self->{fh} = undef;
+  
+  $self->_fs->unlink($self->{rndfile});
+
+  $self = undef;
 }
 
 sub _fs {
-   my ($self) = @_;
-   return Rex::Interface::Fs->create("Sudo");
+  my ($self) = @_;
+  return Rex::Interface::Fs->create("Sudo");
 }
 
 1;
@@ -1,38 +1,38 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::File;
-   
+  
 use strict;
 use warnings;
 
 use Rex;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      #$type = Rex::Commands::task()->get_connection_type;
-      $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
-      #if(Rex::is_ssh() && ! Rex::is_sudo()) {
-      #   $type = "SSH";
-      #}
-      #elsif(Rex::is_sudo()) {
-      #   $type = "Sudo";
-      #}
-      #else {
-      #   $type = "Local";
-      #}
-   }
+  unless($type) {
+    #$type = Rex::Commands::task()->get_connection_type;
+    $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
+    #if(Rex::is_ssh() && ! Rex::is_sudo()) {
+    #  $type = "SSH";
+    #}
+    #elsif(Rex::is_sudo()) {
+    #  $type = "Sudo";
+    #}
+    #else {
+    #  $type = "Local";
+    #}
+  }
 
-   my $class_name = "Rex::Interface::File::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading file interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::File::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading file interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 }
 
 1;
@@ -1,35 +1,35 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs::Base;
-   
+  
 use strict;
 use warnings;
 
 use Rex::Interface::Exec;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
-sub ls          { die("Must be implemented by Interface Class"); }
-sub unlink      { die("Must be implemented by Interface Class"); }
-sub mkdir       { die("Must be implemented by Interface Class"); }
-sub glob        { die("Must be implemented by Interface Class"); }
-sub rename      { die("Must be implemented by Interface Class"); }
-sub stat        { die("Must be implemented by Interface Class"); }
-sub readlink    { die("Must be implemented by Interface Class"); }
-sub is_file     { die("Must be implemented by Interface Class"); }
-sub is_dir      { die("Must be implemented by Interface Class"); }
+sub ls       { die("Must be implemented by Interface Class"); }
+sub unlink    { die("Must be implemented by Interface Class"); }
+sub mkdir     { die("Must be implemented by Interface Class"); }
+sub glob      { die("Must be implemented by Interface Class"); }
+sub rename    { die("Must be implemented by Interface Class"); }
+sub stat      { die("Must be implemented by Interface Class"); }
+sub readlink   { die("Must be implemented by Interface Class"); }
+sub is_file    { die("Must be implemented by Interface Class"); }
+sub is_dir    { die("Must be implemented by Interface Class"); }
 sub is_readable { die("Must be implemented by Interface Class"); }
 sub is_writable { die("Must be implemented by Interface Class"); }
 sub upload { die("Must be implemented by Interface Class"); }
@@ -37,95 +37,95 @@ sub download { die("Must be implemented by Interface Class"); }
 
 
 sub ln {
-   my ($self, $from, $to) = @_;
+  my ($self, $from, $to) = @_;
 
-   Rex::Logger::debug("Symlinking files: $to -> $from");
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("ln -snf '$from' '$to'");
+  Rex::Logger::debug("Symlinking files: $to -> $from");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("ln -snf '$from' '$to'");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 
 sub rmdir {
-   my ($self, @dirs) = @_;
+  my ($self, @dirs) = @_;
 
-   @dirs = $self->_normalize_path(@dirs);
+  @dirs = $self->_normalize_path(@dirs);
 
-   Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("/bin/rm -rf " . join(" ", @dirs));
+  Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("/bin/rm -rf " . join(" ", @dirs));
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub chown {
-   my ($self, $user, $file, @opts) = @_;
-   my $options = { @opts };
-   ($file) = $self->_normalize_path($file);
+  my ($self, $user, $file, @opts) = @_;
+  my $options = { @opts };
+  ($file) = $self->_normalize_path($file);
 
-   my $recursive = "";
-   if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
-      $recursive = " -R ";
-   }
+  my $recursive = "";
+  if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
+    $recursive = " -R ";
+  }
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("chown $recursive $user $file");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("chown $recursive $user $file");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub chgrp {
-   my ($self, $group, $file, @opts) = @_;
-   my $options = { @opts };
-   ($file) = $self->_normalize_path($file);
+  my ($self, $group, $file, @opts) = @_;
+  my $options = { @opts };
+  ($file) = $self->_normalize_path($file);
 
-   my $recursive = "";
-   if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
-      $recursive = " -R ";
-   }
+  my $recursive = "";
+  if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
+    $recursive = " -R ";
+  }
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("chgrp $recursive $group $file");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("chgrp $recursive $group $file");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub chmod {
-   my ($self, $mode, $file, @opts) = @_;
-   my $options = { @opts };
-   ($file) = $self->_normalize_path($file);
+  my ($self, $mode, $file, @opts) = @_;
+  my $options = { @opts };
+  ($file) = $self->_normalize_path($file);
 
-   my $recursive = "";
-   if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
-      $recursive = " -R ";
-   }
+  my $recursive = "";
+  if(exists $options->{"recursive"} && $options->{"recursive"} == 1) {
+    $recursive = " -R ";
+  }
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("chmod $recursive $mode $file");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("chmod $recursive $mode $file");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub cp {
-   my ($self, $source, $dest) = @_;
-   ($source) = $self->_normalize_path($source);
-   ($dest)   = $self->_normalize_path($dest);
+  my ($self, $source, $dest) = @_;
+  ($source) = $self->_normalize_path($source);
+  ($dest)  = $self->_normalize_path($dest);
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("cp -R $source $dest");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("cp -R $source $dest");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub _normalize_path {
-   my ($self, @dirs) = @_;
+  my ($self, @dirs) = @_;
 
-   for(@dirs) {
-      s/ /\\ /g;
-   }
+  for(@dirs) {
+    s/ /\\ /g;
+  }
 
-   return @dirs;
+  return @dirs;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs::HTTP;
-   
+  
 use strict;
 use warnings;
 
@@ -17,185 +17,185 @@ use MIME::Base64;
 use base qw(Rex::Interface::Fs::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub ls {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my $resp = connection->post("/fs/ls", {path => $path});
-   if($resp->{ok}) {
-      return @{ $resp->{ls} };
-   }
+  my $resp = connection->post("/fs/ls", {path => $path});
+  if($resp->{ok}) {
+    return @{ $resp->{ls} };
+  }
 }
 
 sub is_dir {
-   my ($self, $path) = @_;
-   my $resp = connection->post("/fs/is_dir", {path => $path});   
-   return $resp->{ok};
+  my ($self, $path) = @_;
+  my $resp = connection->post("/fs/is_dir", {path => $path});  
+  return $resp->{ok};
 }
 
 sub is_file {
-   my ($self, $file) = @_;
-   my $resp = connection->post("/fs/is_file", {path => $file});   
-   return $resp->{ok};
+  my ($self, $file) = @_;
+  my $resp = connection->post("/fs/is_file", {path => $file});  
+  return $resp->{ok};
 }
 
 sub unlink {
-   my ($self, @files) = @_;
-   
-   my $ok = 0;
-   for my $file (@files) {
-      my $resp = connection->post("/fs/unlink", {path => $file});   
-      $ok = $resp->{ok};
-   }
+  my ($self, @files) = @_;
+  
+  my $ok = 0;
+  for my $file (@files) {
+    my $resp = connection->post("/fs/unlink", {path => $file});  
+    $ok = $resp->{ok};
+  }
 
-   return $ok;
+  return $ok;
 }
 
 sub mkdir {
-   my ($self, $dir) = @_;
-   my $resp = connection->post("/fs/mkdir", {path => $dir});
-   return $resp->{ok};
+  my ($self, $dir) = @_;
+  my $resp = connection->post("/fs/mkdir", {path => $dir});
+  return $resp->{ok};
 }
 
 sub stat {
-   my ($self, $file) = @_;
-   my $resp = connection->post("/fs/stat", {path => $file});   
-   if($resp->{ok}) {
-      return %{ $resp->{stat} };
-   }
+  my ($self, $file) = @_;
+  my $resp = connection->post("/fs/stat", {path => $file});  
+  if($resp->{ok}) {
+    return %{ $resp->{stat} };
+  }
 }
 
 sub is_readable {
-   my ($self, $file) = @_;
-   my $resp = connection->post("/fs/is_readable", {path => $file});   
-   return $resp->{ok};
+  my ($self, $file) = @_;
+  my $resp = connection->post("/fs/is_readable", {path => $file});  
+  return $resp->{ok};
 }
 
 sub is_writable {
-   my ($self, $file) = @_;
-   my $resp = connection->post("/fs/is_writable", {path => $file});   
-   return $resp->{ok};
+  my ($self, $file) = @_;
+  my $resp = connection->post("/fs/is_writable", {path => $file});  
+  return $resp->{ok};
 }
 
 sub readlink {
-   my ($self, $file) = @_;
-   my $resp = connection->post("/fs/readlink", {path => $file});   
-   if($resp->{ok}) {
-      return $resp->{link};
-   }
+  my ($self, $file) = @_;
+  my $resp = connection->post("/fs/readlink", {path => $file});  
+  if($resp->{ok}) {
+    return $resp->{link};
+  }
 }
 
 sub rename {
-   my ($self, $old, $new) = @_;
-   my $resp = connection->post("/fs/rename", {old => $old, new => $new});   
-   return $resp->{ok};
+  my ($self, $old, $new) = @_;
+  my $resp = connection->post("/fs/rename", {old => $old, new => $new});  
+  return $resp->{ok};
 }
 
 sub glob {
-   my ($self, $glob) = @_;
-   my $resp = connection->post("/fs/glob", {glob => $glob});   
-   if($resp->{ok}) {
-      return @{ $resp->{glob} };
-   }
+  my ($self, $glob) = @_;
+  my $resp = connection->post("/fs/glob", {glob => $glob});  
+  if($resp->{ok}) {
+    return @{ $resp->{glob} };
+  }
 }
 
 sub upload {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   my $resp = connection->upload([content => [$source], path => $target]);
-   return $resp->{ok};
+  my $resp = connection->upload([content => [$source], path => $target]);
+  return $resp->{ok};
 }
 
 sub download {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   my $resp = connection->post("/fs/download", {path => $source});
-   if($resp->{ok}) {
-      open(my $fh, ">", $target) or die($!);
-      print $fh decode_base64($resp->{content});
-      close($fh);
+  my $resp = connection->post("/fs/download", {path => $source});
+  if($resp->{ok}) {
+    open(my $fh, ">", $target) or die($!);
+    print $fh decode_base64($resp->{content});
+    close($fh);
 
-      return 1;
-   }
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ln {
-   my ($self, $from, $to) = @_;
+  my ($self, $from, $to) = @_;
 
-   Rex::Logger::debug("Symlinking files: $to -> $from");
-   my $resp = connection->post("/fs/ln", {from => $from, to => $to});
-   return $resp->{ok};
+  Rex::Logger::debug("Symlinking files: $to -> $from");
+  my $resp = connection->post("/fs/ln", {from => $from, to => $to});
+  return $resp->{ok};
 }
 
 
 sub rmdir {
-   my ($self, @dirs) = @_;
+  my ($self, @dirs) = @_;
 
-   Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
-   my $ok = 0;
-   for my $dir (@dirs) {
-      my $resp = connection->post("/fs/rmdir", {path => $dir});
-      $ok = $resp->{ok};
-   }
+  Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
+  my $ok = 0;
+  for my $dir (@dirs) {
+    my $resp = connection->post("/fs/rmdir", {path => $dir});
+    $ok = $resp->{ok};
+  }
 
-   return $ok;
+  return $ok;
 }
 
 sub chown {
-   my ($self, $user, $file, @opts) = @_;
+  my ($self, $user, $file, @opts) = @_;
 
-   my $resp = connection->post("/fs/chown", {
-      user => $user,
-      path => $file,
-      options => { @opts },
-   });
+  my $resp = connection->post("/fs/chown", {
+    user => $user,
+    path => $file,
+    options => { @opts },
+  });
 
-   return $resp->{ok};
+  return $resp->{ok};
 }
 
 sub chgrp {
-   my ($self, $group, $file, @opts) = @_;
+  my ($self, $group, $file, @opts) = @_;
 
-   my $resp = connection->post("/fs/chgrp", {
-      group => $group,
-      path => $file,
-      options => { @opts },
-   });
+  my $resp = connection->post("/fs/chgrp", {
+    group => $group,
+    path => $file,
+    options => { @opts },
+  });
 
-   return $resp->{ok};
+  return $resp->{ok};
 }
 
 sub chmod {
-   my ($self, $mode, $file, @opts) = @_;
+  my ($self, $mode, $file, @opts) = @_;
 
-   my $resp = connection->post("/fs/chmod", {
-      mode => $mode,
-      path => $file,
-      options => { @opts },
-   });
+  my $resp = connection->post("/fs/chmod", {
+    mode => $mode,
+    path => $file,
+    options => { @opts },
+  });
 
-   return $resp->{ok};
+  return $resp->{ok};
 }
 
 sub cp {
-   my ($self, $source, $dest) = @_;
+  my ($self, $source, $dest) = @_;
 
-   my $resp = connection->post("/fs/cp", {
-      source => $source,
-      dest => $dest,
-   });
+  my $resp = connection->post("/fs/cp", {
+    source => $source,
+    dest => $dest,
+  });
 
-   return $resp->{ok};
+  return $resp->{ok};
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs::Local;
-   
+  
 use strict;
 use warnings;
 
@@ -13,140 +13,140 @@ use Rex::Interface::Fs::Base;
 use base qw(Rex::Interface::Fs::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub upload {
-   my ($self, $source, $target) = @_;
-   $self->cp($source, $target);
+  my ($self, $source, $target) = @_;
+  $self->cp($source, $target);
 }
 
 sub download {
-   my ($self, $source, $target) = @_;
-   $self->cp($source, $target);
+  my ($self, $source, $target) = @_;
+  $self->cp($source, $target);
 }
 
 sub ls {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my @ret;
+  my @ret;
 
-   eval {
-      opendir(my $dh, $path) or die("$path is not a directory");
-      while(my $entry = readdir($dh)) {
-         next if ($entry =~ /^\.\.?$/);
-         push @ret, $entry;
-      }
-      closedir($dh);
-   };
+  eval {
+    opendir(my $dh, $path) or die("$path is not a directory");
+    while(my $entry = readdir($dh)) {
+      next if ($entry =~ /^\.\.?$/);
+      push @ret, $entry;
+    }
+    closedir($dh);
+  };
 
-   # failed open directory, return undef
-   if($@) { return; }
+  # failed open directory, return undef
+  if($@) { return; }
 
-   # return directory content
-   return @ret;
+  # return directory content
+  return @ret;
 }
 
 sub rmdir {
-   my ($self, @dirs) = @_;
-
-   Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
-   my $exec = Rex::Interface::Exec->create;
-   if($^O =~ m/^MSWin/) {
-      for (@dirs) {
-         s/\//\\/g;
-      }
-      $exec->exec("rd /Q /S " . join(" ", @dirs));
-   }
-   else {
-      $exec->exec("/bin/rm -rf " . join(" ", @dirs));
-   }
-
-   if($? == 0) { return 1; }
+  my ($self, @dirs) = @_;
+
+  Rex::Logger::debug("Removing directories: " . join(", ", @dirs));
+  my $exec = Rex::Interface::Exec->create;
+  if($^O =~ m/^MSWin/) {
+    for (@dirs) {
+      s/\//\\/g;
+    }
+    $exec->exec("rd /Q /S " . join(" ", @dirs));
+  }
+  else {
+    $exec->exec("/bin/rm -rf " . join(" ", @dirs));
+  }
+
+  if($? == 0) { return 1; }
 }
 
 
 sub is_dir {
-   my ($self, $path) = @_;
-   if(-d $path) { return 1; }
+  my ($self, $path) = @_;
+  if(-d $path) { return 1; }
 }
 
 sub is_file {
-   my ($self, $file) = @_;
-   if(-f $file) { return 1; }
+  my ($self, $file) = @_;
+  if(-f $file) { return 1; }
 }
 
 sub unlink {
-   my ($self, @files) = @_;
-   CORE::unlink(@files);
+  my ($self, @files) = @_;
+  CORE::unlink(@files);
 }
 
 sub mkdir {
-   my ($self, $dir) = @_;
-   CORE::mkdir($dir);
+  my ($self, $dir) = @_;
+  CORE::mkdir($dir);
 }
 
 sub stat {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   if(my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
-               $atime, $mtime, $ctime, $blksize, $blocks) = CORE::stat($file)) {
+  if(my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+          $atime, $mtime, $ctime, $blksize, $blocks) = CORE::stat($file)) {
 
-         my %ret;
+      my %ret;
 
-         $ret{'mode'}  = sprintf("%04o", $mode & 07777); 
-         $ret{'size'}  = $size;
-         $ret{'uid'}   = $uid;
-         $ret{'gid'}   = $gid;
-         $ret{'atime'} = $atime;
-         $ret{'mtime'} = $mtime;
+      $ret{'mode'}  = sprintf("%04o", $mode & 07777); 
+      $ret{'size'}  = $size;
+      $ret{'uid'}  = $uid;
+      $ret{'gid'}  = $gid;
+      $ret{'atime'} = $atime;
+      $ret{'mtime'} = $mtime;
 
-         return %ret;
-   }
+      return %ret;
+  }
 
 }
 
 sub is_readable {
-   my ($self, $file) = @_;
-   if(-r $file) { return 1; }
+  my ($self, $file) = @_;
+  if(-r $file) { return 1; }
 }
 
 sub is_writable {
-   my ($self, $file) = @_;
-   if(-w $file) { return 1; }
+  my ($self, $file) = @_;
+  if(-w $file) { return 1; }
 }
 
 sub readlink {
-   my ($self, $file) = @_;
-   return CORE::readlink($file);
+  my ($self, $file) = @_;
+  return CORE::readlink($file);
 }
 
 sub rename {
-   my ($self, $old, $new) = @_;
+  my ($self, $old, $new) = @_;
 
-   my $exec = Rex::Interface::Exec->create;
+  my $exec = Rex::Interface::Exec->create;
 
-   if($^O =~ m/^MSWin/) {
-      $old =~ s/\//\\/g;
-      $new =~ s/\//\\/g;
-      $exec->exec("move \"$old\" \"$new\"");
-   }
-   else {
-      $exec->exec("/bin/mv '$old' '$new'");
-   }
+  if($^O =~ m/^MSWin/) {
+    $old =~ s/\//\\/g;
+    $new =~ s/\//\\/g;
+    $exec->exec("move \"$old\" \"$new\"");
+  }
+  else {
+    $exec->exec("/bin/mv '$old' '$new'");
+  }
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub glob {
-   my ($self, $glob) = @_;
-   return CORE::glob($glob);
+  my ($self, $glob) = @_;
+  return CORE::glob($glob);
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs::OpenSSH;
-   
+  
 use strict;
 use warnings;
 
@@ -18,138 +18,138 @@ use base qw(Rex::Interface::Fs::SSH);
 require Rex::Commands;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub ls {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my @ret;
+  my @ret;
 
-   Rex::Commands::profiler()->start("ls: $path");
-   eval {
+  Rex::Commands::profiler()->start("ls: $path");
+  eval {
 
-      my $sftp = Rex::get_sftp();
-      my $ls = $sftp->ls($path);
+    my $sftp = Rex::get_sftp();
+    my $ls = $sftp->ls($path);
 
-      for my $entry (@{ $ls }) {
-         push @ret, $entry->{'filename'};
-      }
-   };
-   Rex::Commands::profiler()->end("ls: $path");
+    for my $entry (@{ $ls }) {
+      push @ret, $entry->{'filename'};
+    }
+  };
+  Rex::Commands::profiler()->end("ls: $path");
 
-   # failed open directory, return undef
-   if($@) { return; }
+  # failed open directory, return undef
+  if($@) { return; }
 
-   # return directory content
-   return @ret;
+  # return directory content
+  return @ret;
 }
 
 sub is_dir {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my $ret = 0;
+  my $ret = 0;
 
-   Rex::Commands::profiler()->start("is_dir: $path");
-   my $sftp = Rex::get_sftp();
-   if(my $hndl = $sftp->opendir($path)) {
-      # return true if $path can be opened as a directory
-      $sftp->closedir($hndl);
-      $ret = 1;
-   }
-   Rex::Commands::profiler()->end("is_dir: $path");
+  Rex::Commands::profiler()->start("is_dir: $path");
+  my $sftp = Rex::get_sftp();
+  if(my $hndl = $sftp->opendir($path)) {
+    # return true if $path can be opened as a directory
+    $sftp->closedir($hndl);
+    $ret = 1;
+  }
+  Rex::Commands::profiler()->end("is_dir: $path");
 
-   return $ret;
+  return $ret;
 }
 
 sub is_file {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $ret;
+  my $ret;
 
-   my $sftp = Rex::get_sftp();
-   Rex::Commands::profiler()->start("is_file: $file");
-   if(my $hndl = $sftp->open($file, SSH2_FXF_READ) ) {
-      # return true if $file can be opened read only
-      $sftp->close($hndl);
-      $ret = 1;
-   }
-   Rex::Commands::profiler()->end("is_file: $file");
+  my $sftp = Rex::get_sftp();
+  Rex::Commands::profiler()->start("is_file: $file");
+  if(my $hndl = $sftp->open($file, SSH2_FXF_READ) ) {
+    # return true if $file can be opened read only
+    $sftp->close($hndl);
+    $ret = 1;
+  }
+  Rex::Commands::profiler()->end("is_file: $file");
 
-   return $ret;
+  return $ret;
 }
 
 sub unlink {
-   my ($self, @files) = @_;
-
-   my $sftp = Rex::get_sftp();
-   for my $file (@files) {
-      Rex::Commands::profiler()->start("unlink: $file");
-      eval { $sftp->remove($file); };
-      Rex::Commands::profiler()->end("unlink: $file");
-   }
+  my ($self, @files) = @_;
+
+  my $sftp = Rex::get_sftp();
+  for my $file (@files) {
+    Rex::Commands::profiler()->start("unlink: $file");
+    eval { $sftp->remove($file); };
+    Rex::Commands::profiler()->end("unlink: $file");
+  }
 }
 
 sub stat {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   Rex::Commands::profiler()->start("stat: $file");
+  Rex::Commands::profiler()->start("stat: $file");
 
-   my $sftp = Rex::get_sftp();
-   my $ret = $sftp->stat($file);
+  my $sftp = Rex::get_sftp();
+  my $ret = $sftp->stat($file);
 
-   if(! $ret) { return; }
+  if(! $ret) { return; }
 
-   my %ret = (
-      mode => sprintf("%04o", $ret->perm & 07777),
-      size => $ret->size,
-      uid => $ret->uid,
-      gid => $ret->gid,
-      atime => $ret->atime,
-      mtime => $ret->mtime,
-   );
+  my %ret = (
+    mode => sprintf("%04o", $ret->perm & 07777),
+    size => $ret->size,
+    uid => $ret->uid,
+    gid => $ret->gid,
+    atime => $ret->atime,
+    mtime => $ret->mtime,
+  );
 
-   Rex::Commands::profiler()->end("stat: $file");
+  Rex::Commands::profiler()->end("stat: $file");
 
-   return %ret;
+  return %ret;
 }
 
 
 sub upload {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   Rex::Commands::profiler()->start("upload: $source -> $target");
+  Rex::Commands::profiler()->start("upload: $source -> $target");
 
-   my $sftp = Rex::get_sftp();
-   unless($sftp->put($source, $target)) {
-      Rex::Logger::debug("upload: $target is not writable");
+  my $sftp = Rex::get_sftp();
+  unless($sftp->put($source, $target)) {
+    Rex::Logger::debug("upload: $target is not writable");
 
-      Rex::Commands::profiler()->end("upload: $source -> $target");
+    Rex::Commands::profiler()->end("upload: $source -> $target");
 
-      die("upload: $target is not writable.");
-   }
+    die("upload: $target is not writable.");
+  }
 
-   Rex::Commands::profiler()->end("upload: $source -> $target");
+  Rex::Commands::profiler()->end("upload: $source -> $target");
 }
 
 sub download {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   Rex::Commands::profiler()->start("download: $source -> $target");
+  Rex::Commands::profiler()->start("download: $source -> $target");
 
-   my $sftp = Rex::get_sftp();
-   if(!$sftp->get($source, $target)) {
-      Rex::Commands::profiler()->end("download: $source -> $target");
-      die($sftp->error);
-   }
+  my $sftp = Rex::get_sftp();
+  if(!$sftp->get($source, $target)) {
+    Rex::Commands::profiler()->end("download: $source -> $target");
+    die($sftp->error);
+  }
 
-   Rex::Commands::profiler()->end("download: $source -> $target");
+  Rex::Commands::profiler()->end("download: $source -> $target");
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Fs::SSH;
-   
+
 use strict;
 use warnings;
 
@@ -18,226 +18,245 @@ use base qw(Rex::Interface::Fs::Base);
 require Rex::Commands;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub ls {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my @ret;
+  my @ret;
 
-   Rex::Commands::profiler()->start("ls: $path");
-   eval {
+  Rex::Commands::profiler()->start("ls: $path");
+  eval {
 
-      my $sftp = Rex::get_sftp();
-      my $dir = $sftp->opendir($path);
-      unless($dir) {
-         die("$path is not a directory");
-      }
+    my $sftp = Rex::get_sftp();
+    my $dir = $sftp->opendir($path);
+    unless($dir) {
+      die("$path is not a directory");
+    }
 
-      while(my $entry  = $dir->read) {
-         push @ret, $entry->{'name'};
-      }
-   };
-   Rex::Commands::profiler()->end("ls: $path");
+    while(my $entry  = $dir->read) {
+      push @ret, $entry->{'name'};
+    }
+  };
+  Rex::Commands::profiler()->end("ls: $path");
 
-   # failed open directory, return undef
-   if($@) { return; }
+  # failed open directory, return undef
+  if($@) { return; }
 
-   # return directory content
-   return @ret;
+  # return directory content
+  return @ret;
 }
 
 sub is_dir {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my $ret = 0;
+  my $ret = 0;
 
-   Rex::Commands::profiler()->start("is_dir: $path");
-   my $sftp = Rex::get_sftp();
-   if($sftp->opendir($path)) {
-      # return true if $path can be opened as a directory
-      $ret = 1;
-   }
-   Rex::Commands::profiler()->end("is_dir: $path");
+  Rex::Commands::profiler()->start("is_dir: $path");
+  my $sftp = Rex::get_sftp();
+  if($sftp->opendir($path)) {
+    # return true if $path can be opened as a directory
+    $ret = 1;
+  }
+  Rex::Commands::profiler()->end("is_dir: $path");
 
-   return $ret;
+  return $ret;
 }
 
 sub is_file {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $ret;
+  my $ret;
 
-   Rex::Commands::profiler()->start("is_file: $file");
-   my $sftp = Rex::get_sftp();
-   if( $sftp->open($file, O_RDONLY) ) {
-      # return true if $file can be opened read only
-      $ret = 1;
-   }
-   Rex::Commands::profiler()->end("is_file: $file");
+  Rex::Commands::profiler()->start("is_file: $file");
+  my $sftp = Rex::get_sftp();
+  if( $sftp->open($file, O_RDONLY) ) {
+    # return true if $file can be opened read only
+    $ret = 1;
+  }
+  Rex::Commands::profiler()->end("is_file: $file");
 
-   return $ret;
+  return $ret;
 }
 
 sub unlink {
-   my ($self, @files) = @_;
-
-   my $sftp = Rex::get_sftp();
-   for my $file (@files) {
-      Rex::Commands::profiler()->start("unlink: $file");
-      eval { $sftp->unlink($file); };
-      Rex::Commands::profiler()->end("unlink: $file");
-   }
+  my ($self, @files) = @_;
+
+  my $sftp = Rex::get_sftp();
+  for my $file (@files) {
+    Rex::Commands::profiler()->start("unlink: $file");
+    eval { $sftp->unlink($file); };
+    Rex::Commands::profiler()->end("unlink: $file");
+  }
 }
 
 sub mkdir {
-   my ($self, $dir) = @_;
+  my ($self, $dir) = @_;
 
-   my $ret;
+  my $ret;
 
-   Rex::Commands::profiler()->start("mkdir: $dir");
-   my $sftp = Rex::get_sftp();
+  Rex::Commands::profiler()->start("mkdir: $dir");
+  my $sftp = Rex::get_sftp();
 
-   $sftp->mkdir($dir);
-   if($self->is_dir($dir)) {
-      $ret = 1;
-   }
+  $sftp->mkdir($dir);
+  if($self->is_dir($dir)) {
+    $ret = 1;
+  }
 
-   Rex::Commands::profiler()->end("mkdir: $dir");
+  Rex::Commands::profiler()->end("mkdir: $dir");
 
-   return $ret;
+  return $ret;
 }
 
 sub stat {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   Rex::Commands::profiler()->start("stat: $file");
+  Rex::Commands::profiler()->start("stat: $file");
 
-   my $sftp = Rex::get_sftp();
-   my %ret = $sftp->stat($file);
+  my $sftp = Rex::get_sftp();
+  my %ret = $sftp->stat($file);
 
-   if(! %ret) { return; }
+  if(! %ret) { return; }
 
-   $ret{'mode'} = sprintf("%04o", $ret{'mode'} & 07777);
+  $ret{'mode'} = sprintf("%04o", $ret{'mode'} & 07777);
 
-   Rex::Commands::profiler()->end("stat: $file");
+  Rex::Commands::profiler()->end("stat: $file");
 
-   return %ret;
+  return %ret;
 }
 
 sub is_readable {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   Rex::Commands::profiler()->start("is_readable: $file");
+  Rex::Commands::profiler()->start("is_readable: $file");
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("perl -le 'if(-r \"$file\") { exit 0; } exit 1'");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("perl -le 'if(-r \"$file\") { exit 0; } exit 1'");
 
-   Rex::Commands::profiler()->end("is_readable: $file");
+  Rex::Commands::profiler()->end("is_readable: $file");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub is_writable {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   Rex::Commands::profiler()->start("is_writable: $file");
+  Rex::Commands::profiler()->start("is_writable: $file");
 
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("perl -le 'if(-w \"$file\") { exit 0; } exit 1'");
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("perl -le 'if(-w \"$file\") { exit 0; } exit 1'");
 
-   Rex::Commands::profiler()->end("is_writable: $file");
+  Rex::Commands::profiler()->end("is_writable: $file");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub readlink {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $ret;
+  my $ret;
 
-   Rex::Commands::profiler()->start("readlink: $file");
+  Rex::Commands::profiler()->start("readlink: $file");
 
-   my $sftp = Rex::get_sftp();
-   $ret = $sftp->readlink($file);
+  my $sftp = Rex::get_sftp();
+  $ret = $sftp->readlink($file);
 
-   Rex::Commands::profiler()->end("readlink: $file");
+  Rex::Commands::profiler()->end("readlink: $file");
 
-   return $ret;
+  return $ret;
 }
 
 sub rename {
-   my ($self, $old, $new) = @_;
+  my ($self, $old, $new) = @_;
 
-   my $ret;
+  my $ret;
 
-   Rex::Commands::profiler()->start("rename: $old -> $new");
+  Rex::Commands::profiler()->start("rename: $old -> $new");
 
-   # don't use rename() doesn't work with different file systems / partitions
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec("/bin/mv '$old' '$new'");
+  # don't use rename() doesn't work with different file systems / partitions
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec("/bin/mv '$old' '$new'");
 
-   if( (! $self->is_file($old) && ! $self->is_dir($old) ) && ( $self->is_file($new) || $self->is_dir($new)) ) {
-      $ret = 1;
-   }
+  if( (! $self->is_file($old) && ! $self->is_dir($old) ) && ( $self->is_file($new) || $self->is_dir($new)) ) {
+    $ret = 1;
+  }
 
-   Rex::Commands::profiler()->end("rename: $old -> $new");
+  Rex::Commands::profiler()->end("rename: $old -> $new");
 
-   return $ret;
+  return $ret;
 }
 
 sub glob {
-   my ($self, $glob) = @_;
+  my ($self, $glob) = @_;
 
-   Rex::Commands::profiler()->start("glob: $glob");
+  Rex::Commands::profiler()->start("glob: $glob");
 
-   my $ssh = Rex::is_ssh();
-   my $exec = Rex::Interface::Exec->create;
-   my $content = $exec->exec("perl -le'print join(\"*,*,*\", glob(\"$glob\"))'");
-   chomp $content;
-   my @files = split(/\*,\*,\*/, $content);
+  my $ssh = Rex::is_ssh();
+  my $exec = Rex::Interface::Exec->create;
+  my $content = $exec->exec("perl -le'print join(\"*,*,*\", glob(\"$glob\"))'");
+  chomp $content;
+  my @files = split(/\*,\*,\*/, $content);
 
-   Rex::Commands::profiler()->end("glob: $glob");
+  Rex::Commands::profiler()->end("glob: $glob");
 
-   return @files;
+  return @files;
 }
 
 sub upload {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   Rex::Commands::profiler()->start("upload: $source -> $target");
+  Rex::Commands::profiler()->start("upload: $source -> $target");
 
-   my $ssh = Rex::is_ssh();
-   unless($ssh->scp_put($source, $target)) {
-      Rex::Logger::debug("upload: $target is not writable");
+  my $ssh = Rex::is_ssh();
+  unless($ssh->scp_put($source, $target)) {
+    Rex::Logger::debug("upload: $target is not writable");
 
-      Rex::Commands::profiler()->end("upload: $source -> $target");
+    Rex::Commands::profiler()->end("upload: $source -> $target");
 
-      die("upload: $target is not writable.");
-   }
+    die("upload: $target is not writable.");
+  }
 
-   Rex::Commands::profiler()->end("upload: $source -> $target");
+  Rex::Commands::profiler()->end("upload: $source -> $target");
 }
 
 sub download {
-   my ($self, $source, $target) = @_;
-
-   Rex::Commands::profiler()->start("download: $source -> $target");
-
-   my $ssh = Rex::is_ssh();
-   if(!$ssh->scp_get($source, $target)) {
+  my ($self, $source, $target) = @_;
+
+  Rex::Commands::profiler()->start("download: $source -> $target");
+
+  if($^O =~ m/^MSWin/) {
+    # fix for: #271
+    my $ssh = Rex::is_ssh();
+    my $sftp = $ssh->sftp();
+    eval {
+      my $fh = $sftp->open($source) or die($!);
+      open(my $out, ">", $target) or die($!);
+      binmode $out;
+      print $out $_ while (<$fh>);
+      close $out;
+      close $fh;
+      1;
+    } or do {
+      Rex::Commands::profiler()->end("download: $source -> $target");
+      die($ssh->error);
+    };
+  }
+  else {
+    my $ssh = Rex::is_ssh();
+    if(!$ssh->scp_get($source, $target)) {
       Rex::Commands::profiler()->end("download: $source -> $target");
       die($ssh->error);
-   }
+    }
+  }
 
-   Rex::Commands::profiler()->end("download: $source -> $target");
+  Rex::Commands::profiler()->end("download: $source -> $target");
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs::Sudo;
-   
+  
 use strict;
 use warnings;
 
@@ -17,231 +17,231 @@ use JSON::XS;
 use base qw(Rex::Interface::Fs::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub ls {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   my @ret;
+  my @ret;
 
-   my @out = split(/\n/, $self->_exec("ls -a1 $path"));
-   # failed open directory, return undef
-   if($? != 0) { return; }
+  my @out = split(/\n/, $self->_exec("ls -a1 $path"));
+  # failed open directory, return undef
+  if($? != 0) { return; }
 
-   @ret = grep { ! m/^\.\.?$/ } @out;
+  @ret = grep { ! m/^\.\.?$/ } @out;
 
-   # return directory content
-   return @ret;
+  # return directory content
+  return @ret;
 }
 
 sub upload {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   my $rnd_file = get_tmp_file;
+  my $rnd_file = get_tmp_file;
 
-   if(my $ssh = Rex::is_ssh()) {
-      if(ref $ssh eq "Net::OpenSSH") {
-         $ssh->sftp->put($source, $rnd_file);
-      }
-      else {
-         $ssh->scp_put($source, $rnd_file);
-      }
-      $self->_exec("mv $rnd_file '$target'");
-   }
-   else {
-      $self->cp($source, $target);
-   }
+  if(my $ssh = Rex::is_ssh()) {
+    if(ref $ssh eq "Net::OpenSSH") {
+      $ssh->sftp->put($source, $rnd_file);
+    }
+    else {
+      $ssh->scp_put($source, $rnd_file);
+    }
+    $self->_exec("mv $rnd_file '$target'");
+  }
+  else {
+    $self->cp($source, $target);
+  }
 
 }
 
 sub download {
-   my ($self, $source, $target) = @_;
+  my ($self, $source, $target) = @_;
 
-   my $rnd_file = get_tmp_file;
+  my $rnd_file = get_tmp_file;
 
-   if(my $ssh = Rex::is_ssh()) {
-      $self->_exec("cp '$source' $rnd_file");
-      if(ref $ssh eq "Net::OpenSSH") {
-         $ssh->sftp->get($rnd_file, $target);
-      }
-      else {
-         $ssh->scp_get($rnd_file, $target);
-      }
-      $self->unlink($rnd_file);
-   }
-   else {
-      $self->cp($source, $target);
-   }
+  if(my $ssh = Rex::is_ssh()) {
+    $self->_exec("cp '$source' $rnd_file");
+    if(ref $ssh eq "Net::OpenSSH") {
+      $ssh->sftp->get($rnd_file, $target);
+    }
+    else {
+      $ssh->scp_get($rnd_file, $target);
+    }
+    $self->unlink($rnd_file);
+  }
+  else {
+    $self->cp($source, $target);
+  }
 
 }
 
 sub is_dir {
-   my ($self, $path) = @_;
+  my ($self, $path) = @_;
 
-   $self->_exec("/bin/sh -c '[ -d \"$path\" ]'");
-   my $ret = $?;
+  $self->_exec("/bin/sh -c '[ -d \"$path\" ]'");
+  my $ret = $?;
 
-   if($ret == 0) { return 1; }
+  if($ret == 0) { return 1; }
 }
 
 sub is_file {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   $self->_exec("/bin/sh -c '[ -e \"$file\" ]'");
-   my $ret = $?;
+  $self->_exec("/bin/sh -c '[ -e \"$file\" ]'");
+  my $ret = $?;
 
-   if($ret == 0) { return 1; }
+  if($ret == 0) { return 1; }
 }
 
 sub unlink {
-   my ($self, @files) = @_;
-   (@files) = $self->_normalize_path(@files);
+  my ($self, @files) = @_;
+  (@files) = $self->_normalize_path(@files);
 
-   $self->_exec("rm " . join(" ", @files));
-   if($? == 0) { return 1; }
+  $self->_exec("rm " . join(" ", @files));
+  if($? == 0) { return 1; }
 }
 
 sub mkdir {
-   my ($self, $dir) = @_;
-   $self->_exec("mkdir '$dir' >/dev/null 2>&1");
-   if($? == 0) { return 1; }
+  my ($self, $dir) = @_;
+  $self->_exec("mkdir '$dir' >/dev/null 2>&1");
+  if($? == 0) { return 1; }
 }
 
 sub stat {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $script = q|
-   unlink $0;
+  my $script = q|
+  unlink $0;
 
-   if(my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
-               $atime, $mtime, $ctime, $blksize, $blocks) = stat($ARGV[0])) {
+  if(my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+          $atime, $mtime, $ctime, $blksize, $blocks) = stat($ARGV[0])) {
 
-         my %ret;
+      my %ret;
 
-         $ret{'mode'}  = sprintf("%04o", $mode & 07777); 
-         $ret{'size'}  = $size;
-         $ret{'uid'}   = $uid;
-         $ret{'gid'}   = $gid;
-         $ret{'atime'} = $atime;
-         $ret{'mtime'} = $mtime;
+      $ret{'mode'}  = sprintf("%04o", $mode & 07777); 
+      $ret{'size'}  = $size;
+      $ret{'uid'}  = $uid;
+      $ret{'gid'}  = $gid;
+      $ret{'atime'} = $atime;
+      $ret{'mtime'} = $mtime;
 
-         print to_json(\%ret);
-   }
+      print to_json(\%ret);
+  }
 
-   |;
+  |;
 
-   $script .= func_to_json();
+  $script .= func_to_json();
 
-   my $rnd_file = $self->_write_to_rnd_file($script);
-   my $out = $self->_exec("perl $rnd_file '$file'");
-   my $tmp = decode_json($out);
+  my $rnd_file = $self->_write_to_rnd_file($script);
+  my $out = $self->_exec("perl $rnd_file '$file'");
+  my $tmp = decode_json($out);
 
-   return %{$tmp};
+  return %{$tmp};
 }
 
 sub is_readable {
-   my ($self, $file) = @_;
-   my $script = q|unlink $0; if(-r $ARGV[0]) { exit 0; } exit 1; |;
+  my ($self, $file) = @_;
+  my $script = q|unlink $0; if(-r $ARGV[0]) { exit 0; } exit 1; |;
 
-   my $rnd_file = $self->_write_to_rnd_file($script);
-   $self->_exec("perl $rnd_file '$file'");
-   my $ret = $?;
+  my $rnd_file = $self->_write_to_rnd_file($script);
+  $self->_exec("perl $rnd_file '$file'");
+  my $ret = $?;
 
-   if($ret == 0) { return 1; }
+  if($ret == 0) { return 1; }
 }
 
 sub is_writable {
-   my ($self, $file) = @_;
+  my ($self, $file) = @_;
 
-   my $script = q|unlink $0; if(-w $ARGV[0]) { exit 0; } exit 1; |;
+  my $script = q|unlink $0; if(-w $ARGV[0]) { exit 0; } exit 1; |;
 
-   my $rnd_file = $self->_write_to_rnd_file($script);
-   $self->_exec("perl $rnd_file '$file'");
-   my $ret = $?;
+  my $rnd_file = $self->_write_to_rnd_file($script);
+  $self->_exec("perl $rnd_file '$file'");
+  my $ret = $?;
 
-   if($ret == 0) { return 1; }
+  if($ret == 0) { return 1; }
 }
 
 sub readlink {
-   my ($self, $file) = @_;
-   my $script = q|unlink $0; print readlink($ARGV[0]) . "\n"; |;
+  my ($self, $file) = @_;
+  my $script = q|unlink $0; print readlink($ARGV[0]) . "\n"; |;
 
-   my $rnd_file = $self->_write_to_rnd_file($script);
-   my $out = $self->_exec("perl $rnd_file '$file'");
-   chomp $out;
-   
-   return $out;
+  my $rnd_file = $self->_write_to_rnd_file($script);
+  my $out = $self->_exec("perl $rnd_file '$file'");
+  chomp $out;
+  
+  return $out;
 }
 
 sub rename {
-   my ($self, $old, $new) = @_;
-   ($old) = $self->_normalize_path($old);
-   ($new) = $self->_normalize_path($new);
+  my ($self, $old, $new) = @_;
+  ($old) = $self->_normalize_path($old);
+  ($new) = $self->_normalize_path($new);
 
-   $self->_exec("mv $old $new");
+  $self->_exec("mv $old $new");
 
-   if($? == 0) { return 1; }
+  if($? == 0) { return 1; }
 }
 
 sub glob {
-   my ($self, $glob) = @_;
+  my ($self, $glob) = @_;
 
-   my $script = q|
-   unlink $0;
-   print to_json([ glob("| . $glob . q|") ]);
-   |;
+  my $script = q|
+  unlink $0;
+  print to_json([ glob("| . $glob . q|") ]);
+  |;
 
-   $script .= func_to_json();
+  $script .= func_to_json();
 
-   my $rnd_file = $self->_write_to_rnd_file($script);
-   my $content = $self->_exec("perl $rnd_file");
-   my $tmp = decode_json($content);
+  my $rnd_file = $self->_write_to_rnd_file($script);
+  my $content = $self->_exec("perl $rnd_file");
+  my $tmp = decode_json($content);
 
-   return @{$tmp};
+  return @{$tmp};
 }
 
 sub _get_file_writer {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $fh;
-   if(my $o = Rex::is_ssh()) {
-      if(ref $o eq "Net::OpenSSH") {
-         $fh = Rex::Interface::File->create("OpenSSH");
-      }
-      else {
-         $fh = Rex::Interface::File->create("SSH");
-      }
-   }
-   else {
-      $fh = Rex::Interface::File->create("Local");
-   }
+  my $fh;
+  if(my $o = Rex::is_ssh()) {
+    if(ref $o eq "Net::OpenSSH") {
+      $fh = Rex::Interface::File->create("OpenSSH");
+    }
+    else {
+      $fh = Rex::Interface::File->create("SSH");
+    }
+  }
+  else {
+    $fh = Rex::Interface::File->create("Local");
+  }
 
-   return $fh;
+  return $fh;
 }
 
 sub _write_to_rnd_file {
-   my ($self, $content) = @_;
-   my $fh = $self->_get_file_writer();
-   my $rnd_file = get_tmp_file;
+  my ($self, $content) = @_;
+  my $fh = $self->_get_file_writer();
+  my $rnd_file = get_tmp_file;
 
-   $fh->open(">", $rnd_file);
-   $fh->write($content);
-   $fh->close;
+  $fh->open(">", $rnd_file);
+  $fh->write($content);
+  $fh->close;
 
-   return $rnd_file;
+  return $rnd_file;
 }
 
 sub _exec {
-   my ($self, $cmd) = @_;
-   my $exec = Rex::Interface::Exec->create("Sudo");
-   return $exec->exec($cmd);
+  my ($self, $cmd) = @_;
+  my $exec = Rex::Interface::Exec->create("Sudo");
+  return $exec->exec($cmd);
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Interface::Fs;
-   
+  
 use strict;
 use warnings;
 
@@ -13,27 +13,27 @@ use Rex;
 use Data::Dumper;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   unless($type) {
-      #$type = Rex::Commands::task()->get_connection_type;
-      $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
-      #if(Rex::is_ssh() && ! Rex::is_sudo()) {
-      #   $type = "SSH";
-      #}
-      #elsif(Rex::is_sudo()) {
-      #   $type = "Sudo";
-      #}
-      #else {
-      #   $type = "Local";
-      #}
-   }
+  unless($type) {
+    #$type = Rex::Commands::task()->get_connection_type;
+    $type = Rex::get_current_connection()->{conn}->get_connection_type; #Rex::Commands::task()->get_connection_type;
+    #if(Rex::is_ssh() && ! Rex::is_sudo()) {
+    #  $type = "SSH";
+    #}
+    #elsif(Rex::is_sudo()) {
+    #  $type = "Sudo";
+    #}
+    #else {
+    #  $type = "Local";
+    #}
+  }
 
-   my $class_name = "Rex::Interface::Fs::$type";
-   eval "use $class_name;";
-   if($@) { die("Error loading Fs interface $type.\n$@"); }
+  my $class_name = "Rex::Interface::Fs::$type";
+  eval "use $class_name;";
+  if($@) { die("Error loading Fs interface $type.\n$@"); }
 
-   return $class_name->new;
+  return $class_name->new;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Ash;
 
 use strict;
@@ -14,13 +14,13 @@ use Rex::Interface::Shell::Bash;
 use base qw(Rex::Interface::Shell::Bash);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
 
-    bless($self, $class);
-    
-    return $self;
+  return $self;
 }
 
 1;
@@ -0,0 +1,43 @@
+#
+# (c) Jan Gehring <jan.gehring@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+package Rex::Interface::Shell::Base;
+
+use strict;
+use warnings;
+
+sub new {
+  my $class = shift;
+  my $self  = {};
+  $self->{path}            = undef;
+  $self->{__inner_shell__} = undef;
+
+  bless( $self, $class );
+
+  return $self;
+}
+
+sub set_environment {
+  my ( $self, $env ) = @_;
+  $self->{__env__} = $env;
+}
+
+sub set_inner_shell {
+  my ( $self, $use_inner_shell ) = @_;
+  $self->{__inner_shell__} = $use_inner_shell;
+}
+
+sub set_locale {
+  my ( $self, $locale ) = @_;
+  $self->{locale} = $locale;
+}
+
+sub set_sudo_env {
+  my ( $self, $sudo_env ) = @_;
+  $self->{__sudo_env__} = $sudo_env;
+}
+
+1;
@@ -1,118 +1,142 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
 
 package Rex::Interface::Shell::Bash;
 
 use strict;
 use warnings;
 
+use Rex::Interface::Shell::Base;
+use base qw(Rex::Interface::Shell::Base);
+use Data::Dumper;
+
 sub new {
-    my $class = shift;
-    my $self = {};
-    $self->{path} = undef;
-    bless($self, $class);
-    
-    return $self;
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
+
+  return $self;
 }
 
 sub path {
-    my ($self, $path ) = @_;
-    $self->{path} = $path;
+  my ( $self, $path ) = @_;
+  $self->{path} = $path;
 }
 
 sub source_global_profile {
-    my ($self, $parse) = @_;
-    $self->{source_global_profile} = $parse;
+  my ( $self, $parse ) = @_;
+  $self->{source_global_profile} = $parse;
 }
 
 sub source_profile {
-    my ($self, $parse) = @_;
-    $self->{source_profile} = $parse;
+  my ( $self, $parse ) = @_;
+  $self->{source_profile} = $parse;
 }
 
-sub set_locale {
-    my ($self, $locale) = @_;
-    $self->{locale} = $locale;
-}
+# sub set_env {
+#   my ( $self, $env ) = @_;
+#   my $cmd = undef;
+#
+#   die("Error: env must be a hash")
+#     if ( ref $env ne "HASH" );
+#
+#   while ( my ( $k, $v ) = each($env) ) {
+#     $cmd .= "export $k=$v; ";
+#   }
+#   $self->{env} = $cmd;
+# }
 
 sub exec {
-    my ($self, $cmd, $option) = @_;
-    my $complete_cmd = $cmd;
-
-    if(exists $option->{path}) {
-      $self->path($option->{path});
-    }
-
-    if(exists $option->{no_sh}) {
-
-       if(exists $option->{cwd}) {
-           $option->{format_cmd} = "cd $option->{cwd} && $option->{format_cmd}";
-       }
-
-       if ($self->{path}) {
-           $option->{format_cmd} = "PATH=$self->{path}; export PATH; $option->{format_cmd} ";
-       }
-
-       if ($self->{locale} && ! exists $option->{no_locales}) {
-           $option->{format_cmd} = "LC_ALL=$self->{locale} ; export LC_ALL; $option->{format_cmd} ";
-       }
-
-       if ($self->{source_profile}) {
-           $option->{format_cmd} = ". ~/.profile >/dev/null 2>&1 ; $option->{format_cmd} ";
-       }
-
-
-       if ($self->{source_global_profile}) {
-           $option->{format_cmd} = ". /etc/profile >/dev/null 2>&1 ; $option->{format_cmd} ";
-       }
-
+  my ( $self, $cmd, $option ) = @_;
+
+  if ( exists $option->{path} ) {
+    $self->path( $option->{path} );
+  }
+
+  Rex::Logger::debug("Shell/Bash: Got options:");
+  Rex::Logger::debug( Dumper($option) );
+
+  my $complete_cmd = $cmd;
+
+  # if we need to execute without an sh command,
+  # use the format_cmd key
+  # if ( exists $option->{no_sh} ) {
+  #   $complete_cmd = $option->{format_cmd};
+  # }
+
+  if ( exists $option->{cwd} ) {
+    $complete_cmd = "cd $option->{cwd} && $complete_cmd";
+  }
+
+  if ( $self->{path} ) {
+    $complete_cmd = "PATH=$self->{path}; export PATH; $complete_cmd ";
+  }
+
+  if ( $self->{locale} && !exists $option->{no_locales} ) {
+    $complete_cmd = "LC_ALL=$self->{locale} ; export LC_ALL; $complete_cmd ";
+  }
+
+  if ( $self->{source_profile} ) {
+    $complete_cmd = ". ~/.profile >/dev/null 2>&1 ; $complete_cmd";
+  }
+
+  if ( $self->{source_global_profile} ) {
+    $complete_cmd = ". /etc/profile >/dev/null 2>&1 ; $complete_cmd";
+  }
+
+  if ( exists $self->{__env__} ) {
+    if ( ref $self->{__env__} eq "HASH" ) {
+      for my $key ( keys %{ $self->{__env__} } ) {
+        my $val = $self->{__env__}->{$key};
+        $val =~ s/"/\\"/gms;
+        if ( exists $self->{__sudo_env__} && $self->{__sudo_env__} ) {
+          $complete_cmd = " $key=\"$val\" $complete_cmd ";
+        }
+        else {
+          $complete_cmd = " export $key=\"$val\" ; $complete_cmd ";
+        }
+      }
     }
     else {
-
-       if(exists $option->{cwd}) {
-         $complete_cmd = "cd $option->{cwd} && $complete_cmd";
-       }
-
-       if ($self->{path}) {
-           $complete_cmd = "PATH=$self->{path}; export PATH; $complete_cmd ";
-       }
-
-       if ($self->{locale} && ! exists $option->{no_locales}) {
-           $complete_cmd = "LC_ALL=$self->{locale} ; export LC_ALL; $complete_cmd ";
-       }
-
-       if ($self->{source_profile}) {
-           $complete_cmd = ". ~/.profile >/dev/null 2>&1 ; $complete_cmd";
-       }
-
-
-       if ($self->{source_global_profile}) {
-           $complete_cmd = ". /etc/profile >/dev/null 2>&1 ; $complete_cmd";
-       }
-
+      $complete_cmd = $self->{__env__} . " $complete_cmd ";
     }
-
+  }
 
 # this is due to a strange behaviour with Net::SSH2 / libssh2
 # it may occur when you run rex inside a kvm virtualized host connecting to another virtualized vm on the same hardware
-    if(Rex::Config->get_sleep_hack) {
-      $complete_cmd .= " ; f=\$? ; sleep .00000001 ; exit \$f";
-    }
-
-    if(exists $option->{preprocess_command} && ref $option->{preprocess_command} eq "CODE") {
-      $complete_cmd = $option->{preprocess_command}->($complete_cmd);
-    }
-
-    if(exists $option->{format_cmd}) {
-      $option->{format_cmd} =~ s/{{CMD}}/$complete_cmd/;
-      $complete_cmd = $option->{format_cmd};
-    }
-
-    return $complete_cmd;
+  if ( Rex::Config->get_sleep_hack ) {
+    $complete_cmd .= " ; f=\$? ; sleep .00000001 ; exit \$f";
+  }
+
+  if ( exists $option->{preprocess_command}
+    && ref $option->{preprocess_command} eq "CODE" )
+  {
+    $complete_cmd = $option->{preprocess_command}->($complete_cmd);
+  }
+
+  # rewrite the command again
+  if ( exists $option->{format_cmd} ) {
+    $complete_cmd =~ s/{{CMD}}/$cmd/;
+  }
+
+  if ( $self->{__inner_shell__} ) {
+    $complete_cmd =~ s/\\/\\\\/gms;
+    $complete_cmd =~ s/"/\\"/gms;
+    $complete_cmd =~ s/\$/\\\$/gms;
+
+    $complete_cmd = "sh -c \"$complete_cmd\"";
+  }
+
+  if ( exists $option->{prepend_command} && $option->{prepend_command} ) {
+    $complete_cmd = $option->{prepend_command} . " $complete_cmd";
+  }
+
+  return $complete_cmd;
 }
 
 1;
@@ -1,113 +1,128 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Csh;
 
 use strict;
 use warnings;
 
+use Rex::Interface::Shell::Base;
+use base qw(Rex::Interface::Shell::Base);
+
 sub new {
-    my $class = shift;
-    my $self = {};
-    $self->{path} = undef;
-    bless($self, $class);
-    
-    return $self;
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
+
+  return $self;
 }
 
 sub path {
-    my ($self, $path ) = @_;
-    $self->{path} = $path;
+  my ( $self, $path ) = @_;
+  $self->{path} = $path;
 }
 
 sub source_global_profile {
-    my ($self, $parse) = @_;
-    $self->{source_global_profile} = $parse;
+  my ( $self, $parse ) = @_;
+  $self->{source_global_profile} = $parse;
 }
 
 sub source_profile {
-    my ($self, $parse) = @_;
-    $self->{source_profile} = $parse;
+  my ( $self, $parse ) = @_;
+  $self->{source_profile} = $parse;
 }
 
 sub set_locale {
-    my ($self, $locale) = @_;
-    $self->{locale} = $locale;
+  my ( $self, $locale ) = @_;
+  $self->{locale} = $locale;
 }
 
-sub exec {
-    my ($self, $cmd, $option) = @_;
-    my $complete_cmd = $cmd;
-
-    if(exists $option->{path}) {
-      $self->path($option->{path});
-    }
-
-    if(exists $option->{no_sh}) {
+# sub set_env {
+#   my ( $self, $env ) = @_;
+#   my $cmd = undef;
+#
+#   die("Error: env must be a hash")
+#     if ( ref $env ne "HASH" );
+#
+#   while ( my ( $k, $v ) = each($env) ) {
+#     $cmd .= "setenv $k \"$v\"; ";
+#     $self->{env_raw} .= "$k $v";
+#   }
+#
+#   $self->{env} = $cmd;
+# }
 
-       if(exists $option->{cwd}) {
-          $option->{format_cmd} = "cd $option->{cwd} && $option->{format_cmd} ";
-       }
+sub exec {
+  my ( $self, $cmd, $option ) = @_;
 
-       if ($self->{path}) {
-          $option->{format_cmd} = "set PATH=$self->{path}; $option->{format_cmd} ";
-       }
+  if ( exists $option->{path} ) {
+    $self->path( $option->{path} );
+  }
 
-       if ($self->{locale}) {
-          $option->{format_cmd} = "set LC_ALL=$self->{locale} ; $option->{format_cmd} ";
-       }
+  # if ( exists $option->{env} ) {
+  #   $self->set_env( $option->{env} );
+  # }
 
-       if ($self->{source_profile}) {
-          # csh is using .login
-          $option->{format_cmd} = "source ~/.login >& /dev/null ; $option->{format_cmd} ";
-       }
+  my $complete_cmd = $cmd;
 
-       if ($self->{source_global_profile}) {
-           $option->{format_cmd} = "source /etc/profile >& /dev/null ; $option->{format_cmd} ";
-       }
+  # if we need to execute without an sh command,
+  # use the format_cmd key
+  if ( exists $option->{no_sh} ) {
+    $complete_cmd = $option->{format_cmd};
+  }
 
-    }
-    else {
+  if ( exists $option->{cwd} ) {
+    $complete_cmd = "cd $option->{cwd} && $complete_cmd";
+  }
 
-       if(exists $option->{cwd}) {
-         $complete_cmd = "cd $option->{cwd} && $complete_cmd";
-       }
+  if ( $self->{path} ) {
+    $complete_cmd = "set PATH=$self->{path}; $complete_cmd ";
+  }
 
-       if ($self->{path}) {
-          $complete_cmd = "set PATH=$self->{path}; $complete_cmd ";
-       }
+  if ( $self->{locale} ) {
+    $complete_cmd = "set LC_ALL=$self->{locale} ; $complete_cmd ";
+  }
 
-       if ($self->{locale}) {
-          $complete_cmd = "set LC_ALL=$self->{locale} ; $complete_cmd ";
-       }
+  if ( $self->{source_profile} ) {
 
-       if ($self->{source_profile}) {
-          # csh is using .login
-          $complete_cmd = "source ~/.login >& /dev/null ; $complete_cmd";
-       }
+    # csh is using .login
+    $complete_cmd = "source ~/.login >& /dev/null ; $complete_cmd";
+  }
 
-       if ($self->{source_global_profile}) {
-           $complete_cmd = "source /etc/profile >& /dev/null ; $complete_cmd";
-       }
+  if ( $self->{source_global_profile} ) {
+    $complete_cmd = "source /etc/profile >& /dev/null ; $complete_cmd";
+  }
 
+  if ( exists $self->{__env__} ) {
+    if ( ref $self->{__env__} eq "HASH" ) {
+      for my $key ( keys %{ $self->{__env__} } ) {
+        my $val = $self->{__env__}->{$key};
+        $val =~ s/"/"'"'"/gms;
+        $complete_cmd = " setenv $key \"$val\" ; $complete_cmd ";
+      }
     }
-
+    else {
+      $complete_cmd = $self->{__env__} . " $complete_cmd ";
+    }
+  }
 
 # this is due to a strange behaviour with Net::SSH2 / libssh2
 # it may occur when you run rex inside a kvm virtualized host connecting to another virtualized vm on the same hardware
-    if(Rex::Config->get_sleep_hack) {
-      $complete_cmd .= " ; set f=\$? ; sleep .00000001 ; exit \$f";
-    }
+  if ( Rex::Config->get_sleep_hack ) {
+    $complete_cmd .= " ; set f=\$? ; sleep .00000001 ; exit \$f";
+  }
 
-    if(exists $option->{format_cmd}) {
-      $option->{format_cmd} =~ s/{{CMD}}/$complete_cmd/;
-      $complete_cmd = $option->{format_cmd};
-    }
+  # rewrite the command again
+  if ( exists $option->{format_cmd} ) {
+    $complete_cmd =~ s/{{CMD}}/$cmd/;
+  }
 
-    return $complete_cmd;
+  return $complete_cmd;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Default;
 
 use Rex::Interface::Shell::Bash;
@@ -11,13 +11,13 @@ use Rex::Interface::Shell::Bash;
 use base qw(Rex::Interface::Shell::Bash);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
 
-    bless($self, $class);
-    
-    return $self;
+  return $self;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Ksh;
 
 use strict;
@@ -14,13 +14,13 @@ use Rex::Interface::Shell::Bash;
 use base qw(Rex::Interface::Shell::Bash);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
 
-    bless($self, $class);
-    
-    return $self;
+  return $self;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Sh;
 
 use strict;
@@ -14,15 +14,13 @@ use Rex::Interface::Shell::Bash;
 use base qw(Rex::Interface::Shell::Bash);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
-
-    bless($self, $class);
-    
-    return $self;
-}
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
 
+  bless( $self, $class );
 
+  return $self;
+}
 
 1;
@@ -1,24 +1,23 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
-package Rex::Interface::Shell::Tcsh;
 
+package Rex::Interface::Shell::Tcsh;
 
 use Rex::Interface::Shell::Csh;
 
 use base qw(Rex::Interface::Shell::Csh);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
 
-    bless($self, $class);
-    
-    return $self;
+  return $self;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+
 package Rex::Interface::Shell::Zsh;
 
 use strict;
@@ -14,13 +14,13 @@ use Rex::Interface::Shell::Bash;
 use base qw(Rex::Interface::Shell::Bash);
 
 sub new {
-    my $class = shift;
-    my $proto = ref($class) || $class;
-    my $self = $proto->SUPER::new(@_);
+  my $class = shift;
+  my $proto = ref($class) || $class;
+  my $self  = $proto->SUPER::new(@_);
+
+  bless( $self, $class );
 
-    bless($self, $class);
-    
-    return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Interface::Shell;
@@ -12,20 +12,25 @@ use warnings;
 use Rex::Logger;
 
 sub create {
-    my ($class, $shell) = @_;
-
-    $shell =~ s/[\r\n]//gms; # sometimes there are some wired things...
-
-    my $klass = "Rex::Interface::Shell::\u$shell";
+  my ( $class, $shell ) = @_;
+
+  $shell =~ s/[\r\n]//gms;    # sometimes there are some wired things...
+
+  my $klass = "Rex::Interface::Shell::\u$shell";
+  eval "use $klass";
+  if ($@) {
+    Rex::Logger::info(
+      "Can't load wanted shell: '$shell' ('$klass'). Using default shell.",
+      "warn" );
+    Rex::Logger::info(
+      "If you want to help the development of Rex please report this issue in our Github issue tracker.",
+      "warn"
+    );
+    $klass = "Rex::Interface::Shell::Default";
     eval "use $klass";
-    if ($@) {
-        Rex::Logger::info("Can't load wanted shell: $shell. Using default shell.", "warn");
-        Rex::Logger::info("If you want to help the development of Rex please report this issue in our Github issue tracker.", "warn");
-        $klass = "Rex::Interface::Shell::Default";
-        eval "use $klass";    
-    }
-
-    return $klass->new;
+  }
+
+  return $klass->new;
 }
 
 1;
@@ -1,12 +1,12 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 
 package Rex::Inventory::Bios;
-   
+  
 use strict;
 use warnings;
 
@@ -18,12 +18,12 @@ use Rex::Inventory::DMIDecode;
 
 sub get {
 
-   if(Rex::Hardware::Host::get_operating_system() eq "SunOS") {
-      return Rex::Inventory::SMBios->new;
-   }
-   else {
-      return Rex::Inventory::DMIDecode->new;
-   }
+  if(Rex::Hardware::Host::get_operating_system() eq "SunOS") {
+    return Rex::Inventory::SMBios->new;
+  }
+  else {
+    return Rex::Inventory::DMIDecode->new;
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::BaseBoard;
@@ -15,18 +15,18 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("Base Board Information");
 
 __PACKAGE__->has([ 'Manufacturer', 
-                   'Serial Number',
-                   'Version',
-                   'Product Name', ]);
+             'Serial Number',
+             'Version',
+             'Product Name', ]);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::Bios;
@@ -15,17 +15,17 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("BIOS Information");
 
 __PACKAGE__->has([ 'Vendor', 
-                   'Version',
-                   'Release Date', ]);
+             'Version',
+             'Release Date', ]);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::CPU;
@@ -15,32 +15,32 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("Processor Information");
 
 __PACKAGE__->has([ 'Max Speed', 
-                   'Serial Number',
-                   'Family',
-                   'Core Enabled',
-                   'Version',
-                   'Status',
-                   'Upgrade',
-                   'Thread Count', ], 1);  # is_array 1
+             'Serial Number',
+             'Family',
+             'Core Enabled',
+             'Version',
+             'Status',
+             'Upgrade',
+             'Thread Count', ], 1);  # is_array 1
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub num_cores {
-   my ($self) = @_;
-   return $self->get_core_enabled;
+  my ($self) = @_;
+  return $self->get_core_enabled;
 }
 
 sub get_socket_type {
-   my ($self) = @_;
-   return $self->get_upgrade;
+  my ($self) = @_;
+  return $self->get_upgrade;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::Memory;
@@ -15,38 +15,38 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("Memory Device");
 
 __PACKAGE__->has([ 'Part Number', 
-                   'Serial Number',
-                   'Type',
-                   'Speed',
-                   'Size',
-                   'Manufacturer',
-                   'Bank Locator',
-                   'Form Factor',
-                   'Locator', ], 1);  # is_array 1
+             'Serial Number',
+             'Type',
+             'Speed',
+             'Size',
+             'Manufacturer',
+             'Bank Locator',
+             'Form Factor',
+             'Locator', ], 1);  # is_array 1
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub get {
 
-   my ($self, $key, $is_array) = @_;
-   if($key eq "Type") {
-      my $ret = $self->_search_for($key, $is_array);
-      if($ret eq "<OUT OF SPEC>") {
-         return "";
-      }
+  my ($self, $key, $is_array) = @_;
+  if($key eq "Type") {
+    my $ret = $self->_search_for($key, $is_array);
+    if($ret eq "<OUT OF SPEC>") {
+      return "";
+    }
 
-      return $ret;
-   }
+    return $ret;
+  }
 
-   return $self->SUPER::get($key, $is_array);
+  return $self->SUPER::get($key, $is_array);
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::MemoryArray;
@@ -15,18 +15,18 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("Physical Memory Array");
 
 __PACKAGE__->has([ 'Number Of Devices', 
-                   'Error Correction Type',
-                   'Maximum Capacity',
-                   'Location', ], 1);
+             'Error Correction Type',
+             'Maximum Capacity',
+             'Location', ], 1);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::Section;
@@ -18,123 +18,123 @@ use vars qw($SECTION @EXPORT);
 $SECTION = {};
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub section {
-   my ($class, $section) = @_;
-   $SECTION->{$class} = $section;
+  my ($class, $section) = @_;
+  $SECTION->{$class} = $section;
 }
 
 sub has {
-   my ($class, $item, $is_array) = @_;
-   
-   unless(ref($item) eq "ARRAY") {
-      my $_tmp = $item;
-      $item = [$_tmp];
-   }
-
-   no strict 'refs';
-
-   for my $itm (@{$item}) {
-      my $o_itm = $itm;
-      $itm =~ s/[^a-zA-Z0-9_]+/_/g;
-      *{"${class}::get_\L$itm"} = sub {
-         my $self = shift;
-         return $self->get($o_itm, $is_array);
-      };
-
-      push(@{"${class}::items"}, "\L$itm");
-   }
-
-   use strict;
+  my ($class, $item, $is_array) = @_;
+  
+  unless(ref($item) eq "ARRAY") {
+    my $_tmp = $item;
+    $item = [$_tmp];
+  }
+
+  no strict 'refs';
+
+  for my $itm (@{$item}) {
+    my $o_itm = $itm;
+    $itm =~ s/[^a-zA-Z0-9_]+/_/g;
+    *{"${class}::get_\L$itm"} = sub {
+      my $self = shift;
+      return $self->get($o_itm, $is_array);
+    };
+
+    push(@{"${class}::items"}, "\L$itm");
+  }
+
+  use strict;
 }
 
 sub dmi {
 
-   my ($self) = @_;
-   return $self->{"dmi"};
+  my ($self) = @_;
+  return $self->{"dmi"};
 
 
 }
 
 sub get {
 
-   my ($self, $key, $is_array) = @_;
-   return $self->_search_for($key, $is_array);
+  my ($self, $key, $is_array) = @_;
+  return $self->_search_for($key, $is_array);
 
 }
 
 sub get_all {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   use Data::Dumper;
-   my $r = ref($self);
+  use Data::Dumper;
+  my $r = ref($self);
 
-   no strict 'refs';
-   my @items = @{"${r}::items"};
-   use strict;
+  no strict 'refs';
+  my @items = @{"${r}::items"};
+  use strict;
 
-   my $ret = {};
-   for my $itm (@items) {
-      my $f = "get_$itm";
-      $ret->{$itm} = $self->$f();
-   }
+  my $ret = {};
+  for my $itm (@items) {
+    my $f = "get_$itm";
+    $ret->{$itm} = $self->$f();
+  }
 
-   return $ret;
+  return $ret;
 
 }
 
 sub dump {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   require Data::Dumper;
-   print Data::Dumper::Dumper($self->dmi->get_tree($SECTION->{ref($self)}));
+  require Data::Dumper;
+  print Data::Dumper::Dumper($self->dmi->get_tree($SECTION->{ref($self)}));
 
 }
 
 sub _search_for {
-   my ($self, $key, $is_array) = @_;
-
-   unless($self->dmi->get_tree($SECTION->{ref($self)})) {
-      #die $SECTION->{ref($self)} . " not supported";
-      return;
-   }
-
-   my $idx = 0;
-   for my $entry (@{ $self->dmi->get_tree($SECTION->{ref($self)}) }) {
-      my ($_key) = keys %{$entry};
-      if($is_array) {
-         if ($idx != $self->get_index()) {
-            ++$idx;
-            next;
-         }
+  my ($self, $key, $is_array) = @_;
+
+  unless($self->dmi->get_tree($SECTION->{ref($self)})) {
+    #die $SECTION->{ref($self)} . " not supported";
+    return;
+  }
+
+  my $idx = 0;
+  for my $entry (@{ $self->dmi->get_tree($SECTION->{ref($self)}) }) {
+    my ($_key) = keys %{$entry};
+    if($is_array) {
+      if ($idx != $self->get_index()) {
+        ++$idx;
+        next;
       }
-
-      if(exists $entry->{$key}) {
-         return $entry->{$key};
-      }
-      else {
-         return "";
-      }
-      ++$idx;
-   }
-
-   return "";
+    }
+
+    if(exists $entry->{$key}) {
+      return $entry->{$key};
+    }
+    else {
+      return "";
+    }
+    ++$idx;
+  }
+
+  return "";
 }
 
 sub get_index {
 
-   my ($self) = @_;
-   return $self->{"index"};
+  my ($self) = @_;
+  return $self->{"index"};
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode::SystemInformation;
@@ -15,21 +15,21 @@ use base qw(Rex::Inventory::DMIDecode::Section);
 __PACKAGE__->section("System Information");
 
 __PACKAGE__->has([ 'Manufacturer', 
-                   'Product Name',
-                   'UUID',
-                   'SKU Number',
-                   'Family',
-                   'Version',
-                   'Serial Number', ]);
+             'Product Name',
+             'UUID',
+             'SKU Number',
+             'Family',
+             'Version',
+             'Serial Number', ]);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::DMIDecode;
@@ -20,200 +20,200 @@ use Rex::Commands::Run;
 use Rex::Helper::Run;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->_read_dmidecode();
+  $self->_read_dmidecode();
 
-   return $self;
+  return $self;
 }
 
 sub get_tree {
-   my ($self, $section) = @_;
+  my ($self, $section) = @_;
 
-   if($section) {
-      return $self->{"__dmi"}->{$section};
-   }
-   
-   return $self->{"__dmi"};
+  if($section) {
+    return $self->{"__dmi"}->{$section};
+  }
+  
+  return $self->{"__dmi"};
 }
 
 sub get_base_board {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   return Rex::Inventory::DMIDecode::BaseBoard->new(dmi => $self);
+  return Rex::Inventory::DMIDecode::BaseBoard->new(dmi => $self);
 }
 
 sub get_bios {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   return Rex::Inventory::DMIDecode::Bios->new(dmi => $self);
+  return Rex::Inventory::DMIDecode::Bios->new(dmi => $self);
 }
 
 sub get_system_information {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   return Rex::Inventory::DMIDecode::SystemInformation->new(dmi => $self);
+  return Rex::Inventory::DMIDecode::SystemInformation->new(dmi => $self);
 }
 
 
 sub get_cpus {
 
-   my ($self) = @_;
-   my @cpus = ();
-   my $tree = $self->get_tree("Processor Information");
-   my $idx=0;
-   for my $cpu ( @{ $tree } ) {
-      if($cpu->{"Status"} =~m/Populated/) {
-         push(@cpus, Rex::Inventory::DMIDecode::CPU->new(dmi => $self, index => $idx));
-      }
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @cpus = ();
+  my $tree = $self->get_tree("Processor Information");
+  my $idx=0;
+  for my $cpu ( @{ $tree } ) {
+    if($cpu->{"Status"} =~m/Populated/) {
+      push(@cpus, Rex::Inventory::DMIDecode::CPU->new(dmi => $self, index => $idx));
+    }
+    ++$idx;
+  }
 
-   return @cpus;
+  return @cpus;
 
 }
 
 sub get_memory_modules {
 
-   my ($self) = @_;
-   my @mems = ();
-   my $tree = $self->get_tree("Memory Device");
-   my $idx = 0;
-   for my $mem (@{ $tree }) {
-      if($mem->{"Size"} =~ m/\d+/) {
-         push(@mems, Rex::Inventory::DMIDecode::Memory->new(dmi => $self, index => $idx));
-      }
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @mems = ();
+  my $tree = $self->get_tree("Memory Device");
+  my $idx = 0;
+  for my $mem (@{ $tree }) {
+    if($mem->{"Size"} =~ m/\d+/) {
+      push(@mems, Rex::Inventory::DMIDecode::Memory->new(dmi => $self, index => $idx));
+    }
+    ++$idx;
+  }
 
-   return @mems;
+  return @mems;
 
 }
 
 sub get_memory_arrays {
 
-   my ($self) = @_;
-   my @mems = ();
-   my $tree = $self->get_tree("Physical Memory Array");
-   my $idx = 0;
-   for my $mema (@{ $tree }) {
-      push(@mems, Rex::Inventory::DMIDecode::MemoryArray->new(dmi => $self, index => $idx));
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @mems = ();
+  my $tree = $self->get_tree("Physical Memory Array");
+  my $idx = 0;
+  for my $mema (@{ $tree }) {
+    push(@mems, Rex::Inventory::DMIDecode::MemoryArray->new(dmi => $self, index => $idx));
+    ++$idx;
+  }
 
-   return @mems;
+  return @mems;
 
 }
 
 sub _read_dmidecode {
 
-   my ($self) = @_;
-
-   my @lines;
-   if($self->{lines}) {
-      @lines = @{ $self->{lines} };
-   }
-   else {
-      my $dmidecode = can_run("dmidecode");
+  my ($self) = @_;
 
-      unless($dmidecode) {
-         #Rex::Logger::debug("Please install dmidecode on the target system.");
-         #return;
-         $dmidecode = "dmidecode";
-      }
+  my @lines;
+  if($self->{lines}) {
+    @lines = @{ $self->{lines} };
+  }
+  else {
+    my $dmidecode = can_run("dmidecode");
 
-      @lines = i_run $dmidecode;
-      if($? != 0) {
-         Rex::Logger::debug("Please install dmidecode on the target system.");
-         return;
-      }
-   }
-   chomp @lines;
+    unless($dmidecode) {
+      #Rex::Logger::debug("Please install dmidecode on the target system.");
+      #return;
+      $dmidecode = "dmidecode";
+    }
 
-   unless(@lines) {
+    @lines = i_run $dmidecode;
+    if($? != 0) {
       Rex::Logger::debug("Please install dmidecode on the target system.");
       return;
-   }
-
-   my %section = ();
-   my $section = ""; 
-   my $new_section = 0;
-   my $sub_section = "";
-
-   for my $l (@lines) {
-
-      next if $l =~ m/^Handle/;
-      next if $l =~ m/^#/;
-      next if $l =~ m/^SMBIOS/;
-      next if $l =~ m/^$/;
-      last if $l =~ m/^End Of Table$/;
-
-      # for openbsd
-      $l =~ s/        /\t/g;
-
-      unless(substr($l, 0, 1) eq "\t") {
-         $section = $l;
-         $new_section = 1;
-         next;
+    }
+  }
+  chomp @lines;
+
+  unless(@lines) {
+    Rex::Logger::debug("Please install dmidecode on the target system.");
+    return;
+  }
+
+  my %section = ();
+  my $section = ""; 
+  my $new_section = 0;
+  my $sub_section = "";
+
+  for my $l (@lines) {
+
+    next if $l =~ m/^Handle/;
+    next if $l =~ m/^#/;
+    next if $l =~ m/^SMBIOS/;
+    next if $l =~ m/^$/;
+    last if $l =~ m/^End Of Table$/;
+
+    # for openbsd
+    $l =~ s/      /\t/g;
+
+    unless(substr($l, 0, 1) eq "\t") {
+      $section = $l;
+      $new_section = 1;
+      next;
+    }
+
+    my $line = $l;
+    $line =~ s/^\t+//g;
+    $line =~ s/\s+$//g;
+
+    next if $l =~ m/^$/;
+
+    if($l =~ m/^\t[a-zA-Z0-9]/) {
+      if(exists $section{$section} && ! ref($section{$section})) {
+        my $content = $section{$section};
+        $section{$section} = [];
+        my @arr = ();
+        my ($key, $val) = split(/: /, $line, 2);
+        $key =~ s/:$//; 
+        $sub_section = $key;
+        #push (@{$section{$section}}, $content);
+        push (@{$section{$section}}, {$key => $val});
+        $new_section = 0;
+        next;
       }
-
-      my $line = $l;
-      $line =~ s/^\t+//g;
-      $line =~ s/\s+$//g;
-
-      next if $l =~ m/^$/;
-
-      if($l =~ m/^\t[a-zA-Z0-9]/) {
-         if(exists $section{$section} && ! ref($section{$section})) {
-            my $content = $section{$section};
-            $section{$section} = [];
-            my @arr = ();
-            my ($key, $val) = split(/: /, $line, 2);
-            $key =~ s/:$//; 
-            $sub_section = $key;
-            #push (@{$section{$section}}, $content);
-            push (@{$section{$section}}, {$key => $val});
-            $new_section = 0;
-            next;
-         }
-         elsif(exists $section{$section} && ref($section{$section})) {
-            if($new_section) {
-               push (@{$section{$section}}, {});
-               $new_section = 0;
-            }
-            my ($key, $val) = split(/: /, $line, 2);
-            $key =~ s/:$//; 
-            $sub_section = $key;
-            my $href = $section{$section}->[-1];
-            #push (@{$section{$section}}, {$key => $val});
-            $href->{$key} = $val;
-            next;
-         }
-
-         my ($key, $val) = split(/: /, $line, 2);
-         if(!$val) { $key =~ s/:$//; }
-         $sub_section = $key;
-         $section{$section} = [{$key => $val}];
-         $new_section = 0;
+      elsif(exists $section{$section} && ref($section{$section})) {
+        if($new_section) {
+          push (@{$section{$section}}, {});
+          $new_section = 0;
+        }
+        my ($key, $val) = split(/: /, $line, 2);
+        $key =~ s/:$//; 
+        $sub_section = $key;
+        my $href = $section{$section}->[-1];
+        #push (@{$section{$section}}, {$key => $val});
+        $href->{$key} = $val;
+        next;
       }
-      elsif($l =~ m/^\t\t[a-zA-Z0-9]/) {
-         my $href = $section{$section}->[-1];
-         if(! ref($href->{$sub_section})) {
-            $href->{$sub_section} = [];
-         }
 
-         push(@{$href->{$sub_section}}, $line);
+      my ($key, $val) = split(/: /, $line, 2);
+      if(!$val) { $key =~ s/:$//; }
+      $sub_section = $key;
+      $section{$section} = [{$key => $val}];
+      $new_section = 0;
+    }
+    elsif($l =~ m/^\t\t[a-zA-Z0-9]/) {
+      my $href = $section{$section}->[-1];
+      if(! ref($href->{$sub_section})) {
+        $href->{$sub_section} = [];
       }
 
+      push(@{$href->{$sub_section}}, $line);
+    }
+
 
 
-   }
+  }
 
-   $self->{"__dmi"} = \%section;
+  $self->{"__dmi"} = \%section;
 
 }
 
@@ -1,27 +1,27 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::HP::ACU;
-    
+   
 use strict;
 use warnings;
 
 use Rex::Commands::Run;
 use Rex::Helper::Run;
-    
+   
 sub get {
 
-   if(can_run("hpacucli")) {
-      my @lines = i_run "/usr/sbin/hpacucli controller all show config detail";
-      my $ret = parse_config(@lines);
-      return $ret;
-   }
-   else {
-      return 0;
-   }
+  if(can_run("hpacucli")) {
+    my @lines = i_run "/usr/sbin/hpacucli controller all show config detail";
+    my $ret = parse_config(@lines);
+    return $ret;
+  }
+  else {
+    return 0;
+  }
 
 }
 
@@ -38,226 +38,226 @@ sub get {
 #
 sub parse_config
 {
-   my (@lines) = @_;
+  my (@lines) = @_;
 
-   my $controller = {};
-   my $current_controller         = 0;
-   my $current_array                = undef;
-   my $current_logical_drive    = undef;
-   my $current_mirror_group      = undef;
-   my $current_physical_drive   = undef;
+  my $controller = {};
+  my $current_controller      = 0;
+  my $current_array           = undef;
+  my $current_logical_drive   = undef;
+  my $current_mirror_group    = undef;
+  my $current_physical_drive  = undef;
 
-   LINE: for my $line (@lines)
-   {
-      chomp $line;
+  LINE: for my $line (@lines)
+  {
+    chomp $line;
 
-      next if($line =~ /^$/);
+    next if($line =~ /^$/);
 
-      if($line !~ /^[ ]+/)
-      {
-         $current_controller       = $current_controller + 1;
-         $current_array               = undef;
-         $current_logical_drive   = undef;
-         $current_mirror_group    = undef;
-         $current_physical_drive = undef;
-         $controller->{$current_controller} = {};
-         $controller->{$current_controller}
-            ->{'description'} = $line;
-         next;
-      }
+    if($line !~ /^[ ]+/)
+    {
+      $current_controller     = $current_controller + 1;
+      $current_array          = undef;
+      $current_logical_drive  = undef;
+      $current_mirror_group   = undef;
+      $current_physical_drive = undef;
+      $controller->{$current_controller} = {};
+      $controller->{$current_controller}
+        ->{'description'} = $line;
+      next;
+    }
 
-      next if(!defined($current_controller));
+    next if(!defined($current_controller));
 
-      $line =~ s/^\s+//g;
-      $line =~ s/\s+$//g;
-      $line =~ s/[ ]+/ /g;
+    $line =~ s/^\s+//g;
+    $line =~ s/\s+$//g;
+    $line =~ s/[ ]+/ /g;
 
-      if($line =~ /unassigned/)
-      {
-         $current_array               = "unassigned";
-         $current_logical_drive   = undef;
-         $current_mirror_group    = undef;
-         $current_physical_drive = undef;
-         $controller->{$current_controller}
-            ->{'unassigned'} = {};
-         $controller->{$current_controller}
-            ->{'unassigned'}->{'physical_drive'} = {};
-         next;
-      }
+    if($line =~ /unassigned/)
+    {
+      $current_array          = "unassigned";
+      $current_logical_drive  = undef;
+      $current_mirror_group   = undef;
+      $current_physical_drive = undef;
+      $controller->{$current_controller}
+        ->{'unassigned'} = {};
+      $controller->{$current_controller}
+        ->{'unassigned'}->{'physical_drive'} = {};
+      next;
+    }
 
-      if($line =~ /Array: ([A-Z]+)/)
-      {
-         $current_array               = $1;
-         $current_logical_drive   = undef;
-         $current_mirror_group    = undef;
-         $current_physical_drive = undef;
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array} = {};
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array}
-            ->{'logical_drive'} = {};
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array}
-            ->{'physical_drive'} = {};
-         next;
-      }
+    if($line =~ /Array: ([A-Z]+)/)
+    {
+      $current_array          = $1;
+      $current_logical_drive  = undef;
+      $current_mirror_group   = undef;
+      $current_physical_drive = undef;
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array} = {};
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array}
+        ->{'logical_drive'} = {};
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array}
+        ->{'physical_drive'} = {};
+      next;
+    }
 
-      if($line =~ /Logical Drive: ([0-9]+)/)
-      {
-         $current_logical_drive   = $1;
-         $current_physical_drive = undef;
-         $current_mirror_group    = undef;
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array}
-            ->{'logical_drive'}->{$current_logical_drive} = {};
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array}
-            ->{'logical_drive'}->{$current_logical_drive}
-            ->{'mirror_group'} = {};
-         next;
-      }
+    if($line =~ /Logical Drive: ([0-9]+)/)
+    {
+      $current_logical_drive  = $1;
+      $current_physical_drive = undef;
+      $current_mirror_group   = undef;
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array}
+        ->{'logical_drive'}->{$current_logical_drive} = {};
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array}
+        ->{'logical_drive'}->{$current_logical_drive}
+        ->{'mirror_group'} = {};
+      next;
+    }
 
-      if($line =~ /physicaldrive ([0-9IC:]+)/ and $line !~ /port/)
+    if($line =~ /physicaldrive ([0-9IC:]+)/ and $line !~ /port/)
+    {
+      $current_logical_drive  = undef;
+      $current_physical_drive = $1;
+      $current_mirror_group   = undef;
+      if($current_array eq 'unassigned')
       {
-         $current_logical_drive   = undef;
-         $current_physical_drive = $1;
-         $current_mirror_group    = undef;
-         if($current_array eq 'unassigned')
-         {
-            $controller->{$current_controller}
-               ->{'unassigned'}
-               ->{'physical_drive'}->{$current_physical_drive} = {};
-         } else {
-            $controller->{$current_controller}
-               ->{'array'}->{$current_array}
-               ->{'physical_drive'}->{$current_physical_drive} = {};
-         }
-         next;
+        $controller->{$current_controller}
+          ->{'unassigned'}
+          ->{'physical_drive'}->{$current_physical_drive} = {};
+      } else {
+        $controller->{$current_controller}
+          ->{'array'}->{$current_array}
+          ->{'physical_drive'}->{$current_physical_drive} = {};
       }
+      next;
+    }
 
-      if($line =~ /Mirror Group ([0-9]+):/)
-      {
-         $current_mirror_group = $1;
-         $controller->{$current_controller}
-            ->{'array'}->{$current_array}
-            ->{'logical_drive'}->{$current_logical_drive}
-            ->{'mirror_group'}->{$current_mirror_group} = [];
-         next;
-      }
+    if($line =~ /Mirror Group ([0-9]+):/)
+    {
+      $current_mirror_group = $1;
+      $controller->{$current_controller}
+        ->{'array'}->{$current_array}
+        ->{'logical_drive'}->{$current_logical_drive}
+        ->{'mirror_group'}->{$current_mirror_group} = [];
+      next;
+    }
 
-      if(defined($current_array) 
-         and defined($current_logical_drive)
-         and defined($current_mirror_group))
+    if(defined($current_array) 
+      and defined($current_logical_drive)
+      and defined($current_mirror_group))
+    {
+      if($line =~ /physicaldrive ([0-9IC:]+) \(/)
       {
-         if($line =~ /physicaldrive ([0-9IC:]+) \(/)
-         {
-            my $current_mirror_group_list = $controller->{$current_controller}
-               ->{'array'}->{$current_array}
-               ->{'logical_drive'}->{$current_logical_drive}
-               ->{'mirror_group'}->{$current_mirror_group};
+        my $current_mirror_group_list = $controller->{$current_controller}
+          ->{'array'}->{$current_array}
+          ->{'logical_drive'}->{$current_logical_drive}
+          ->{'mirror_group'}->{$current_mirror_group};
 
-            foreach my $pd (@{$current_mirror_group_list})
-            {
-               next LINE if($pd eq $1);
-            }
-            push @{$current_mirror_group_list}, $1;
-         }
-         next;
+        foreach my $pd (@{$current_mirror_group_list})
+        {
+          next LINE if($pd eq $1);
+        }
+        push @{$current_mirror_group_list}, $1;
       }
+      next;
+    }
 
-      if(defined($current_array)
-         and defined($current_logical_drive))
+    if(defined($current_array)
+      and defined($current_logical_drive))
+    {
+      if(my ($k, $v) = &K_V($line))
       {
-         if(my ($k, $v) = &K_V($line))
-         {
-            next unless defined($k);
-            $controller->{$current_controller}
-               ->{'array'}->{$current_array}
-               ->{'logical_drive'}->{$current_logical_drive}->{$k} = $v;
-         }
-         next;
+        next unless defined($k);
+        $controller->{$current_controller}
+          ->{'array'}->{$current_array}
+          ->{'logical_drive'}->{$current_logical_drive}->{$k} = $v;
       }
+      next;
+    }
 
-      if(defined($current_array)
-         and defined($current_physical_drive))
-      {
-         if(my ($k, $v) = &K_V($line))
-         {
-            next unless defined($k);
-            if($current_array eq 'unassigned')
-            {
-               $controller->{$current_controller}
-                  ->{'unassigned'}
-                  ->{'physical_drive'}->{$current_physical_drive}->{$k} = $v;
-            } else {
-               $controller->{$current_controller}
-                  ->{'array'}->{$current_array}
-                  ->{'physical_drive'}->{$current_physical_drive}->{$k} = $v;
-            }
-         }
-         next;
-      }
-   
-      if(defined($current_array))
+    if(defined($current_array)
+      and defined($current_physical_drive))
+    {
+      if(my ($k, $v) = &K_V($line))
       {
-         if(my ($k, $v) = &K_V($line))
-         {
-            next unless defined($k);
-            $controller->{$current_controller}
-               ->{'array'}->{$current_array}->{$k} = $v;
-         }
-         next;
+        next unless defined($k);
+        if($current_array eq 'unassigned')
+        {
+          $controller->{$current_controller}
+            ->{'unassigned'}
+            ->{'physical_drive'}->{$current_physical_drive}->{$k} = $v;
+        } else {
+          $controller->{$current_controller}
+            ->{'array'}->{$current_array}
+            ->{'physical_drive'}->{$current_physical_drive}->{$k} = $v;
+        }
       }
-
+      next;
+    }
+  
+    if(defined($current_array))
+    {
       if(my ($k, $v) = &K_V($line))
       {
-         next unless defined($k);
-         $controller->{$current_controller}->{$k} = $v;
+        next unless defined($k);
+        $controller->{$current_controller}
+          ->{'array'}->{$current_array}->{$k} = $v;
       }
       next;
-   }
-   
-   return $controller;
+    }
+
+    if(my ($k, $v) = &K_V($line))
+    {
+      next unless defined($k);
+      $controller->{$current_controller}->{$k} = $v;
+    }
+    next;
+  }
+  
+  return $controller;
 }
 
 sub K
 {
-   my ($k) = @_;
+  my ($k) = @_;
 
-   $k = lc $k;   
-   $k =~ s/[ \/\-]/_/g;
-   $k =~ s/[\(\)]//g;
+  $k = lc $k;  
+  $k =~ s/[ \/\-]/_/g;
+  $k =~ s/[\(\)]//g;
 
-   return $k;
+  return $k;
 }
 
 sub V
 {
-   my ($k, $v) = @_;
+  my ($k, $v) = @_;
 
-   if($k eq 'accelerator_ratio')
-   {
-      if($v =~ /([0-9]+)% Read \/ ([0-9]+)% Write/)
-      {
-         return {'read' => $1, 'write' => $2};
-      }
-   }
+  if($k eq 'accelerator_ratio')
+  {
+    if($v =~ /([0-9]+)% Read \/ ([0-9]+)% Write/)
+    {
+      return {'read' => $1, 'write' => $2};
+    }
+  }
 
-   return $v;
+  return $v;
 }
 
 sub K_V($)
 {
-   my ($line) = @_;
+  my ($line) = @_;
 
-   if($line =~ /(.+):\s+(.+)/)
-   {
-      my $k = &K($1);
-      my $v = &V($k, $2);
-      return ($k, $v);
-   }
+  if($line =~ /(.+):\s+(.+)/)
+  {
+    my $k = &K($1);
+    my $v = &V($k, $2);
+    return ($k, $v);
+  }
 
-   return (undef, undef);
+  return (undef, undef);
 }
-    
+   
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::Hal::Object::Net;
@@ -14,21 +14,21 @@ use base qw(Rex::Inventory::Hal::Object);
 
 __PACKAGE__->has([
 
-   { key => "net.interface", accessor => "dev", },
-   { key => "net.address",   accessor => "mac", },
-   { key => "info.product",  accessor => "product", parent => 1, },
-   { key => "info.vendor",   accessor => "vendor",  parent => 1, },
+  { key => "net.interface", accessor => "dev", },
+  { key => "net.address",  accessor => "mac", },
+  { key => "info.product",  accessor => "product", parent => 1, },
+  { key => "info.vendor",  accessor => "vendor",  parent => 1, },
 
 ]);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::Hal::Object::Storage;
@@ -18,68 +18,68 @@ use base qw(Rex::Inventory::Hal::Object);
 
 __PACKAGE__->has([
 
-   { key => "block.device",   accessor => "dev", },
-   #{ key => "storage.size",   accessor => "size", },
-   { key => "info.product",   accessor => "product" },
-   { key => ["storage.vendor", "info.vendor"], accessor => "vendor" },
-   { key => "storage.bus",    accessor => "bus" },
+  { key => "block.device",  accessor => "dev", },
+  #{ key => "storage.size",  accessor => "size", },
+  { key => "info.product",  accessor => "product" },
+  { key => ["storage.vendor", "info.vendor"], accessor => "vendor" },
+  { key => "storage.bus",   accessor => "bus" },
 
 ]);
 
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_cdrom {
 
-   my ($self) = @_;
-   if( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
-      return 1;
-   }
+  my ($self) = @_;
+  if( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
+    return 1;
+  }
 
 }
 
 sub is_volume {
-   
-   my ($self) = @_;
-   if( grep { ! /^false$/ } $self->get('block.is_volume') ) {
-      return 1;
-   }
+  
+  my ($self) = @_;
+  if( grep { ! /^false$/ } $self->get('block.is_volume') ) {
+    return 1;
+  }
 
 }
 
 sub is_floppy {
-   
-   my ($self) = @_;
-   if( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
-      return 1;
-   }
+  
+  my ($self) = @_;
+  if( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
+    return 1;
+  }
 
 }
 
 sub get_size {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $os = get_operating_system();
+  my $os = get_operating_system();
 
-   if($os =~ m/BSD/) {
-      my ($info_line) = run "diskinfo " . $self->get_dev;
-      my ($dev_name, $sector, $size, $sectors, $stripesize, $stripeoffset, $cylinders, $heads) = split(/\s+/, $info_line);
+  if($os =~ m/BSD/) {
+    my ($info_line) = run "diskinfo " . $self->get_dev;
+    my ($dev_name, $sector, $size, $sectors, $stripesize, $stripeoffset, $cylinders, $heads) = split(/\s+/, $info_line);
 
-      return $size;
-   }
-   else {
-      return $self->get("storage.size");
-   }
+    return $size;
+  }
+  else {
+    return $self->get("storage.size");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::Hal::Object::Volume;
@@ -15,63 +15,63 @@ use base qw(Rex::Inventory::Hal::Object);
 
 __PACKAGE__->has([
 
-   { key => "block.device",  accessor => "dev", },
-   { key => "volume.size",   accessor => "size", },
-   { key => "volume.fstype", accessor => "fstype" },
-   { key => "volume.uuid",   accessor => "uuid" },
+  { key => "block.device",  accessor => "dev", },
+  { key => "volume.size",  accessor => "size", },
+  { key => "volume.fstype", accessor => "fstype" },
+  { key => "volume.uuid",  accessor => "uuid" },
 
 ]);
 
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_parition {
 
-   my ($self) = @_;
-   return $self->get('volume.is_partition') eq "true"?1:0;
+  my ($self) = @_;
+  return $self->get('volume.is_partition') eq "true"?1:0;
 
 }
 
 sub is_mounted {
 
-   my ($self) = @_;
-   return $self->get('volume.is_mounted') eq "true"?1:0;
+  my ($self) = @_;
+  return $self->get('volume.is_mounted') eq "true"?1:0;
 
 }
 
 sub is_cdrom {
 
-   my ($self) = @_;
-   if( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
-      return 1;
-   }
+  my ($self) = @_;
+  if( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
+    return 1;
+  }
 
 }
 
 sub is_volume {
-   
-   my ($self) = @_;
-   if( grep { ! /^false$/ } $self->get('block.is_volume') ) {
-      return 1;
-   }
+  
+  my ($self) = @_;
+  if( grep { ! /^false$/ } $self->get('block.is_volume') ) {
+    return 1;
+  }
 
 }
 
 sub is_floppy {
-   
-   my ($self) = @_;
-   if( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
-      return 1;
-   }
+  
+  my ($self) = @_;
+  if( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
+    return 1;
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::Hal::Object;
@@ -10,47 +10,47 @@ use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub has {
 
-   my ($class, $keys) = @_;
-   for my $k (@{$keys}) {
-      my $key      = $k->{"key"};
-      my $accessor = $k->{"accessor"};
-
-      no strict 'refs';
-      *{"${class}::get_$accessor"} = sub {
-         my ($self) = @_;
-         if($k->{"parent"}) {
-            return $self->parent()->get($key);
-         }
-         else {
-            if(ref($key) eq "ARRAY") {
-               for my $_k (@{$key}) {
-                  if(my $ret = $self->get($_k)) {
-                     return $ret;
-                  }
-
-                  return "";
-               }
+  my ($class, $keys) = @_;
+  for my $k (@{$keys}) {
+    my $key    = $k->{"key"};
+    my $accessor = $k->{"accessor"};
+
+    no strict 'refs';
+    *{"${class}::get_$accessor"} = sub {
+      my ($self) = @_;
+      if($k->{"parent"}) {
+        return $self->parent()->get($key);
+      }
+      else {
+        if(ref($key) eq "ARRAY") {
+          for my $_k (@{$key}) {
+            if(my $ret = $self->get($_k)) {
+              return $ret;
             }
-            else {
-               return $self->get($key);
-            }
-         }
-      };
 
-      push(@{"${class}::items"}, $k);
-      use strict;
-   }
+            return "";
+          }
+        }
+        else {
+          return $self->get($key);
+        }
+      }
+    };
+
+    push(@{"${class}::items"}, $k);
+    use strict;
+  }
 
 }
 
@@ -58,42 +58,42 @@ sub has {
 # returns the parent of the current object
 sub parent {
 
-   my ($self) = @_;
-   return $self->{"hal"}->get_object_by_udi($self->{'info.parent'});
+  my ($self) = @_;
+  return $self->{"hal"}->get_object_by_udi($self->{'info.parent'});
 
 }
 
 sub get {
 
-   my ($self, $key) = @_;
+  my ($self, $key) = @_;
 
-   if(ref($self->{$key}) eq "ARRAY") {
-      return @{$self->{$key}};
-   }
+  if(ref($self->{$key}) eq "ARRAY") {
+    return @{$self->{$key}};
+  }
 
-   return exists $self->{$key} ?
-               $self->{$key} :
-               "";
+  return exists $self->{$key} ?
+          $self->{$key} :
+          "";
 
 }
 
 sub get_all {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $r = ref($self);
+  my $r = ref($self);
 
-   no strict 'refs';
-   my @items = @{"${r}::items"};
-   use strict;
+  no strict 'refs';
+  my @items = @{"${r}::items"};
+  use strict;
 
-   my $ret;
-   for my $itm (@items) {
-      my $f = "get_" . $itm->{"accessor"};
-      $ret->{$itm->{"accessor"}} = $self->$f();
-   }
+  my $ret;
+  for my $itm (@items) {
+    my $f = "get_" . $itm->{"accessor"};
+    $ret->{$itm->{"accessor"}} = $self->$f();
+  }
 
-   return $ret;
+  return $ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::Hal;
@@ -18,190 +18,190 @@ use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->_read_lshal();
+  $self->_read_lshal();
 
-   return $self;
+  return $self;
 }
 
 # get devices of $category
 # like net or storage
 sub get_devices_of {
 
-   my ($self, $cat, $rex_class) = @_;
-   my @ret;
+  my ($self, $cat, $rex_class) = @_;
+  my @ret;
 
-   for my $dev (keys %{ $self->{'__hal'}->{$cat} }) {
-      push( @ret, $self->get_object_by_cat_and_udi($cat, $dev, $rex_class));
-   }
+  for my $dev (keys %{ $self->{'__hal'}->{$cat} }) {
+    push( @ret, $self->get_object_by_cat_and_udi($cat, $dev, $rex_class));
+  }
 
-   return @ret;
+  return @ret;
 }
 
 # get network devices
 sub get_network_devices {
 
-   my ($self) = @_;
-   return $self->get_devices_of('net');
+  my ($self) = @_;
+  return $self->get_devices_of('net');
 
 }
 
 # get storage devices
 sub get_storage_devices {
 
-   my ($self) = @_;
-   my $os = get_operating_system();
+  my ($self) = @_;
+  my $os = get_operating_system();
 
-   if($os =~ m/BSD/) {
-      return grep { ! $_->is_cdrom && ! $_->is_volume && ! $_->is_floppy } $self->get_devices_of('block', 'storage');
-   }
-   else {
-      # default linux
-      return grep { ! $_->is_cdrom && ! $_->is_floppy } $self->get_devices_of('storage');
-   }
+  if($os =~ m/BSD/) {
+    return grep { ! $_->is_cdrom && ! $_->is_volume && ! $_->is_floppy } $self->get_devices_of('block', 'storage');
+  }
+  else {
+    # default linux
+    return grep { ! $_->is_cdrom && ! $_->is_floppy } $self->get_devices_of('storage');
+  }
 
 }
 
 # get storage volumes
 sub get_storage_volumes {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $os = get_operating_system();
+  my $os = get_operating_system();
 
-   if($os =~ m/BSD/) {
-      return grep { ! $_->is_cdrom && $_->is_volume && ! $_->is_floppy } $self->get_devices_of('block', 'volume');
-   }
-   else {
-      # default linux
-      return $self->get_devices_of('volume');
-   }
+  if($os =~ m/BSD/) {
+    return grep { ! $_->is_cdrom && $_->is_volume && ! $_->is_floppy } $self->get_devices_of('block', 'volume');
+  }
+  else {
+    # default linux
+    return $self->get_devices_of('volume');
+  }
 
 }
 
 # get a hal object from category and udi
 sub get_object_by_cat_and_udi {
-   my ($self, $cat, $udi, $rex_class) = @_;
+  my ($self, $cat, $udi, $rex_class) = @_;
 
-   $rex_class ||= $cat;
+  $rex_class ||= $cat;
 
-   my $class_name = "Rex::Inventory::Hal::Object::\u$rex_class";
-   eval "use $class_name";
-   if($@) {
-      Rex::Logger::debug("This Hal Object isn't supported yet. Falling back to Base Object.");
-      $class_name = "Rex::Inventory::Hal::Object";
-   }
+  my $class_name = "Rex::Inventory::Hal::Object::\u$rex_class";
+  eval "use $class_name";
+  if($@) {
+    Rex::Logger::debug("This Hal Object isn't supported yet. Falling back to Base Object.");
+    $class_name = "Rex::Inventory::Hal::Object";
+  }
 
-   return $class_name->new(%{$self->{'__hal'}->{$cat}->{$udi}}, hal => $self);
+  return $class_name->new(%{$self->{'__hal'}->{$cat}->{$udi}}, hal => $self);
 }
 
 # get object by udi
 sub get_object_by_udi {
-   my ($self, $udi) = @_;
+  my ($self, $udi) = @_;
 
-   for my $cat (keys %{$self->{'__hal'}}) {
-      for my $dev (keys %{$self->{'__hal'}->{$cat}}) {
-         if($dev eq $udi) {
-            return $self->get_object_by_cat_and_udi($cat, $dev);
-         }
+  for my $cat (keys %{$self->{'__hal'}}) {
+    for my $dev (keys %{$self->{'__hal'}->{$cat}}) {
+      if($dev eq $udi) {
+        return $self->get_object_by_cat_and_udi($cat, $dev);
       }
-   }
+    }
+  }
 }
 
 # private method to read lshal output
 # you don't see that...
 sub _read_lshal {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   unless(can_run "lshal") {
-      Rex::Logger::info("No lshal available");
-      die;
-   }
+  unless(can_run "lshal") {
+    Rex::Logger::info("No lshal available");
+    die;
+  }
 
-   my @lines = i_run "lshal";
-   my %devices;
-   my %tmp_devices;
+  my @lines = i_run "lshal";
+  my %devices;
+  my %tmp_devices;
 
-   my $in_dev= 0;
-   my %data;
-   my $dev_name;
+  my $in_dev= 0;
+  my %data;
+  my $dev_name;
 
-   for my $l (@lines) {
-      chomp $l;
+  for my $l (@lines) {
+    chomp $l;
 
-      if($l =~ m/^udi = '(.*?)'/) {
-         $in_dev = 1;
-         $dev_name = $1;
-      }
+    if($l =~ m/^udi = '(.*?)'/) {
+      $in_dev = 1;
+      $dev_name = $1;
+    }
 
-      if($l =~ m/^$/) {
-         $in_dev = 0;
-         unless ($dev_name) {
-            %data = ();
-            next;
-         }
-         $tmp_devices{$dev_name} = { %data };
-         %data = ();
+    if($l =~ m/^$/) {
+      $in_dev = 0;
+      unless ($dev_name) {
+        %data = ();
+        next;
       }
+      $tmp_devices{$dev_name} = { %data };
+      %data = ();
+    }
 
-      if($in_dev) {
-         my ($key, $val) = split(/ = /, $l, 2);
-         $key =~ s/^\s+//;
-         $key =~ s/^'|'$//g;
-         $val =~ s/\(.*?\)$//;
-         $val =~ s/^\s+//;
-         $val =~ s/\s+$//;
-         $val =~ s/^'|'$//g;
-         $data{$key} = $self->_parse_hal_string($val);
-      }
+    if($in_dev) {
+      my ($key, $val) = split(/ = /, $l, 2);
+      $key =~ s/^\s+//;
+      $key =~ s/^'|'$//g;
+      $val =~ s/\(.*?\)$//;
+      $val =~ s/^\s+//;
+      $val =~ s/\s+$//;
+      $val =~ s/^'|'$//g;
+      $data{$key} = $self->_parse_hal_string($val);
+    }
 
-   }
+  }
 
 
-   for my $dev (keys %tmp_devices) {
+  for my $dev (keys %tmp_devices) {
 
-      my $s_key = $tmp_devices{$dev}->{"info.subsystem"} || $tmp_devices{$dev}->{"linux.subsystem"};
-      $s_key ||= $tmp_devices{$dev}->{"info.category"};
+    my $s_key = $tmp_devices{$dev}->{"info.subsystem"} || $tmp_devices{$dev}->{"linux.subsystem"};
+    $s_key ||= $tmp_devices{$dev}->{"info.category"};
 
-      if(! $s_key) {
-         #print Dumper($tmp_devices{$dev});
-         next;
-      }
+    if(! $s_key) {
+      #print Dumper($tmp_devices{$dev});
+      next;
+    }
 
-      if($s_key =~ m/\./) {
-         ($s_key) = split(/\./, $s_key);
-      }
+    if($s_key =~ m/\./) {
+      ($s_key) = split(/\./, $s_key);
+    }
 
-      if(! exists $devices{$s_key}) {
-         $devices{$s_key} = {};
-      }
+    if(! exists $devices{$s_key}) {
+      $devices{$s_key} = {};
+    }
 
-      $devices{$s_key}->{$dev} = $tmp_devices{$dev};
+    $devices{$s_key}->{$dev} = $tmp_devices{$dev};
 
-   }
+  }
 
-   $self->{'__hal'} = \%devices;
+  $self->{'__hal'} = \%devices;
 
 }
 
 sub _parse_hal_string {
 
-   my ($self, $line) = @_;
+  my ($self, $line) = @_;
 
-   if($line =~ m/^\{.*\}$/) {
-      $line =~ s/^\{/[/;
-      $line =~ s/\}$/]/;
+  if($line =~ m/^\{.*\}$/) {
+    $line =~ s/^\{/[/;
+    $line =~ s/\}$/]/;
 
-      return eval $line;
-   }
-   
-   return $line;
+    return eval $line;
+  }
+  
+  return $line;
 
 }
 
@@ -0,0 +1,47 @@
+#
+# (c) Jan Gehring <jan.gehring@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+package Rex::Inventory::Proc::Cpuinfo;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use Rex::Commands::File;
+
+sub new {
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
+
+  bless( $self, $proto );
+
+  return $self;
+}
+
+sub get {
+  my ($self) = @_;
+
+  my @cpuinfo = split /\n/, cat "/proc/cpuinfo";
+  chomp @cpuinfo;
+
+  my @ret;
+  my $proc = 0;
+  for my $line (@cpuinfo) {
+    my ( $key, $val ) = split /\s*:\s*/, $line, 2;
+    if ( $key eq "processor" ) {
+      $proc = $val;
+      $ret[$proc] = {};
+      next;
+    }
+
+    $ret[$proc]->{$key} = $val;
+  }
+
+  return \@ret;
+}
+
+1;
@@ -0,0 +1,39 @@
+#
+# (c) Jan Gehring <jan.gehring@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+package Rex::Inventory::Proc;
+
+use strict;
+use warnings;
+
+use Rex::Inventory::Proc::Cpuinfo;
+
+sub new {
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
+
+  bless( $self, $proto );
+
+  $self->_read_proc();
+
+  return $self;
+}
+
+sub _read_proc {
+  my ($self) = @_;
+
+  my $p_cpu = Rex::Inventory::Proc::Cpuinfo->new;
+
+  $self->{__proc__} = { cpus => $p_cpu->get, };
+}
+
+sub get_cpus {
+  my ($self) = @_;
+  return $self->{__proc__}->{cpus};
+}
+
+1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::BaseBoard;
@@ -15,18 +15,18 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("base board");
 
 __PACKAGE__->has([ 'Manufacturer', 
-                   'Serial Number',
-                   'Version',
-                   { from => 'Product', key => 'Product Name'}], 1);
+             'Serial Number',
+             'Version',
+             { from => 'Product', key => 'Product Name'}], 1);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::Bios;
@@ -15,17 +15,17 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("BIOS information");
 
 __PACKAGE__->has([ 'Vendor', 
-                   { from => 'Version String', key => 'Version' },
-                   'Release Date', ], 1);
+             { from => 'Version String', key => 'Version' },
+             'Release Date', ], 1);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::CPU;
@@ -17,29 +17,29 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("processor");
 
 __PACKAGE__->has([ { key => 'Max Speed', from => "Maximum Speed" }, 
-                   'Family',
-                   { key => 'Status', from => "Processor Status" },], 1);  # is_array 1
+             'Family',
+             { key => 'Status', from => "Processor Status" },], 1);  # is_array 1
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub num_cores {
-   my ($self) = @_;
-   Rex::Logger::debug("num_cores not supported");
-   return -1;
+  my ($self) = @_;
+  Rex::Logger::debug("num_cores not supported");
+  return -1;
 }
 
 sub get_socket_type {
-   my ($self) = @_;
-   Rex::Logger::debug("get_socket_type not supported");
-   return undef;
+  my ($self) = @_;
+  Rex::Logger::debug("get_socket_type not supported");
+  return undef;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::Memory;
@@ -15,21 +15,21 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("memory device");
 
 __PACKAGE__->has([
-                   { key => 'Type', from => "Memory Type" },
-                   'Speed',
-                   'Size',
-                   'Bank Locator',
-                   'Form Factor',
-                   { key => 'Locator', from => "Device Locator" }, ], 1);  # is_array 1
+             { key => 'Type', from => "Memory Type" },
+             'Speed',
+             'Size',
+             'Bank Locator',
+             'Form Factor',
+             { key => 'Locator', from => "Device Locator" }, ], 1);  # is_array 1
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::MemoryArray;
@@ -15,18 +15,18 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("physical memory array");
 
 __PACKAGE__->has([ { key => 'Number Of Devices', from => "Number of Slots/Sockets" }, 
-                   { key => 'Error Correction Type', from => "ECC" },
-                   { key => 'Maximum Capacity', from => "Max Capacity" },
-                   'Location', ], 1);
+             { key => 'Error Correction Type', from => "ECC" },
+             { key => 'Maximum Capacity', from => "Max Capacity" },
+             'Location', ], 1);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::Section;
@@ -18,132 +18,132 @@ use vars qw($SECTION @EXPORT);
 $SECTION = {};
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub section {
-   my ($class, $section) = @_;
-   $SECTION->{$class} = $section;
+  my ($class, $section) = @_;
+  $SECTION->{$class} = $section;
 }
 
 sub has {
-   my ($class, $item, $is_array) = @_;
-   
-   unless(ref($item) eq "ARRAY") {
-      my $_tmp = $item;
-      $item = [$_tmp];
-   }
-
-   no strict 'refs';
-
-   for my $_itm (@{$item}) {
-      my ($itm, $from);
-
-      if(ref($_itm) eq "HASH") {
-         $itm = $_itm->{key};
-         $from = $_itm->{from};
-      }
-      else {
-         $itm = $_itm;
-         $from = $_itm;
-      }
-      $itm =~ s/[^a-zA-Z0-9_]+/_/g;
-      *{"${class}::get_\L$itm"} = sub {
-         my $self = shift;
-         return $self->get($from, $is_array);
-      };
-
-      push(@{"${class}::items"}, "\L$itm");
-   }
-
-   use strict;
+  my ($class, $item, $is_array) = @_;
+  
+  unless(ref($item) eq "ARRAY") {
+    my $_tmp = $item;
+    $item = [$_tmp];
+  }
+
+  no strict 'refs';
+
+  for my $_itm (@{$item}) {
+    my ($itm, $from);
+
+    if(ref($_itm) eq "HASH") {
+      $itm = $_itm->{key};
+      $from = $_itm->{from};
+    }
+    else {
+      $itm = $_itm;
+      $from = $_itm;
+    }
+    $itm =~ s/[^a-zA-Z0-9_]+/_/g;
+    *{"${class}::get_\L$itm"} = sub {
+      my $self = shift;
+      return $self->get($from, $is_array);
+    };
+
+    push(@{"${class}::items"}, "\L$itm");
+  }
+
+  use strict;
 }
 
 sub dmi {
 
-   my ($self) = @_;
-   return $self->{"dmi"};
+  my ($self) = @_;
+  return $self->{"dmi"};
 
 
 }
 
 sub get {
 
-   my ($self, $key, $is_array) = @_;
-   return $self->_search_for($key, $is_array);
+  my ($self, $key, $is_array) = @_;
+  return $self->_search_for($key, $is_array);
 
 }
 
 sub get_all {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   use Data::Dumper;
-   my $r = ref($self);
+  use Data::Dumper;
+  my $r = ref($self);
 
-   no strict 'refs';
-   my @items = @{"${r}::items"};
-   use strict;
+  no strict 'refs';
+  my @items = @{"${r}::items"};
+  use strict;
 
-   my $ret = {};
-   for my $itm (@items) {
-      my $f = "get_$itm";
-      $ret->{$itm} = $self->$f();
-   }
+  my $ret = {};
+  for my $itm (@items) {
+    my $f = "get_$itm";
+    $ret->{$itm} = $self->$f();
+  }
 
-   return $ret;
+  return $ret;
 
 }
 
 sub dump {
 
-   my ($self) = @_;
+  my ($self) = @_;
 
-   require Data::Dumper;
-   print Data::Dumper::Dumper($self->dmi->get_tree($SECTION->{ref($self)}));
+  require Data::Dumper;
+  print Data::Dumper::Dumper($self->dmi->get_tree($SECTION->{ref($self)}));
 
 }
 
 sub _search_for {
-   my ($self, $key, $is_array) = @_;
-
-   unless($self->dmi->get_tree($SECTION->{ref($self)})) {
-      #die $SECTION->{ref($self)} . " not supported";
-      return;
-   }
-
-   my $idx = 0;
-   for my $entry (@{ $self->dmi->get_tree($SECTION->{ref($self)}) }) {
-      my ($_key) = keys %{$entry};
-      if($is_array) {
-         if ($idx != $self->get_index()) {
-            ++$idx;
-            next;
-         }
-      }
-
-      if(exists $entry->{$key}) {
-         return $entry->{$key};
+  my ($self, $key, $is_array) = @_;
+
+  unless($self->dmi->get_tree($SECTION->{ref($self)})) {
+    #die $SECTION->{ref($self)} . " not supported";
+    return;
+  }
+
+  my $idx = 0;
+  for my $entry (@{ $self->dmi->get_tree($SECTION->{ref($self)}) }) {
+    my ($_key) = keys %{$entry};
+    if($is_array) {
+      if ($idx != $self->get_index()) {
+        ++$idx;
+        next;
       }
-      else {
-         return "";
-      }
-      ++$idx;
-   }
-
-   return "";
+    }
+
+    if(exists $entry->{$key}) {
+      return $entry->{$key};
+    }
+    else {
+      return "";
+    }
+    ++$idx;
+  }
+
+  return "";
 }
 
 sub get_index {
 
-   my ($self) = @_;
-   return $self->{"index"} || 0;
+  my ($self) = @_;
+  return $self->{"index"} || 0;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory::SMBios::SystemInformation;
@@ -15,21 +15,21 @@ use base qw(Rex::Inventory::SMBios::Section);
 __PACKAGE__->section("system information");
 
 __PACKAGE__->has([ 'Manufacturer', 
-                   { key => 'Product Name', from => "Product" },
-                   'UUID',
-                   'SKU Number',
-                   'Family',
-                   'Version',
-                   'Serial Number', ], 1);
+             { key => 'Product Name', from => "Product" },
+             'UUID',
+             'SKU Number',
+             'Family',
+             'Version',
+             'Serial Number', ], 1);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Inventory::SMBios;
-   
+  
 use strict;
 use warnings;
 
@@ -23,139 +23,139 @@ use Rex::Inventory::SMBios::MemoryArray;
 use Rex::Inventory::SMBios::SystemInformation;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->_read_smbios();
+  $self->_read_smbios();
 
-   return $self;
+  return $self;
 }
 
 sub get_tree {
-   my ($self, $section) = @_;
+  my ($self, $section) = @_;
 
-   if($section) {
-      return $self->{"__dmi"}->{$section};
-   }
-   
-   return $self->{"__dmi"};
+  if($section) {
+    return $self->{"__dmi"}->{$section};
+  }
+  
+  return $self->{"__dmi"};
 }
 
 sub get_base_board {
-   my ($self) = @_;
-   return Rex::Inventory::SMBios::BaseBoard->new(dmi => $self);
+  my ($self) = @_;
+  return Rex::Inventory::SMBios::BaseBoard->new(dmi => $self);
 }
 
 sub get_bios {
-   my ($self) = @_;
-   return Rex::Inventory::SMBios::Bios->new(dmi => $self);
+  my ($self) = @_;
+  return Rex::Inventory::SMBios::Bios->new(dmi => $self);
 }
 
 sub get_system_information {
-   my ($self) = @_;
-   return Rex::Inventory::SMBios::SystemInformation->new(dmi => $self);
+  my ($self) = @_;
+  return Rex::Inventory::SMBios::SystemInformation->new(dmi => $self);
 }
 
 
 sub get_cpus {
 
-   my ($self) = @_;
-   my @cpus = ();
-   my $tree = $self->get_tree("processor");
-   my $idx=0;
-   for my $cpu ( @{ $tree } ) {
-      if($cpu->{"Socket Status"} =~m/Populated/) {
-         push(@cpus, Rex::Inventory::SMBios::CPU->new(dmi => $self, index => $idx));
-      }
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @cpus = ();
+  my $tree = $self->get_tree("processor");
+  my $idx=0;
+  for my $cpu ( @{ $tree } ) {
+    if($cpu->{"Socket Status"} =~m/Populated/) {
+      push(@cpus, Rex::Inventory::SMBios::CPU->new(dmi => $self, index => $idx));
+    }
+    ++$idx;
+  }
 
-   return @cpus;
+  return @cpus;
 
 }
 
 sub get_memory_modules {
 
-   my ($self) = @_;
-   my @mems = ();
-   my $tree = $self->get_tree("memory device");
-   my $idx = 0;
-   for my $mem (@{ $tree }) {
-      if($mem->{"Size"} =~ m/\d+/) {
-         push(@mems, Rex::Inventory::SMBios::Memory->new(dmi => $self, index => $idx));
-      }
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @mems = ();
+  my $tree = $self->get_tree("memory device");
+  my $idx = 0;
+  for my $mem (@{ $tree }) {
+    if($mem->{"Size"} =~ m/\d+/) {
+      push(@mems, Rex::Inventory::SMBios::Memory->new(dmi => $self, index => $idx));
+    }
+    ++$idx;
+  }
 
-   return @mems;
+  return @mems;
 
 }
 
 sub get_memory_arrays {
 
-   my ($self) = @_;
-   my @mems = ();
-   my $tree = $self->get_tree("physical memory array");
-   my $idx = 0;
-   for my $mema (@{ $tree }) {
-      push(@mems, Rex::Inventory::SMBios::MemoryArray->new(dmi => $self, index => $idx));
-      ++$idx;
-   }
+  my ($self) = @_;
+  my @mems = ();
+  my $tree = $self->get_tree("physical memory array");
+  my $idx = 0;
+  for my $mema (@{ $tree }) {
+    push(@mems, Rex::Inventory::SMBios::MemoryArray->new(dmi => $self, index => $idx));
+    ++$idx;
+  }
 
-   return @mems;
+  return @mems;
 
 }
 
 
 sub _read_smbios {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @data = i_run("smbios");
+  my @data = i_run("smbios");
 
-   my ($current_section, %section, $key, $val, %cur_data);
-   for my $line (@data) {
-      next if($line =~ /^$/);
-      next if($line =~ /^\s*$/);
-      next if($line =~ /^ID/);
+  my ($current_section, %section, $key, $val, %cur_data);
+  for my $line (@data) {
+    next if($line =~ /^$/);
+    next if($line =~ /^\s*$/);
+    next if($line =~ /^ID/);
 
-      if($line =~ m/^\d/) {
-         push(@{$section{$current_section}}, { %cur_data }) if (%cur_data);
+    if($line =~ m/^\d/) {
+      push(@{$section{$current_section}}, { %cur_data }) if (%cur_data);
 
-         ($current_section) = ($line =~ m/\(([^\)]+)\)/);
-         
-         if(! exists $section{$current_section}) {
-            $section{$current_section} = [];
-         }
-
-         %cur_data = ();
-         next;
+      ($current_section) = ($line =~ m/\(([^\)]+)\)/);
+      
+      if(! exists $section{$current_section}) {
+        $section{$current_section} = [];
       }
 
-      # outer section
-      if($line =~ /^\s\s[a-z]/i) {
-         $line =~ s/^\s*//;
-         ($key, $val) = split(/: /, $line);
-         $cur_data{$key} = $val;
+      %cur_data = ();
+      next;
+    }
+
+    # outer section
+    if($line =~ /^\s\s[a-z]/i) {
+      $line =~ s/^\s*//;
+      ($key, $val) = split(/: /, $line);
+      $cur_data{$key} = $val;
+    }
+    elsif($line =~ /^\t[a-z]/i) {
+      if(! ref($cur_data{$key})) {
+        $cur_data{$key} = [];
       }
-      elsif($line =~ /^\t[a-z]/i) {
-         if(! ref($cur_data{$key})) {
-            $cur_data{$key} = [];
-         }
 
-         $line =~ s/^\s*//;
-         push(@{$cur_data{$key}}, $line);
-      }
+      $line =~ s/^\s*//;
+      push(@{$cur_data{$key}}, $line);
+    }
 
-   }
+  }
 
-   # push the last
-   push(@{$section{$current_section}}, { %cur_data });
+  # push the last
+  push(@{$section{$current_section}}, { %cur_data });
 
 
-   $self->{"__dmi"} = \%section;
+  $self->{"__dmi"} = \%section;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Inventory;
@@ -11,150 +11,208 @@ use warnings;
 
 use Rex::Inventory::DMIDecode;
 use Rex::Inventory::Hal;
+use Rex::Inventory::Proc;
 use Rex::Commands::Network;
 use Rex::Commands::Run;
 use Rex::Commands::Gather;
 use Rex::Commands::LVM;
-use Rex::Commands::Run;
+use Rex::Commands::Fs;
 
 use Rex::Inventory::HP::ACU;
+use Data::Dumper;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
 
-   bless($self, $proto);
+  bless( $self, $proto );
 
-   return $self;
+  return $self;
 }
 
 sub get {
 
-   my ($self) = @_;
-   
-   my $dmi = Rex::Inventory::DMIDecode->new;
-   my ($base_board, $bios, @cpus, @dimms, @mem_arrays, $sys_info);
-
-   $base_board = $dmi->get_base_board;
-   $bios       = $dmi->get_bios;
-   @cpus       = $dmi->get_cpus;
-   @dimms      = $dmi->get_memory_modules;
-   @mem_arrays = $dmi->get_memory_arrays;
-   $sys_info   = $dmi->get_system_information;
-
-   my $hal = {};
-   my (@net_devs, @storage, @volumes);
-
-   eval {
-      $hal = Rex::Inventory::Hal->new;
-
-      @net_devs = $hal->get_network_devices;
-      @storage  = $hal->get_storage_devices;
-      @volumes  = $hal->get_storage_volumes;
-   };
-
-   my @routes     = route;
-   my @netstat    = netstat;
-   my $default_gw = default_gateway;
-
-   my (@pvs, @vgs, @lvs);
-   eval {
-      @pvs = pvs;
-      @vgs = vgs;
-      @lvs = lvs;
-   };
-
-   my @raid_controller;
-   eval {
-      if(my $hp_raid = Rex::Inventory::HP::ACU->get()) {
-         # hp raid entdeckt
-         for my $key (keys %{$hp_raid}) {
-
-            my %raid_shelfs;
-            for my $shelf (keys %{$hp_raid->{$key}->{"array"}}) {
-               my $shelf_data = $hp_raid->{$key}->{"array"}->{$shelf};
-
-               my @raid_logical_drives;
-               for my $l_drive (keys %{$hp_raid->{$key}->{"array"}->{$shelf}->{"logical_drive"}}) {
-                  my $l_drive_data = $hp_raid->{$key}->{"array"}->{$shelf}->{"logical_drive"}->{$l_drive};
-                  my ($size) = ($l_drive_data->{"size"} =~ m/^([0-9\.]+)/);
-                  my $multi = 1024 * 1024 * 1024;
-                  if($l_drive_data->{"size"} =~ m/TB$/) {
-                     $multi *= 1024;
-                  }
-
-                  push(@raid_logical_drives, {
-                        status => ($l_drive_data->{"status"} eq "OK"?1:0),
-                        raid_level => $l_drive_data->{"fault_tolerance"},
-                        size => sprintf("%i", $size * $multi),
-                        dev => $l_drive_data->{"disk_name"},
-                        shelf => $shelf,
-                     });
-               }
-
-               $raid_shelfs{$shelf} = {
-                     type => $shelf_data->{"interface_type"},
-                     status => ($shelf_data->{"status"} eq "OK"?1:0),
-                     logical_drives => \@raid_logical_drives,
-                  };
+  my ($self) = @_;
 
-            }
+  my $dmi = Rex::Inventory::DMIDecode->new;
+  my ( $base_board, $bios, @cpus, @dimms, @mem_arrays, $sys_info );
+
+  $base_board = $dmi->get_base_board;
+  $bios       = $dmi->get_bios;
+  @cpus       = $dmi->get_cpus;
+  @dimms      = $dmi->get_memory_modules;
+  @mem_arrays = $dmi->get_memory_arrays;
+  $sys_info   = $dmi->get_system_information;
+
+  my $hal = {};
+  my ( @net_devs, @storage, @volumes );
 
-            push(@raid_controller, {
-                        type => $hp_raid->{$key}->{"description"},
-                        model => $hp_raid->{$key}->{"model"},
-                        serial_number => $hp_raid->{$key}->{"serial_number"},
-                        cache_status => ($hp_raid->{$key}->{"cache_status"} eq "OK"?1:0),
-                        shelfs => \%raid_shelfs,
-                     });
+  eval {
+    $hal = Rex::Inventory::Hal->new;
 
+    @net_devs = $hal->get_network_devices;
+    @storage  = $hal->get_storage_devices;
+    @volumes  = $hal->get_storage_volumes;
+  };
 
-         }
+  eval {
+    if ( scalar @cpus == 0 ) {
+
+      # get cpu info from /proc
+      if ( is_dir("/proc") ) {
+        Rex::Logger::info(
+          "Got no cpu information from dmidecode. Falling back to /proc/cpuinfo"
+        );
+        my $proc_i = Rex::Inventory::Proc->new;
+        @cpus = @{ $proc_i->get_cpus };
       }
-   };
-
-   my ($fusion_inventory_xmlref);
-   if(can_run("fusioninventory-agent")) {
-      require XML::Simple;
-      my $xml = XML::Simple->new;
-      my $fusion_inventory = run "fusioninventory-agent --stdout 2>/dev/null";
-      $fusion_inventory_xmlref = $xml->XMLin($fusion_inventory);
-   }
-
-   return {
-      base_board  => ($base_board?$base_board->get_all():{}),
-      bios        => $bios->get_all(),
-      system_info => $sys_info->get_all(),
-      cpus        => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @cpus; return $ret; }->(),
-      dimms       => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @dimms; return $ret; }->(),
-      mem_arrays  => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @mem_arrays; return $ret; }->(),
-      net         => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @net_devs; return $ret; }->(),
-      storage     => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @storage; return $ret; }->(),
-      volumes     => sub { my $ret = []; push(@{$ret}, $_->get_all()) for @volumes; return $ret; }->(),
-      raid        => {
-         controller => \@raid_controller,
-      },
-      lvm         => {
-         physical_volumes => \@pvs,
-         volume_groups    => \@vgs,
-         logical_volumes  => \@lvs,
+    }
+  };
+
+  my @routes     = route;
+  my @netstat    = netstat;
+  my $default_gw = default_gateway;
+
+  my ( @pvs, @vgs, @lvs );
+  eval {
+    @pvs = pvs;
+    @vgs = vgs;
+    @lvs = lvs;
+  };
+
+  my @raid_controller;
+  eval {
+    if ( my $hp_raid = Rex::Inventory::HP::ACU->get() ) {
+
+      # hp raid entdeckt
+      for my $key ( keys %{$hp_raid} ) {
+
+        my %raid_shelfs;
+        for my $shelf ( keys %{ $hp_raid->{$key}->{"array"} } ) {
+          my $shelf_data = $hp_raid->{$key}->{"array"}->{$shelf};
+
+          my @raid_logical_drives;
+          for my $l_drive (
+            keys %{ $hp_raid->{$key}->{"array"}->{$shelf}->{"logical_drive"} } )
+          {
+            my $l_drive_data =
+              $hp_raid->{$key}->{"array"}->{$shelf}->{"logical_drive"}
+              ->{$l_drive};
+            my ($size) = ( $l_drive_data->{"size"} =~ m/^([0-9\.]+)/ );
+            my $multi = 1024 * 1024 * 1024;
+            if ( $l_drive_data->{"size"} =~ m/TB$/ ) {
+              $multi *= 1024;
+            }
+
+            push(
+              @raid_logical_drives,
+              {
+                status => ( $l_drive_data->{"status"} eq "OK" ? 1 : 0 ),
+                raid_level => $l_drive_data->{"fault_tolerance"},
+                size       => sprintf( "%i", $size * $multi ),
+                dev        => $l_drive_data->{"disk_name"},
+                shelf      => $shelf,
+              }
+            );
+          }
+
+          $raid_shelfs{$shelf} = {
+            type           => $shelf_data->{"interface_type"},
+            status         => ( $shelf_data->{"status"} eq "OK" ? 1 : 0 ),
+            logical_drives => \@raid_logical_drives,
+          };
+
+        }
+
+        push(
+          @raid_controller,
+          {
+            type          => $hp_raid->{$key}->{"description"},
+            model         => $hp_raid->{$key}->{"model"},
+            serial_number => $hp_raid->{$key}->{"serial_number"},
+            cache_status =>
+              ( $hp_raid->{$key}->{"cache_status"} eq "OK" ? 1 : 0 ),
+            shelfs => \%raid_shelfs,
+          }
+        );
+
+      }
+    }
+  };
+
+  my ($fusion_inventory_xmlref);
+  if ( can_run("fusioninventory-agent") ) {
+    require XML::Simple;
+    my $xml              = XML::Simple->new;
+    my $fusion_inventory = run "fusioninventory-agent --stdout 2>/dev/null";
+    $fusion_inventory_xmlref = $xml->XMLin($fusion_inventory);
+  }
+
+  return {
+    base_board => ( $base_board ? $base_board->get_all() : {} ),
+    bios => $bios->get_all(),
+    system_info => $sys_info->get_all(),
+    cpus        => sub {
+      my $ret = [];
+      push( @{$ret}, ( ref $_ ne "HASH" ? $_->get_all() : $_ ) ) for @cpus;
+      return $ret;
+      }
+      ->(),
+    dimms => sub {
+      my $ret = [];
+      push( @{$ret}, $_->get_all() )
+        for @dimms;
+      return $ret;
+      }
+      ->(),
+    mem_arrays => sub {
+      my $ret = [];
+      push( @{$ret}, $_->get_all() ) for @mem_arrays;
+      return $ret;
+      }
+      ->(),
+    net => sub {
+      my $ret = [];
+      push( @{$ret}, $_->get_all() ) for @net_devs;
+      return $ret;
+      }
+      ->(),
+    storage => sub {
+      my $ret = [];
+      push( @{$ret}, $_->get_all() ) for @storage;
+      return $ret;
+      }
+      ->(),
+    volumes => sub {
+      my $ret = [];
+      push( @{$ret}, $_->get_all() ) for @volumes;
+      return $ret;
+      }
+      ->(),
+    raid => {
+      controller => \@raid_controller,
+    },
+    lvm => {
+      physical_volumes => \@pvs,
+      volume_groups    => \@vgs,
+      logical_volumes  => \@lvs,
+    },
+    configuration => {
+      network => {
+        routes                => \@routes,
+        current_connections   => \@netstat,
+        default_gateway       => $default_gw,
+        current_configuration => network_interfaces(),
       },
-      configuration => {
-         network => {
-            routes                => \@routes,
-            current_connections   => \@netstat,
-            default_gateway       => $default_gw,
-            current_configuration => network_interfaces(),
-         },
-         host    => {
-            name   => [ run "hostname -s" ]->[0],
-            domain => [ run "hostname -d" || qw() ]->[0],
-            kernel => [ run "uname -r" || qw() ]->[0],
-         },
+      host => {
+        name   => [ run "hostname -s" ]->[0],
+        domain => [ run "hostname -d" || qw() ]->[0],
+        kernel => [ run "uname -r" || qw() ]->[0],
       },
-      fusion_inventory => $fusion_inventory_xmlref,
-   };
+    },
+    fusion_inventory => $fusion_inventory_xmlref,
+  };
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -17,7 +17,7 @@ This module if the logging module. You can define custom logformats.
  $Rex::Logger::format = '[%D] %s';
  # will output something like
  # [2012-04-12 18:35:12] Installing package vim
-    
+   
  $Rex::Logger::format = '%h - %D - %s';
  # will output something like
  # srv001 - 2012-04-12 18:35:12 - Installing package vim
@@ -41,7 +41,7 @@ if($@) { $no_color = 1; }
 
 # no colors under windows
 if($^O =~ m/MSWin/) {
-   $no_color = 1;
+  $no_color = 1;
 }
 
 my $has_syslog = 0;
@@ -88,129 +88,129 @@ our $format = "[%D] %l - %s";
 my $log_opened = 0;
 
 sub init {
-   return if $silent;
-   eval {
-      die if(Rex::Config->get_log_filename || ! Rex::Config->get_log_facility);
+  return if $silent;
+  eval {
+    die if(Rex::Config->get_log_filename || ! Rex::Config->get_log_facility);
 
-      require Sys::Syslog;
-      Sys::Syslog->import;
-      openlog("rex", "ndelay,pid", Rex::Config->get_log_facility);
-      $has_syslog = 1;
-   };
+    require Sys::Syslog;
+    Sys::Syslog->import;
+    openlog("rex", "ndelay,pid", Rex::Config->get_log_facility);
+    $has_syslog = 1;
+  };
 
-   $log_opened = 1;
+  $log_opened = 1;
 }
 
 sub info {
-   my ($msg, $type) = @_;
-   my $color = 'green';
+  my ($msg, $type) = @_;
+  my $color = 'green';
 
-   if (defined($type)) {
-     CHECK_COLOR: {
-         $type eq 'warn' && do { $color = 'yellow'; last CHECK_COLOR; };
-         $type eq 'error' && do { $color = 'red'; last CHECK_COLOR; };
-       }
-   }
+  if (defined($type)) {
+    CHECK_COLOR: {
+      $type eq 'warn' && do { $color = 'yellow'; last CHECK_COLOR; };
+      $type eq 'error' && do { $color = 'red'; last CHECK_COLOR; };
+     }
+  }
 
-   return if $silent;
-   
-   if(defined($type)) {
-      $msg = format_string($msg, uc($type));
-   }
-   else {
-      $msg = format_string($msg, "INFO");
-   }
-   # workaround for windows Sys::Syslog behaviour on forks
-   # see: #6
-   unless($log_opened) {
-      init();
-      $log_opened = 2;
-   }
-
-   if($has_syslog) {
-      syslog("info", $msg);
-   }
-
-   if(Rex::Config->get_log_filename()) {
-      open($log_fh, ">>", Rex::Config->get_log_filename()) or die($!);
-      flock($log_fh, 2);
-      print {$log_fh} "$msg\n" if($log_fh);
-      close($log_fh);
-   }
-
-   if($no_color) {
-      print STDERR "$msg\n" if( ((defined $::QUIET && $::QUIET == 2) && (defined $type && $type ne 'info')) || ! defined $::QUIET);
-   }
-   else {
-      print STDERR colored([$color], "$msg\n") if( ((defined $::QUIET && $::QUIET == 2) && (defined $type && $type ne 'info')) || ! defined $::QUIET);
-   }
-
-   # workaround for windows Sys::Syslog behaviour on forks
-   # see: #6
-   if($log_opened == 2) {
-      &shutdown();
-   }
+  return if $silent;
+  
+  if(defined($type)) {
+    $msg = format_string($msg, uc($type));
+  }
+  else {
+    $msg = format_string($msg, "INFO");
+  }
+  # workaround for windows Sys::Syslog behaviour on forks
+  # see: #6
+  unless($log_opened) {
+    init();
+    $log_opened = 2;
+  }
+
+  if($has_syslog) {
+    syslog("info", $msg);
+  }
+
+  if(Rex::Config->get_log_filename()) {
+    open($log_fh, ">>", Rex::Config->get_log_filename()) or die($!);
+    flock($log_fh, 2);
+    print {$log_fh} "$msg\n" if($log_fh);
+    close($log_fh);
+  }
+
+  if($no_color) {
+    print STDERR "$msg\n" if( ((defined $::QUIET && $::QUIET == 2) && (defined $type && $type ne 'info')) || ! defined $::QUIET);
+  }
+  else {
+    print STDERR colored([$color], "$msg\n") if( ((defined $::QUIET && $::QUIET == 2) && (defined $type && $type ne 'info')) || ! defined $::QUIET);
+  }
+
+  # workaround for windows Sys::Syslog behaviour on forks
+  # see: #6
+  if($log_opened == 2) {
+    &shutdown();
+  }
 }
 
 sub debug {
-   my ($msg) = @_;
-   return if $silent;
-   return unless $debug;
-
-   $msg = format_string($msg, "DEBUG");
-
-   # workaround for windows Sys::Syslog behaviour on forks
-   # see: #6
-   unless($log_opened) {
-      init();
-      $log_opened = 2;
-   }
-
-   if($has_syslog) {
-      syslog("debug", $msg);
-   }
-
-   if(Rex::Config->get_log_filename()) {
-      open($log_fh, ">>", Rex::Config->get_log_filename()) or die($!);
-      flock($log_fh, 2);
-      print {$log_fh} "$msg\n" if($log_fh);
-      close($log_fh);
-   }
-   
-   if($no_color) {
-      print STDERR "$msg\n" unless($::QUIET);
-   }
-   else {
-      print STDERR colored(['red'], "$msg\n") unless($::QUIET);
-   }
-
-   # workaround for windows Sys::Syslog behaviour on forks
-   # see: #6
-   if($log_opened == 2) {
-      &shutdown();
-   }
+  my ($msg) = @_;
+  return if $silent;
+  return unless $debug;
+
+  $msg = format_string($msg, "DEBUG");
+
+  # workaround for windows Sys::Syslog behaviour on forks
+  # see: #6
+  unless($log_opened) {
+    init();
+    $log_opened = 2;
+  }
+
+  if($has_syslog) {
+    syslog("debug", $msg);
+  }
+
+  if(Rex::Config->get_log_filename()) {
+    open($log_fh, ">>", Rex::Config->get_log_filename()) or die($!);
+    flock($log_fh, 2);
+    print {$log_fh} "$msg\n" if($log_fh);
+    close($log_fh);
+  }
+  
+  if($no_color) {
+    print STDERR "$msg\n" unless($::QUIET);
+  }
+  else {
+    print STDERR colored(['red'], "$msg\n") unless($::QUIET);
+  }
+
+  # workaround for windows Sys::Syslog behaviour on forks
+  # see: #6
+  if($log_opened == 2) {
+    &shutdown();
+  }
 }
 
 sub get_timestamp {
-   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-   $mon++;
-   $year += 1900;
+  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+  $mon++;
+  $year += 1900;
 
-   return "$year-" . sprintf("%02i", $mon) . "-" . sprintf("%02i", $mday) . " " . sprintf("%02i", $hour) . ":" . sprintf("%02i", $min) . ":" . sprintf("%02i", $sec);
+  return "$year-" . sprintf("%02i", $mon) . "-" . sprintf("%02i", $mday) . " " . sprintf("%02i", $hour) . ":" . sprintf("%02i", $min) . ":" . sprintf("%02i", $sec);
 }
 
 sub shutdown {
-   return if $silent;
-   return unless $log_opened;
+  return if $silent;
+  return unless $log_opened;
 
-   if($has_syslog) {
-      closelog();
-   }
-   else {
-      close($log_fh) if $log_fh;
-   }
+  if($has_syslog) {
+    closelog();
+  }
+  else {
+    close($log_fh) if $log_fh;
+  }
 
-   $log_opened = 0;
+  $log_opened = 0;
   
 }
 
@@ -219,21 +219,21 @@ sub shutdown {
 # %h - Host
 # %s - Logstring
 sub format_string {
-   my ($s, $level) = @_;
+  my ($s, $level) = @_;
 
-   my $date = get_timestamp;
-   my $host = Rex::get_current_connection() ? Rex::get_current_connection()->{conn}->server : "<local>";
-   my $pid = $$;
+  my $date = get_timestamp;
+  my $host = Rex::get_current_connection() ? Rex::get_current_connection()->{conn}->server : "<local>";
+  my $pid = $$;
 
-   my $line = $format;
+  my $line = $format;
 
-   $line =~ s/\%D/$date/gms;
-   $line =~ s/\%h/$host/gms;
-   $line =~ s/\%s/$s/gms;
-   $line =~ s/\%l/$level/gms;
-   $line =~ s/\%p/$pid/gms;
+  $line =~ s/\%D/$date/gms;
+  $line =~ s/\%h/$host/gms;
+  $line =~ s/\%s/$s/gms;
+  $line =~ s/\%l/$level/gms;
+  $line =~ s/\%p/$pid/gms;
 
-   return $line;
+  return $line;
 }
 
 =back
@@ -0,0 +1,101 @@
+#
+# (c) Jan Gehring <jan.gehring@gmail.com>
+#
+# vim: set ts=2 sw=2 tw=0:
+# vim: set expandtab:
+
+package Rex::Notify;
+
+use strict;
+use warnings;
+
+sub new {
+  my $that  = shift;
+  my $proto = ref($that) || $that;
+  my $self  = {@_};
+
+  bless( $self, $proto );
+
+  $self->{__types__}             = {};
+  $self->{__postponed__}         = [];
+  $self->{__running_postponed__} = 0;
+  $self->{__in_notify__}         = 0;
+
+  return $self;
+}
+
+sub add {
+  my ( $self, %option ) = @_;
+
+  return if ( $self->{__in_notify__} );
+
+  if ( exists $self->{__types__}->{ $option{type} }->{ $option{name} } ) {
+    Rex::Logger::debug(
+      "A resource of the type $option{type} and name $option{name}"
+        . "already exists.",
+      "warn"
+    );
+    return;
+  }
+
+  $self->{__types__}->{ $option{type} }->{ $option{name} } = {
+    postpone => $option{postpone} || 0,
+    options  => $option{options},
+    cb       => $option{cb},
+  };
+}
+
+sub run {
+  my ( $self, %option ) = @_;
+
+  Rex::Logger::debug("Try to notify $option{type} -> $option{name}");
+
+  if ( exists $self->{__types__}->{ $option{type} }
+    && exists $self->{__types__}->{ $option{type} }->{ $option{name} }
+    && exists $self->{__types__}->{ $option{type} }->{ $option{name} }->{cb}
+    && $self->{__types__}->{ $option{type} }->{ $option{name} }->{postpone} ==
+    0 )
+  {
+    Rex::Logger::debug("Running notify $option{type} -> $option{name}");
+
+    my $cb = $self->{__types__}->{ $option{type} }->{ $option{name} }->{cb};
+
+    $self->{__in_notify__} = 1;
+
+    $cb->(
+      $self->{__types__}->{ $option{type} }->{ $option{name} }->{options} );
+
+    $self->{__in_notify__} = 0;
+  }
+  else {
+    if ( !$self->{__running_postponed__} ) {
+      Rex::Logger::debug(
+        "Can't notify $option{type} -> $option{name}. Postponing...");
+      $self->_postpone(%option);
+    }
+    else {
+      Rex::Logger::info(
+        "Can't run postponed notification. "
+          . "Resource not found ($option{type} -> $option{name})",
+        "warn"
+      );
+    }
+  }
+
+}
+
+sub run_postponed {
+  my ($self) = @_;
+  $self->{__running_postponed__} = 1;
+  Rex::Logger::debug("Running postponed notifications.");
+  for my $p ( @{ $self->{__postponed__} } ) {
+    $self->run( %{$p} );
+  }
+}
+
+sub _postpone {
+  my ( $self, %option ) = @_;
+  push @{ $self->{__postponed__} }, \%option;
+}
+
+1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Output::JUnit;
-   
+  
 use strict;
 use warnings;
 
@@ -13,67 +13,67 @@ use Data::Dumper;
 use Rex::Template;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{time}  = time();
-   $self->{error} = "";
+  $self->{time}  = time();
+  $self->{error} = "";
 
-   return $self;
+  return $self;
 }
 
 sub add {
-   my ($self, $task, %option) = @_;
-   $option{name} = $task;
-   $option{time} = time() - $self->{time};
+  my ($self, $task, %option) = @_;
+  $option{name} = $task;
+  $option{time} = time() - $self->{time};
 
-   push(@{$self->{"data"}}, { %option });
+  push(@{$self->{"data"}}, { %option });
 
-   if(exists $option{error}) {
-      $self->error($option{msg});
-   }
+  if(exists $option{error}) {
+    $self->error($option{msg});
+  }
 }
 
 sub error {
-   my ($self, $msg) = @_;
-   $self->{error} .= $msg . "\n";
+  my ($self, $msg) = @_;
+  $self->{error} .= $msg . "\n";
 }
 
 
 sub DESTROY {
-   my ($self) = @_;
-
-   if(! exists $self->{data}) { return; }
-
-   my $t = Rex::Template->new;
-   my $data = eval { local $/; <DATA>; };
-   my $time = time() - $self->{time};
-
-   if(! exists $self->{data}) {
-      return;
-   }
-
-   if(scalar(@{ $self->{data} }) == 0) {
-      return;
-   }
-
-   my $s = $t->parse($data, {
-      errors        => scalar(grep { $_->{"error"} && $_->{"error"} == 1 } @{$self->{"data"}}),
-      tests         => scalar(@{$self->{"data"}}),
-      time_over_all => $time,
-      system_out    => $self->{"error"} || "",
-      items         => $self->{"data"},
-   });
-
-   print $s;
-   if($s) {
-      open(my $fh, ">", "junit_output.xml") or die($!);
-      print $fh $s;
-      close($fh);
-   }
+  my ($self) = @_;
+
+  if(! exists $self->{data}) { return; }
+
+  my $t = Rex::Template->new;
+  my $data = eval { local $/; <DATA>; };
+  my $time = time() - $self->{time};
+
+  if(! exists $self->{data}) {
+    return;
+  }
+
+  if(scalar(@{ $self->{data} }) == 0) {
+    return;
+  }
+
+  my $s = $t->parse($data, {
+    errors      => scalar(grep { $_->{"error"} && $_->{"error"} == 1 } @{$self->{"data"}}),
+    tests      => scalar(@{$self->{"data"}}),
+    time_over_all => $time,
+    system_out   => $self->{"error"} || "",
+    items      => $self->{"data"},
+  });
+
+  print $s;
+  if($s) {
+    open(my $fh, ">", "junit_output.xml") or die($!);
+    print $fh $s;
+    close($fh);
+  }
 }
 
 1;
@@ -82,16 +82,16 @@ __DATA__
 <?xml version='1.0' encoding='utf-8'?>
 <testsuites>
   <testsuite name="rex" errors="<%= $::errors %>" failures="0" tests="<%= $::tests %>" time="<%= $::time_over_all %>">
-    <system-out><%= $::system_out %></system-out>                                                                                               
-    <% foreach my $item (@$::items) { %>
-    <% if($item->{"error"}) { %>
-    <testcase name="<%= $item->{"name"} %>" classname="t_rex_proc" time="<%= $item->{"time"} %>">
-       <failure message="<%= $item->{"name"} %>" type="Rex::Task"></failure>
-    </testcase>
-    <% } else { %>
-    <testcase name="<%= $item->{"name"} %>" classname="t_rex_task" time="<%= $item->{"time"} %>" />
-    <% } %>
-    <% } %>
+   <system-out><%= $::system_out %></system-out>                                                                
+   <% foreach my $item (@$::items) { %>
+   <% if($item->{"error"}) { %>
+   <testcase name="<%= $item->{"name"} %>" classname="t_rex_proc" time="<%= $item->{"time"} %>">
+     <failure message="<%= $item->{"name"} %>" type="Rex::Task"></failure>
+   </testcase>
+   <% } else { %>
+   <testcase name="<%= $item->{"name"} %>" classname="t_rex_task" time="<%= $item->{"time"} %>" />
+   <% } %>
+   <% } %>
   </testsuite>
 </testsuites>
 
@@ -1,32 +1,32 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Output;
-   
+  
 use strict;
 use warnings;
 
 use vars qw($output_object);
 
 sub get {
-   my ($class, $output_module) = @_;
+  my ($class, $output_module) = @_;
 
-   return $output_object if($output_object);
+  return $output_object if($output_object);
 
-   return unless($output_module);
+  return unless($output_module);
 
-   eval "use Rex::Output::$output_module;";
-   if($@) {
-      die("Output Module ,,$output_module'' not found.");
-   }
+  eval "use Rex::Output::$output_module;";
+  if($@) {
+    die("Output Module ,,$output_module'' not found.");
+  }
 
-   my $output_class = "Rex::Output::$output_module";
-   $output_object = $output_class->new;
+  my $output_class = "Rex::Output::$output_module";
+  $output_object = $output_class->new;
 
-   return $output_object;
+  return $output_object;
 }
 
 1;
@@ -16,130 +16,130 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("/usr/bin/rpm -ql $pkg");
+  i_run("/usr/bin/rpm -ql $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
 
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{"version"} || "";
+  my $version = $option->{"version"} || "";
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("/usr/bin/apt-get -y install $pkg" . ($version?"-$version":""));
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("/usr/bin/apt-get -y install $pkg" . ($version?"-$version":""));
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("/usr/bin/apt-get -y remove $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("/usr/bin/apt-get -y remove $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run '/usr/bin/rpm -qa --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
+  my @lines = i_run '/usr/bin/rpm -qa --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
-         push(@pkg, {
-            name    => $1,
-            epoch   => $2,
-            version => $3,
-            release => $4,
-            arch    => $5,
-         });
-      }
-   }
+  for my $line (@lines) {
+    if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
+      push(@pkg, {
+        name   => $1,
+        epoch  => $2,
+        version => $3,
+        release => $4,
+        arch   => $5,
+      });
+    }
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "/usr/bin/apt-get update";
-   if($? != 0) {
-      die("Error updating package repository");
-   }
+  i_run "/usr/bin/apt-get update";
+  if($? != 0) {
+    die("Error updating package repository");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   my $name = $data{"name"};
-   my $sign = $data{"sign_key"} || "";
-   my @arch = split(/, */, $data{"arch"});
-
-   my $fh = file_write "/etc/apt/sources.list.d/$name.list";
-   $fh->write("# This file is managed by Rex\n");
-
-   foreach(@arch) {
-       $fh->write("rpm " .($sign?"[".$sign."] ":""). $data{"url"} . " " . $_ . " " . $data{"repository"} . "\n");
-   };
-   $fh->close;
+  my ($self, %data) = @_;
+  my $name = $data{"name"};
+  my $sign = $data{"sign_key"} || "";
+  my @arch = split(/, */, $data{"arch"});
+
+  my $fh = file_write "/etc/apt/sources.list.d/$name.list";
+  $fh->write("# This file is managed by Rex\n");
+
+  foreach(@arch) {
+     $fh->write("rpm " .($sign?"[".$sign."] ":""). $data{"url"} . " " . $_ . " " . $data{"repository"} . "\n");
+  };
+  $fh->close;
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   unlink "/etc/apt/sources.list.d/$name.list";
+  my ($self, $name) = @_;
+  unlink "/etc/apt/sources.list.d/$name.list";
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Pkg::Base;
 
 use strict;
@@ -11,65 +11,65 @@ use warnings;
 use Rex::Interface::Exec;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   Rex::Logger::info("Checking for installed package not supported on this platform", "warn");
+  Rex::Logger::info("Checking for installed package not supported on this platform", "warn");
 }
 
 sub install {
-   Rex::Logger::info("Installing package not supported on this platform", "warn");
+  Rex::Logger::info("Installing package not supported on this platform", "warn");
 }
 
 sub bulk_install {
-   Rex::Logger::info("Installing bulk packages not supported on this platform. Falling back to one by one method", "warn");
-
-   my ($self, $packages_aref, $option) = @_;
-   for my $pkg_to_install (@{$packages_aref}) {
-      $self->install($pkg_to_install, $option);
-   }
-   
-   return 1;
+  Rex::Logger::info("Installing bulk packages not supported on this platform. Falling back to one by one method", "warn");
+
+  my ($self, $packages_aref, $option) = @_;
+  for my $pkg_to_install (@{$packages_aref}) {
+    $self->install($pkg_to_install, $option);
+  }
+  
+  return 1;
 }
 
 sub update {
-   Rex::Logger::info("Updating package not supported on this platform", "warn");
+  Rex::Logger::info("Updating package not supported on this platform", "warn");
 }
 
 sub update_system {
-   Rex::Logger::info("Complete system update not supported on this platform", "warn");
+  Rex::Logger::info("Complete system update not supported on this platform", "warn");
 }
 
 sub remove {
-   Rex::Logger::info("Removing package not supported on this platform", "warn");
+  Rex::Logger::info("Removing package not supported on this platform", "warn");
 }
 
 sub get_installed {
-   Rex::Logger::info("Listing installed packages not supported on this platform", "warn");
+  Rex::Logger::info("Listing installed packages not supported on this platform", "warn");
 }
 
 sub update_pkg_db {
-   Rex::Logger::info("Updating package database not supported on this platform", "warn");
+  Rex::Logger::info("Updating package database not supported on this platform", "warn");
 }
 
 sub add_repository {
-   Rex::Logger::info("Adding new repositories not supported on this platform", "warn");
+  Rex::Logger::info("Adding new repositories not supported on this platform", "warn");
 }
 
 sub rm_repository {
-   Rex::Logger::info("Removing repositories not supported on this platform", "warn");
+  Rex::Logger::info("Removing repositories not supported on this platform", "warn");
 }
 
 sub _exec {
-   my ($self, $cmd) = @_;
-   my $exec = Rex::Interface::Exec->create;
-   $exec->exec($cmd);
+  my ($self, $cmd) = @_;
+  my $exec = Rex::Interface::Exec->create;
+  $exec->exec($cmd);
 }
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::Debian;
@@ -18,162 +18,162 @@ use Rex::Pkg::Base;
 use base qw(Rex::Pkg::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
 
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
+
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  my @pkg_info = $self->get_installed($pkg);
 
-   my @pkg_info = $self->get_installed($pkg);
+  unless(@pkg_info) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
 
-   unless(@pkg_info) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub bulk_install {
-   my ($self, $packages_aref, $option) = @_;
-   
-   delete $option->{version}; # makes no sense to specify the same version for several packages
-    
-   $self->update("@{$packages_aref}", $option);
-   
-   return 1;
+  my ($self, $packages_aref, $option) = @_;
+
+  delete $option->{version}; # makes no sense to specify the same version for several packages
+
+  $self->update("@{$packages_aref}", $option);
+
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=--force-confold --force-yes -y install $pkg" . ($version?"=$version":""));
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=--force-confold --force-yes -y install $pkg" . ($version?"=$version":""));
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub update_system {
-   my ($self) = @_;
-   i_run("apt-get -y upgrade");
+  my ($self) = @_;
+  i_run("DEBIAN_FRONTEND=noninteractive apt-get -y -qq upgrade");
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("apt-get -y remove $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("apt-get -y remove $pkg");
 
-   Rex::Logger::debug("Purging $pkg");
-   i_run("dpkg --purge $pkg");
+  Rex::Logger::debug("Purging $pkg");
+  i_run("dpkg --purge $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self, $pkg) = @_;
-   my @pkgs;
-   my $dpkg_cmd = 'dpkg-query -W --showformat "\${Status} \${Package}|\${Version}\n"';
-   if ($pkg) {
-       $dpkg_cmd .= " ". $pkg;
-   }
-   
-   my @lines = i_run $dpkg_cmd;
-
-   for my $line (@lines) {
-      if($line =~ m/^install ok installed ([^\|]+)\|(.*)$/) {
-         push(@pkgs, {
-            name    => $1,
-            version => $2,
-         });
-      }
-   }
-
-   return @pkgs;
+  my ($self, $pkg) = @_;
+  my @pkgs;
+  my $dpkg_cmd = 'dpkg-query -W --showformat "\${Status} \${Package}|\${Version}\n"';
+  if ($pkg) {
+     $dpkg_cmd .= " ". $pkg;
+  }
+
+  my @lines = i_run $dpkg_cmd;
+
+  for my $line (@lines) {
+    if($line =~ m/^install ok installed ([^\|]+)\|(.*)$/) {
+      push(@pkgs, {
+        name   => $1,
+        version => $2,
+      });
+    }
+  }
+
+  return @pkgs;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "apt-get -y update";
-   if($? != 0) {
-      die("Error updating package database");
-   }
+  i_run "apt-get -y update";
+  if($? != 0) {
+    die("Error updating package database");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-
-   my $name = $data{"name"};
-
-   my $fh = file_write "/etc/apt/sources.list.d/$name.list";
-   $fh->write("# This file is managed by Rex\n");
-   if(exists $data{"arch"}) {
-      $fh->write("deb [arch=" . $data{"arch"} . "] " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
-   }
-   else {
-      $fh->write("deb " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
-   }
-   if(exists $data{"source"} && $data{"source"}) {
-      $fh->write("deb-src " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
-   }
-   $fh->close;
-
-   if(exists $data{"key_url"}) {
-      i_run "wget -O - " . $data{"key_url"} . " | apt-key add -";
-   }
-
-   if(exists $data{"key_id"} && $data{"key_server"}) {
-      i_run "apt-key adv --keyserver " . $data{"key_server"} . " --recv-keys " . $data{"key_id"};
-   }
+  my ($self, %data) = @_;
+
+  my $name = $data{"name"};
+
+  my $fh = file_write "/etc/apt/sources.list.d/$name.list";
+  $fh->write("# This file is managed by Rex\n");
+  if(exists $data{"arch"}) {
+    $fh->write("deb [arch=" . $data{"arch"} . "] " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
+  }
+  else {
+    $fh->write("deb " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
+  }
+  if(exists $data{"source"} && $data{"source"}) {
+    $fh->write("deb-src " . $data{"url"} . " " . $data{"distro"} . " " . $data{"repository"} . "\n");
+  }
+  $fh->close;
+
+  if(exists $data{"key_url"}) {
+    i_run "wget -O - " . $data{"key_url"} . " | apt-key add -";
+  }
+
+  if(exists $data{"key_id"} && $data{"key_server"}) {
+    i_run "apt-key adv --keyserver " . $data{"key_server"} . " --recv-keys " . $data{"key_id"};
+  }
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   unlink "/etc/apt/sources.list.d/$name.list";
+  my ($self, $name) = @_;
+  unlink "/etc/apt/sources.list.d/$name.list";
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::FreeBSD;
@@ -17,121 +17,121 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("pkg_info $pkg-\\*");
+  i_run("pkg_info $pkg-\\*");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
 
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Version option not supported.");
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("pkg_add -r $pkg");
+  Rex::Logger::debug("Version option not supported.");
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("pkg_add -r $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
 
-   my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
-   my $pkg_version = $pkg_found->{"version"};
+  my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
+  my $pkg_version = $pkg_found->{"version"};
 
-   Rex::Logger::debug("Removing $pkg-$pkg_version");
-   my $f = i_run("pkg_delete $pkg-$pkg_version");
+  Rex::Logger::debug("Removing $pkg-$pkg_version");
+  my $f = i_run("pkg_delete $pkg-$pkg_version");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg-$pkg_version.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg-$pkg_version");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg-$pkg_version.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg-$pkg_version");
+  }
 
-   Rex::Logger::debug("$pkg-$pkg_version successfully removed.");
+  Rex::Logger::debug("$pkg-$pkg_version successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run "pkg_info";
+  my @lines = i_run "pkg_info";
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      my ($pkg_name_v, $descr) = split(/\s/, $line, 2);
+  for my $line (@lines) {
+    my ($pkg_name_v, $descr) = split(/\s/, $line, 2);
 
-      my ($pkg_name, $pkg_version) = ($pkg_name_v =~ m/^(.*)-(.*?)$/);
+    my ($pkg_name, $pkg_version) = ($pkg_name_v =~ m/^(.*)-(.*?)$/);
 
-      push(@pkg, {
-         name    => $pkg_name,
-         version => $pkg_version,
-      });
-   }
+    push(@pkg, {
+      name   => $pkg_name,
+      version => $pkg_version,
+    });
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self, %data) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self, $name) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::Gentoo;
@@ -17,156 +17,156 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   unless(grep { $_->{"name"} eq $pkg } get_installed()) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless(grep { $_->{"name"} eq $pkg } get_installed()) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub bulk_install {
-   my ($self, $packages_aref, $option) = @_;
-   
-   delete $option->{version}; # makes no sense to specify the same version for several packages
-    
-   $self->update("@{$packages_aref}", $option);
+  my ($self, $packages_aref, $option) = @_;
+  
+  delete $option->{version}; # makes no sense to specify the same version for several packages
    
-   return 1;
+  $self->update("@{$packages_aref}", $option);
+  
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
-   if($version) {
-      $pkg = "=$pkg-$version";
-   }
+  my $version = $option->{'version'} || '';
+  if($version) {
+    $pkg = "=$pkg-$version";
+  }
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("emerge $pkg");
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("emerge $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("emerge -C $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("emerge -C $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
-
-   # ,,stolen'' from epm
-   my $pkgregex =
-      '(.+?)'.                                    # name
-      '-(\d+(?:\.\d+)*\w*)'.                      # version, eg 1.23.4a
-      '((?:(?:_alpha|_beta|_pre|_rc)\d*)?)'.      # special suffix
-      '((?:-r\d+)?)$';                            # revision, eg r12
-
-   my @ret;
-
-   for my $line (i_run("ls -d /var/db/pkg/*/* | cut -d '/' -f6-")) {
-      my $r = qr{$pkgregex};
-      my ($name, $version, $suffix, $revision) = ($line =~ $r);
-      push(@ret, {
-         name => $name,
-         version => $version,
-         suffix => $suffix,
-         release => $revision,
-      });
-   }
-
-   return @ret;
+  my ($self) = @_;
+
+  # ,,stolen'' from epm
+  my $pkgregex =
+    '(.+?)'.                        # name
+    '-(\d+(?:\.\d+)*\w*)'.               # version, eg 1.23.4a
+    '((?:(?:_alpha|_beta|_pre|_rc)\d*)?)'.    # special suffix
+    '((?:-r\d+)?)$';                   # revision, eg r12
+
+  my @ret;
+
+  for my $line (i_run("ls -d /var/db/pkg/*/* | cut -d '/' -f6-")) {
+    my $r = qr{$pkgregex};
+    my ($name, $version, $suffix, $revision) = ($line =~ $r);
+    push(@ret, {
+      name => $name,
+      version => $version,
+      suffix => $suffix,
+      release => $revision,
+    });
+  }
+
+  return @ret;
 }
 
 sub update_system {
-   my ($self) = @_;
-   i_run "emerge --update --deep --with-bdeps=y --newuse world";
+  my ($self) = @_;
+  i_run "emerge --update --deep --with-bdeps=y --newuse world";
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "emerge --sync";
-   if($? != 0) {
-      die("Error updating package database");
-   }
+  i_run "emerge --sync";
+  if($? != 0) {
+    die("Error updating package database");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my $name = $data{"name"};
+  my $name = $data{"name"};
 
-   if(can_run("layman")) {
-      i_run "layman -a $name";
-   }
-   else {
-      Rex::Logger::debug("You have to install layman, git and subversion.");
-      die("Please install layman, git and subversion");
-   }
+  if(can_run("layman")) {
+    i_run "layman -a $name";
+  }
+  else {
+    Rex::Logger::debug("You have to install layman, git and subversion.");
+    die("Please install layman, git and subversion");
+  }
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-
-   if(can_run("layman")) {
-      i_run "layman -d $name";
-   }
-   else {
-      Rex::Logger::debug("You have to install layman, git and subversion.");
-      die("Please install layman, git and subversion");
-   }
+  my ($self, $name) = @_;
+
+  if(can_run("layman")) {
+    i_run "layman -d $name";
+  }
+  else {
+    Rex::Logger::debug("You have to install layman, git and subversion.");
+    die("Please install layman, git and subversion");
+  }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::Mageia;
@@ -16,131 +16,131 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("rpm -ql $pkg");
+  i_run("rpm -ql $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{"version"} || "";
+  my $version = $option->{"version"} || "";
 
-   my $f = i_run("urpmi --auto --quiet $pkg");
+  my $f = i_run("urpmi --auto --quiet $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub update_system {
-   my ($self) = @_;
-   i_run "urpmi --auto --quiet --auto-update";
+  my ($self) = @_;
+  i_run "urpmi --auto --quiet --auto-update";
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("urpme --auto $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("urpme --auto $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
+  my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
-         push(@pkg, {
-            name    => $1,
-            epoch   => $2,
-            version => $3,
-            release => $4,
-            arch    => $5,
-         });
-      }
-   }
+  for my $line (@lines) {
+    if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
+      push(@pkg, {
+        name   => $1,
+        epoch  => $2,
+        version => $3,
+        release => $4,
+        arch   => $5,
+      });
+    }
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "urpmi.update -a";
-   if($? != 0) {
-      die("Error updating package repository");
-   }
+  i_run "urpmi.update -a";
+  if($? != 0) {
+    die("Error updating package repository");
+  }
 }
 sub add_repository {
-   my ($self, %data) = @_;
-   my $name = $data{"name"};
+  my ($self, %data) = @_;
+  my $name = $data{"name"};
 
-   i_run "urpmi.addmedia $name " . $data{"url"};
-   if($? != 0) {
-      die("Error adding repository $name");
-   }
+  i_run "urpmi.addmedia $name " . $data{"url"};
+  if($? != 0) {
+    die("Error adding repository $name");
+  }
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   i_run "urpmi.removemedia $name";
-   if($? != 0) {
-      die("Error removing repository $name");
-   }
+  my ($self, $name) = @_;
+  i_run "urpmi.removemedia $name";
+  if($? != 0) {
+    die("Error removing repository $name");
+  }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::NetBSD;
@@ -17,122 +17,122 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
-
-   Rex::Logger::debug("Checking if $pkg is installed");
-
-   unless(grep { $_->{"name"} eq $pkg } get_installed()) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  my ($self, $pkg) = @_;
+
+  Rex::Logger::debug("Checking if $pkg is installed");
+
+  unless(grep { $_->{"name"} eq $pkg } get_installed()) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = ($option->{"version"}?"-".$option->{"version"}:"");
+  my $version = ($option->{"version"}?"-".$option->{"version"}:"");
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run(". /etc/profile; /usr/sbin/pkg_add $pkg$version");
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run(". /etc/profile; /usr/sbin/pkg_add $pkg$version");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
 
-   my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
-   my $pkg_version = $pkg_found->{"version"};
+  my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
+  my $pkg_version = $pkg_found->{"version"};
 
-   Rex::Logger::debug("Removing $pkg-$pkg_version");
-   my $f = i_run("/usr/sbin/pkg_delete $pkg-$pkg_version");
+  Rex::Logger::debug("Removing $pkg-$pkg_version");
+  my $f = i_run("/usr/sbin/pkg_delete $pkg-$pkg_version");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg-$pkg_version.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg-$pkg_version");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg-$pkg_version.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg-$pkg_version");
+  }
 
-   Rex::Logger::debug("$pkg-$pkg_version successfully removed.");
+  Rex::Logger::debug("$pkg-$pkg_version successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run "/usr/sbin/pkg_info";
+  my @lines = i_run "/usr/sbin/pkg_info";
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      my ($pkg_name_v, $descr) = split(/\s/, $line, 2);
+  for my $line (@lines) {
+    my ($pkg_name_v, $descr) = split(/\s/, $line, 2);
 
-      my ($pkg_name, $pkg_version) = ($pkg_name_v =~ m/^(.*)-(.*?)$/);
+    my ($pkg_name, $pkg_version) = ($pkg_name_v =~ m/^(.*)-(.*?)$/);
 
-      push(@pkg, {
-         name    => $pkg_name,
-         version => $pkg_version,
-      });
-   }
+    push(@pkg, {
+      name   => $pkg_name,
+      version => $pkg_version,
+    });
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self, %data) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   Rex::Logger::debug("Not supported under BSD");
+  my ($self, $name) = @_;
+  Rex::Logger::debug("Not supported under BSD");
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::OpenBSD;
@@ -17,13 +17,13 @@ use Rex::Pkg::NetBSD;
 use base qw(Rex::Pkg::NetBSD);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -17,146 +17,146 @@ use Rex::Pkg::Base;
 use base qw(Rex::Pkg::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   my @pkg_info = $self->get_installed($pkg);
+  my @pkg_info = $self->get_installed($pkg);
 
-   unless(@pkg_info) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
+  unless(@pkg_info) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
 
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub bulk_install {
-   my ($self, $packages_aref, $option) = @_;
+  my ($self, $packages_aref, $option) = @_;
+  
+  delete $option->{version}; # makes no sense to specify the same version for several packages
    
-   delete $option->{version}; # makes no sense to specify the same version for several packages
-    
-   $self->update("@{$packages_aref}", $option);
-   
-   return 1;
+  $self->update("@{$packages_aref}", $option);
+  
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("opkg install $pkg");
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("opkg install $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub update_system {
-   my ($self) = @_;
-   my @pkgs;
-   my @lines = i_run("opkg list-upgradable");
+  my ($self) = @_;
+  my @pkgs;
+  my @lines = i_run("opkg list-upgradable");
 
-   for my $line (@lines) {
-      if($line =~ m/^(.*) - .* - .*$/) { push(@pkgs, $1); }
-   }
+  for my $line (@lines) {
+    if($line =~ m/^(.*) - .* - .*$/) { push(@pkgs, $1); }
+  }
 
-   my $packages_to_upgrade = join(" ", @pkgs);
+  my $packages_to_upgrade = join(" ", @pkgs);
 
-   i_run("opkg upgrade " . $packages_to_upgrade);
+  i_run("opkg upgrade " . $packages_to_upgrade);
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("opkg remove $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("opkg remove $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 sub get_installed {
-   my ($self, $pkg) = @_;
-   my @pkgs;
-   my $opkg_cmd = 'opkg list-installed';
-   if ($pkg) {
-       $opkg_cmd .= ' | grep "^' . $pkg . ' "';
-   }
-
-   my @lines = i_run $opkg_cmd;
-
-   for my $line (@lines) {
-      if($line =~ m/^(.*) - (.*)$/) {
-         push(@pkgs, {
-            name    => $1,
-            version => $2,
-         });
-      }
-   }
-
-   return @pkgs;
+  my ($self, $pkg) = @_;
+  my @pkgs;
+  my $opkg_cmd = 'opkg list-installed';
+  if ($pkg) {
+     $opkg_cmd .= ' | grep "^' . $pkg . ' "';
+  }
+
+  my @lines = i_run $opkg_cmd;
+
+  for my $line (@lines) {
+    if($line =~ m/^(.*) - (.*)$/) {
+      push(@pkgs, {
+        name   => $1,
+        version => $2,
+      });
+    }
+  }
+
+  return @pkgs;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "opkg update";
-   if($? != 0) {
-      die("Error updating package database");
-   }
+  i_run "opkg update";
+  if($? != 0) {
+    die("Error updating package database");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   append_if_no_such_line "/etc/opkg.conf",
-      "src/gz " . $data{"name"} . " " . $data{"url"},
-      $data{"name"},
-      $data{"url"};
+  my ($self, %data) = @_;
+  append_if_no_such_line "/etc/opkg.conf",
+    "src/gz " . $data{"name"} . " " . $data{"url"},
+    $data{"name"},
+    $data{"url"};
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   delete_lines_matching "/etc/opkg.conf" => "src/gz " . $name . " ";
+  my ($self, $name) = @_;
+  delete_lines_matching "/etc/opkg.conf" => "src/gz " . $name . " ";
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::Redhat;
@@ -18,165 +18,165 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("rpm -ql $pkg");
+  i_run("rpm -ql $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub bulk_install {
-   my ($self, $packages_aref, $option) = @_;
-   
-   delete $option->{version}; # makes no sense to specify the same version for several packages
-    
-   $self->update("@{$packages_aref}", $option);
+  my ($self, $packages_aref, $option) = @_;
+  
+  delete $option->{version}; # makes no sense to specify the same version for several packages
    
-   return 1;
+  $self->update("@{$packages_aref}", $option);
+  
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{"version"} || "";
+  my $version = $option->{"version"} || "";
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run(_yum("-y install $pkg" . ($version?"-$version":"")));
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run(_yum("-y install $pkg" . ($version?"-$version":"")));
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run(_yum("-y erase $pkg"));
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run(_yum("-y erase $pkg"));
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
+  my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
-         push(@pkg, {
-            name    => $1,
-            epoch   => $2,
-            version => $3,
-            release => $4,
-            arch    => $5,
-         });
-      }
-   }
+  for my $line (@lines) {
+    if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
+      push(@pkg, {
+        name   => $1,
+        epoch  => $2,
+        version => $3,
+        release => $4,
+        arch   => $5,
+      });
+    }
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_system {
-   my ($self) = @_;
-   i_run(_yum("-y upgrade"));
+  my ($self) = @_;
+  i_run(_yum("-y upgrade"));
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run(_yum("clean all"));
-   i_run(_yum("makecache"));
-   if($? != 0) {
-      die("Error updating package repository");
-   }
+  i_run(_yum("clean all"));
+  i_run(_yum("makecache"));
+  if($? != 0) {
+    die("Error updating package repository");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
+  my ($self, %data) = @_;
 
-   my $name = $data{"name"};
-   my $desc = $data{"description"} || $data{"name"};
+  my $name = $data{"name"};
+  my $desc = $data{"description"} || $data{"name"};
 
-   my $fh = file_write "/etc/yum.repos.d/$name.repo";
+  my $fh = file_write "/etc/yum.repos.d/$name.repo";
 
-   $fh->write("# This file is managed by Rex\n");
-   $fh->write("[$name]\n");
-   $fh->write("name=$desc\n");
-   $fh->write("baseurl=" . $data{"url"} . "\n");
-   $fh->write("enabled=1\n");
-   $fh->write("gpgcheck=" . $data{"gpgcheck"} ."\n") if defined $data{"gpgcheck"};
+  $fh->write("# This file is managed by Rex\n");
+  $fh->write("[$name]\n");
+  $fh->write("name=$desc\n");
+  $fh->write("baseurl=" . $data{"url"} . "\n");
+  $fh->write("enabled=1\n");
+  $fh->write("gpgcheck=" . $data{"gpgcheck"} ."\n") if defined $data{"gpgcheck"};
 
-   $fh->close;
+  $fh->close;
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   unlink "/etc/yum.repos.d/$name.repo";
+  my ($self, $name) = @_;
+  unlink "/etc/yum.repos.d/$name.repo";
 }
 
 
 sub _yum {
-   my (@cmd) = @_;
+  my (@cmd) = @_;
 
-   my $str;
+  my $str;
 
-   if($Rex::Logger::debug) {
-      $str = join(' ', "yum ", @cmd);
-   }
-   else {
-      $str = join(' ', "yum -q ", @cmd);
-   }
+  if($Rex::Logger::debug) {
+    $str = join(' ', "yum ", @cmd);
+  }
+  else {
+    $str = join(' ', "yum -q ", @cmd);
+  }
 
-   return $str;
+  return $str;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::SuSE;
@@ -16,149 +16,149 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("rpm -ql $pkg");
+  i_run("rpm -ql $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub bulk_install {
-   my ($self, $packages_aref, $option) = @_;
-   
-   delete $option->{version}; # makes no sense to specify the same version for several packages
-    
-   $self->update("@{$packages_aref}", $option);
+  my ($self, $packages_aref, $option) = @_;
+  
+  delete $option->{version}; # makes no sense to specify the same version for several packages
    
-   return 1;
+  $self->update("@{$packages_aref}", $option);
+  
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{"version"} || "";
+  my $version = $option->{"version"} || "";
 
-   Rex::Logger::debug("Installing $pkg / $version");
-   my $f = i_run("zypper -n install $pkg".($version?"-$version":""));
+  Rex::Logger::debug("Installing $pkg / $version");
+  my $f = i_run("zypper -n install $pkg".($version?"-$version":""));
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("zypper -n remove $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("zypper -n remove $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
+  my @lines = i_run 'rpm -qa --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n"';
 
-   my @pkg;
+  my @pkg;
 
-   for my $line (@lines) {
-      if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
-         push(@pkg, {
-            name    => $1,
-            epoch   => $2,
-            version => $3,
-            release => $4,
-            arch    => $5,
-         });
-      }
-   }
+  for my $line (@lines) {
+    if($line =~ m/^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.*)$/) {
+      push(@pkg, {
+        name   => $1,
+        epoch  => $2,
+        version => $3,
+        release => $4,
+        arch   => $5,
+      });
+    }
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_system {
-   my ($self) = @_;
-   i_run "zypper -n up";
+  my ($self) = @_;
+  i_run "zypper -n up";
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "zypper --no-gpg-checks -n ref -fd";
-   if($? != 0) {
-      die("Error updating package repository");
-   }
+  i_run "zypper --no-gpg-checks -n ref -fd";
+  if($? != 0) {
+    die("Error updating package repository");
+  }
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   i_run "zypper addrepo -f -n " . $data{"name"} . " " . $data{"url"} . " " . $data{"name"};
-   if($? == 4) {
-      if(Rex::Config->get_do_reporting) {
-         return {changed => 0};
-      }
-   }
-   if($? != 0) {
-      die("Error adding repository " . $data{name});
-   }
+  my ($self, %data) = @_;
+  i_run "zypper addrepo -f -n " . $data{"name"} . " " . $data{"url"} . " " . $data{"name"};
+  if($? == 4) {
+    if(Rex::Config->get_do_reporting) {
+      return {changed => 0};
+    }
+  }
+  if($? != 0) {
+    die("Error adding repository " . $data{name});
+  }
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   i_run "zypper removerepo $name";
-   if($? != 0) {
-      die("Error removing repository $name");
-   }
-
-   if(Rex::Config->get_do_reporting) {
-      return {changed => 1};
-   }
+  my ($self, $name) = @_;
+  i_run "zypper removerepo $name";
+  if($? != 0) {
+    die("Error removing repository $name");
+  }
+
+  if(Rex::Config->get_do_reporting) {
+    return {changed => 1};
+  }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::SunOS::OpenCSW;
@@ -17,78 +17,78 @@ use Rex::Pkg::SunOS;
 use base qw(Rex::Pkg::SunOS);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Version option not supported.");
-   Rex::Logger::debug("Installing $pkg");
+  Rex::Logger::debug("Version option not supported.");
+  Rex::Logger::debug("Installing $pkg");
 
-   my $cmd = $self->_pkgutil() . " --yes -i $pkg";
-   my $f = i_run($cmd);
+  my $cmd = $self->_pkgutil() . " --yes -i $pkg";
+  my $f = i_run($cmd);
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
 
-   Rex::Logger::debug("Removing $pkg");
+  Rex::Logger::debug("Removing $pkg");
 
-   my $cmd = $self->_pkgutil() . " --yes -r $pkg";
-   my $f = i_run($cmd . " $pkg");
+  my $cmd = $self->_pkgutil() . " --yes -r $pkg";
+  my $f = i_run($cmd . " $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub update_pkg_db {
-   my ($self) = @_;
-   i_run $self->_pkgutil() . " -U";
+  my ($self) = @_;
+  i_run $self->_pkgutil() . " -U";
 }
 
 sub _pkgutil {
-   return "/opt/csw/bin/pkgutil";
+  return "/opt/csw/bin/pkgutil";
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::SunOS::pkg;
@@ -17,118 +17,118 @@ use Rex::Pkg::SunOS;
 use base qw(Rex::Pkg::SunOS);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("pkg info $pkg");
+  i_run("pkg info $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Installing $pkg");
-   my $f = i_run "pkg install -q --accept $pkg";
+  Rex::Logger::debug("Installing $pkg");
+  my $f = i_run "pkg install -q --accept $pkg";
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Removing $pkg");
-   my $f = i_run("pkg uninstall -r -q $pkg");
+  Rex::Logger::debug("Removing $pkg");
+  my $f = i_run("pkg uninstall -r -q $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
-
-   my @lines = i_run "pkg info -l";
-
-   my @pkg;
-
-   my ($version, $name);
-   for my $line (@lines) {
-      if($line =~ m/^$/) {
-         push(@pkg, {
-            name => $name,
-            version => $version,
-         });
-         next;
-      }
-
-      if($line =~ m/Name: .*\/(.*?)$/) {
-         $name = $1;
-         next;
-      }
-
-      if($line =~ m/Version: (.*)$/) {
-         $version = $1;
-         next;
-      }
-   }
-
-   return @pkg;
+  my ($self) = @_;
+
+  my @lines = i_run "pkg info -l";
+
+  my @pkg;
+
+  my ($version, $name);
+  for my $line (@lines) {
+    if($line =~ m/^$/) {
+      push(@pkg, {
+        name => $name,
+        version => $version,
+      });
+      next;
+    }
+
+    if($line =~ m/Name: .*\/(.*?)$/) {
+      $name = $1;
+      next;
+    }
+
+    if($line =~ m/Version: (.*)$/) {
+      $version = $1;
+      next;
+    }
+  }
+
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   i_run "pkg refresh";
-   if($? != 0) {
-      die("Error updating package database");
-   }
+  i_run "pkg refresh";
+  if($? != 0) {
+    die("Error updating package database");
+  }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::SunOS;
@@ -17,151 +17,151 @@ use base qw(Rex::Pkg::Base);
 
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub is_installed {
-   my ($self, $pkg) = @_;
+  my ($self, $pkg) = @_;
 
-   Rex::Logger::debug("Checking if $pkg is installed");
+  Rex::Logger::debug("Checking if $pkg is installed");
 
-   i_run("pkginfo $pkg");
+  i_run("pkginfo $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::debug("$pkg is NOT installed.");
-      return 0;
-   }
-   
-   Rex::Logger::debug("$pkg is installed.");
-   return 1;
+  unless($? == 0) {
+    Rex::Logger::debug("$pkg is NOT installed.");
+    return 0;
+  }
+  
+  Rex::Logger::debug("$pkg is installed.");
+  return 1;
 }
 
 sub install {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   if($self->is_installed($pkg) && ! $option->{"version"}) {
-      Rex::Logger::info("$pkg is already installed");
-      return 1;
-   }
+  if($self->is_installed($pkg) && ! $option->{"version"}) {
+    Rex::Logger::info("$pkg is already installed");
+    return 1;
+  }
 
-   $self->update($pkg, $option);
+  $self->update($pkg, $option);
 
-   return 1;
+  return 1;
 }
 
 sub update {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
-   my $version = $option->{'version'} || '';
+  my $version = $option->{'version'} || '';
 
-   Rex::Logger::debug("Version option not supported.");
-   Rex::Logger::debug("Installing $pkg / $version");
+  Rex::Logger::debug("Version option not supported.");
+  Rex::Logger::debug("Installing $pkg / $version");
 
-   my $cmd = "pkgadd ";
+  my $cmd = "pkgadd ";
 
-   if(! exists $option->{"source"}) {
-      die("You have to specify the source.");
-   }
+  if(! exists $option->{"source"}) {
+    die("You have to specify the source.");
+  }
 
-   $cmd .= " -a " . $option->{"adminfile"} if($option->{"adminfile"});
-   $cmd .= " -r " . $option->{"responsefile"} if($option->{"responsefile"});
+  $cmd .= " -a " . $option->{"adminfile"} if($option->{"adminfile"});
+  $cmd .= " -r " . $option->{"responsefile"} if($option->{"responsefile"});
 
-   $cmd .= " -d " . $option->{"source"};
-   $cmd .= " -n " . $pkg;
+  $cmd .= " -d " . $option->{"source"};
+  $cmd .= " -n " . $pkg;
 
-   my $f = i_run($cmd);
+  my $f = i_run($cmd);
 
-   unless($? == 0) {
-      Rex::Logger::info("Error installing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error installing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error installing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error installing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully installed.");
+  Rex::Logger::debug("$pkg successfully installed.");
 
 
-   return 1;
+  return 1;
 }
 
 sub remove {
-   my ($self, $pkg, $option) = @_;
+  my ($self, $pkg, $option) = @_;
 
 
-   Rex::Logger::debug("Removing $pkg");
+  Rex::Logger::debug("Removing $pkg");
 
-   my $cmd = "pkgrm -n ";
-   $cmd .= " -a " . $option->{"adminfile"} if($option->{"adminfile"});
+  my $cmd = "pkgrm -n ";
+  $cmd .= " -a " . $option->{"adminfile"} if($option->{"adminfile"});
 
-   my $f = i_run($cmd . " $pkg");
+  my $f = i_run($cmd . " $pkg");
 
-   unless($? == 0) {
-      Rex::Logger::info("Error removing $pkg.", "warn");
-      Rex::Logger::debug($f);
-      die("Error removing $pkg");
-   }
+  unless($? == 0) {
+    Rex::Logger::info("Error removing $pkg.", "warn");
+    Rex::Logger::debug($f);
+    die("Error removing $pkg");
+  }
 
-   Rex::Logger::debug("$pkg successfully removed.");
+  Rex::Logger::debug("$pkg successfully removed.");
 
-   return 1;
+  return 1;
 }
 
 
 sub get_installed {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my @lines = i_run "pkginfo -l";
+  my @lines = i_run "pkginfo -l";
 
-   my (@pkg, %current);
+  my (@pkg, %current);
 
-   for my $line (@lines) {
-      if($line =~ m/^$/) {
-         push(@pkg, { %current });
-         next;
-      }
+  for my $line (@lines) {
+    if($line =~ m/^$/) {
+      push(@pkg, { %current });
+      next;
+    }
 
-      if($line =~ m/PKGINST:\s+([^\s]+)/) {
-         $current{"name"} = $1;
-         next;
-      }
+    if($line =~ m/PKGINST:\s+([^\s]+)/) {
+      $current{"name"} = $1;
+      next;
+    }
 
-      if($line =~ m/VERSION:\s+([^\s]+)/) {
-         my ($version, $rev) = split(/,/, $1);
-         $current{"version"} = $version;
-         $rev =~ s/^REV=// if($rev);
-         $current{"revision"} = $rev;
-         next;
-      }
+    if($line =~ m/VERSION:\s+([^\s]+)/) {
+      my ($version, $rev) = split(/,/, $1);
+      $current{"version"} = $version;
+      $rev =~ s/^REV=// if($rev);
+      $current{"revision"} = $rev;
+      next;
+    }
 
 
-      if($line =~ m/STATUS:\s+(.*?)$/) {
-         $current{"status"} = ($1 eq "completely installed"?"installed":$1);
-         next;
-      }
+    if($line =~ m/STATUS:\s+(.*?)$/) {
+      $current{"status"} = ($1 eq "completely installed"?"installed":$1);
+      next;
+    }
 
-   }
+  }
 
-   return @pkg;
+  return @pkg;
 }
 
 sub update_pkg_db {
-   my ($self) = @_;
-   Rex::Logger::debug("Not supported under Solaris");
+  my ($self) = @_;
+  Rex::Logger::debug("Not supported under Solaris");
 }
 
 sub add_repository {
-   my ($self, %data) = @_;
-   Rex::Logger::debug("Not supported under Solaris");
+  my ($self, %data) = @_;
+  Rex::Logger::debug("Not supported under Solaris");
 }
 
 sub rm_repository {
-   my ($self, $name) = @_;
-   Rex::Logger::debug("Not supported under Solaris");
+  my ($self, $name) = @_;
+  Rex::Logger::debug("Not supported under Solaris");
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg::Ubuntu;
@@ -16,13 +16,13 @@ use Rex::Commands::File;
 use base qw(Rex::Pkg::Debian);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Pkg;
@@ -19,52 +19,52 @@ use Data::Dumper;
 
 my %PKG_PROVIDER;
 sub register_package_provider {
-   my ($class, $service_name, $service_class) = @_;
-   $PKG_PROVIDER{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $PKG_PROVIDER{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub get {
 
-   my ($self) = @_;
-
-   my %_host = %{ Rex::Hardware::Host->get() };
-   my $host = { %_host };
-
-   my $pkg_provider_for = Rex::Config->get("package_provider") || {};
-
-   #if(lc($host->{"operatingsystem"}) eq "centos" || lc($host->{"operatingsystem"}) eq "redhat") {
-   if(is_redhat()) {
-      $host->{"operatingsystem"} = "Redhat";
-   }
-
-   my $class = "Rex::Pkg::" . $host->{"operatingsystem"};
-
-   my $provider;
-   if(ref($pkg_provider_for) && exists $pkg_provider_for->{$host->{"operatingsystem"}}) {
-      $provider = $pkg_provider_for->{$host->{"operatingsystem"}};
-      $class .= "::$provider";
-   }
-   elsif(exists $PKG_PROVIDER{$pkg_provider_for}) {
-      $class = $PKG_PROVIDER{$pkg_provider_for};
-   }
-
-   Rex::Logger::debug("Using $class for package management");
-   eval "use $class";
-
-   if($@) {
-   
-      if($provider) {
-         Rex::Logger::info("Provider not supported (" . $provider . ")");
-      }
-      else {
-         Rex::Logger::info("OS not supported (" . $host->{"operatingsystem"} . ")");
-      }
-      die("OS/Provider not supported");
-   
-   }
-
-   return $class->new;
+  my ($self) = @_;
+
+  my %_host = %{ Rex::Hardware::Host->get() };
+  my $host = { %_host };
+
+  my $pkg_provider_for = Rex::Config->get("package_provider") || {};
+
+  #if(lc($host->{"operatingsystem"}) eq "centos" || lc($host->{"operatingsystem"}) eq "redhat") {
+  if(is_redhat()) {
+    $host->{"operatingsystem"} = "Redhat";
+  }
+
+  my $class = "Rex::Pkg::" . $host->{"operatingsystem"};
+
+  my $provider;
+  if(ref($pkg_provider_for) && exists $pkg_provider_for->{$host->{"operatingsystem"}}) {
+    $provider = $pkg_provider_for->{$host->{"operatingsystem"}};
+    $class .= "::$provider";
+  }
+  elsif(exists $PKG_PROVIDER{$pkg_provider_for}) {
+    $class = $PKG_PROVIDER{$pkg_provider_for};
+  }
+
+  Rex::Logger::debug("Using $class for package management");
+  eval "use $class";
+
+  if($@) {
+  
+    if($provider) {
+      Rex::Logger::info("Provider not supported (" . $provider . ")");
+    }
+    else {
+      Rex::Logger::info("OS not supported (" . $host->{"operatingsystem"} . ")");
+    }
+    die("OS/Provider not supported");
+  
+  }
+
+  return $class->new;
 
 }
 
@@ -1,79 +1,79 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Profiler;
-   
+  
 use strict;
 use warnings;
 
 use Time::HiRes qw(gettimeofday tv_interval);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{__data} = {};
+  $self->{__data} = {};
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my ($self, $info) = @_;
+  my ($self, $info) = @_;
 
-   push(@{ $self->{__data}->{$info} }, {
-      start => [gettimeofday]
-   });
+  push(@{ $self->{__data}->{$info} }, {
+    start => [gettimeofday]
+  });
 }
 
 sub end {
-   my ($self, $info) = @_;
+  my ($self, $info) = @_;
 
-   return unless($self->{__data}->{$info}->[-1]);
+  return unless($self->{__data}->{$info}->[-1]);
 
-   my $data = $self->{__data}->{$info}->[-1];
-   $data->{end} = [gettimeofday];
-   $data->{duration} = tv_interval($data->{start}, $data->{end});
+  my $data = $self->{__data}->{$info}->[-1];
+  $data->{end} = [gettimeofday];
+  $data->{duration} = tv_interval($data->{start}, $data->{end});
 
-   $self->{__data}->{$info}->[-1] = $data;
+  $self->{__data}->{$info}->[-1] = $data;
 }
 
 sub report {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   for my $info (keys %{ $self->{__data} }) {
-      print "# $info (count: " . scalar(@{ $self->{__data}->{$info} }) . ")\n";
-      print "   Timings:\n";
+  for my $info (keys %{ $self->{__data} }) {
+    print "# $info (count: " . scalar(@{ $self->{__data}->{$info} }) . ")\n";
+    print "  Timings:\n";
 
-      my ($max, $min, $avg, $all);
-      for my $entry (@{ $self->{__data}->{$info} }) {
-         if(! $max || $max < $entry->{duration}) {
-            $max = $entry->{duration};
-         }
-
-         if(! $min || $min > $entry->{duration}) {
-            $min = $entry->{duration};
-         }
+    my ($max, $min, $avg, $all);
+    for my $entry (@{ $self->{__data}->{$info} }) {
+      if(! $max || $max < $entry->{duration}) {
+        $max = $entry->{duration};
+      }
 
-         $all += $entry->{duration};
+      if(! $min || $min > $entry->{duration}) {
+        $min = $entry->{duration};
       }
 
-      $avg = $all / scalar(@{ $self->{__data}->{$info} });
+      $all += $entry->{duration};
+    }
 
-      print "      min: $min / max: $max / avg: $avg / all: $all\n";
-      print "   Overview:\n";
+    $avg = $all / scalar(@{ $self->{__data}->{$info} });
 
-      for my $entry (@{ $self->{__data}->{$info} }) {
-         print "      " . $entry->{duration} . "\n";
-      }
+    print "    min: $min / max: $max / avg: $avg / all: $all\n";
+    print "  Overview:\n";
+
+    for my $entry (@{ $self->{__data}->{$info} }) {
+      print "    " . $entry->{duration} . "\n";
+    }
 
-      print "--------------------------------------------------------------------------------\n";
-   }
+    print "--------------------------------------------------------------------------------\n";
+  }
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Report::Base;
-   
+  
 use strict;
 use warnings;
 
@@ -14,18 +14,18 @@ use Rex::Logger;
 use Time::HiRes qw(time);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub report {
-   my ($self, $msg) = @_;
-   return 1;
+  my ($self, $msg) = @_;
+  return 1;
 }
 
 sub register_reporting_hooks {}
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Report::YAML;
 
 use strict;
@@ -19,127 +19,127 @@ use base qw(Rex::Report::Base);
 our $REPORT_PATH = "./reports";
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{__reports__} = [];
+  $self->{__reports__} = [];
 
-   return $self;
+  return $self;
 }
 
 sub report {
-   my ($self, $msg) = @_;
-   push @{$self->{__reports__}}, $msg; 
+  my ($self, $msg) = @_;
+  push @{$self->{__reports__}}, $msg; 
 }
 
 sub write_report {
-   my ($self) = @_;
-
-   $REPORT_PATH = Rex::Commands::get('report_path') || "reports";
-
-   if(! -d $REPORT_PATH) {
-      mkdir $REPORT_PATH or die($! . ": $REPORT_PATH");
-   }
-
-   my $server_name = Rex::Commands::connection()->server;
-   if($server_name eq "<local>") {
-      $server_name = "_local_";
-   }
-   if(! -d $REPORT_PATH . "/" . $server_name) {
-      mkdir "$REPORT_PATH/$server_name";
-   }
-   open(my $fh, ">", "$REPORT_PATH/$server_name/" . time() . ".yml") or die($!);
-   print $fh Dump($self->{__reports__});
-   close($fh);
-
-   $self->{__reports__} = [];
+  my ($self) = @_;
+
+  $REPORT_PATH = Rex::Commands::get('report_path') || "reports";
+
+  if(! -d $REPORT_PATH) {
+    mkdir $REPORT_PATH or die($! . ": $REPORT_PATH");
+  }
+
+  my $server_name = Rex::Commands::connection()->server;
+  if($server_name eq "<local>") {
+    $server_name = "_local_";
+  }
+  if(! -d $REPORT_PATH . "/" . $server_name) {
+    mkdir "$REPORT_PATH/$server_name";
+  }
+  open(my $fh, ">", "$REPORT_PATH/$server_name/" . time() . ".yml") or die($!);
+  print $fh Dump($self->{__reports__});
+  close($fh);
+
+  $self->{__reports__} = [];
 }
 
 sub register_reporting_hooks {
-   my ($self) = @_;
-
-   my @modules = qw(File Fs Pkg Run Service Upload User Cron Download);
-
-   my @skip_functions = qw/
-      file_write file_append file_read extract cat template
-      can_run
-      is_dir is_file stat rm list_files ls readlink chdir cd is_readable is_writable is_writeable free df du glob
-      installed_packages is_installed update_package_db package_provider_for
-      service_provider_for
-      get_uid get_user user_list user_groups get_group get_gid
-   /;
-
-   for my $mod (@modules) {
-      my @exports = eval "\@Rex::Commands::${mod}::EXPORT";
-      for my $export (@exports) {
-         if(grep { $_ eq $export } @skip_functions) {
-            next;
-         }
-         no strict 'refs';
-         no warnings;
-         eval "use Rex::Commands::$mod;";
-         my $orig_sub = \&{ "Rex::Commands::${mod}::$export" };
-         *{"Rex::Commands::${mod}::$export"} = sub {
-            my $ret;
-            my $start_time = time;
-
-            eval {
-               $ret = $orig_sub->(@_);
-               if(ref $ret eq "HASH") {
-                  if(exists $ret->{skip} && $ret->{skip} == 1) {
-                     return 1;
-                  }
-                  $self->report({
-                        command    => $export,
-                        module     => "Rex::Commands::$mod",
-                        start_time => $start_time,
-                        end_time   => time,
-                        data       => [ @_ ],
-                        success    => 1,
-                        message    => "",
-                        %{ $ret },
-                  });
-               }
-               else {
-                  $self->report({
-                        command    => $export,
-                        module     => "Rex::Commands::$mod",
-                        start_time => $start_time,
-                        end_time   => time,
-                        data       => [ @_ ],
-                        success    => 1,
-                        changed    => 1,
-                        message    => "",
-                  });
-               }
-               1;
-            } or do {
-               $self->report({
-                     command    => $export,
-                     module     => "Rex::Commands::$mod",
-                     start_time => $start_time,
-                     end_time   => time,
-                     data       => [ @_ ],
-                     success    => 0,
-                     changed    => 0,
-                     message    => $@,
-               });
-               Rex::unset_modified_caller();
-
-               die($@);
-            };
-
-            if(ref $ret eq "HASH" && exists $ret->{ret}) {
-               # return the original return value
-               return $ret->{ret};
-            }
-            return $ret;
-         };
+  my ($self) = @_;
+
+  my @modules = qw(File Fs Pkg Run Service Upload User Cron Download);
+
+  my @skip_functions = qw/
+    file_write file_append file_read extract cat template
+    can_run
+    is_dir is_file stat rm list_files ls readlink chdir cd is_readable is_writable is_writeable free df du glob
+    installed_packages is_installed update_package_db package_provider_for
+    service_provider_for
+    get_uid get_user user_list user_groups get_group get_gid
+  /;
+
+  for my $mod (@modules) {
+    my @exports = eval "\@Rex::Commands::${mod}::EXPORT";
+    for my $export (@exports) {
+      if(grep { $_ eq $export } @skip_functions) {
+        next;
       }
-   }
+      no strict 'refs';
+      no warnings;
+      eval "use Rex::Commands::$mod;";
+      my $orig_sub = \&{ "Rex::Commands::${mod}::$export" };
+      *{"Rex::Commands::${mod}::$export"} = sub {
+        my $ret;
+        my $start_time = time;
+
+        eval {
+          $ret = $orig_sub->(@_);
+          if(ref $ret eq "HASH") {
+            if(exists $ret->{skip} && $ret->{skip} == 1) {
+              return 1;
+            }
+            $self->report({
+                command   => $export,
+                module    => "Rex::Commands::$mod",
+                start_time => $start_time,
+                end_time  => time,
+                data     => [ @_ ],
+                success   => 1,
+                message   => "",
+                %{ $ret },
+            });
+          }
+          else {
+            $self->report({
+                command   => $export,
+                module    => "Rex::Commands::$mod",
+                start_time => $start_time,
+                end_time  => time,
+                data     => [ @_ ],
+                success   => 1,
+                changed   => 1,
+                message   => "",
+            });
+          }
+          1;
+        } or do {
+          $self->report({
+              command   => $export,
+              module    => "Rex::Commands::$mod",
+              start_time => $start_time,
+              end_time  => time,
+              data     => [ @_ ],
+              success   => 0,
+              changed   => 0,
+              message   => $@,
+          });
+          Rex::unset_modified_caller();
+
+          die($@);
+        };
+
+        if(ref $ret eq "HASH" && exists $ret->{ret}) {
+          # return the original return value
+          return $ret->{ret};
+        }
+        return $ret;
+      };
+    }
+  }
 }
 
 
@@ -1,32 +1,32 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Report;
-   
+  
 use strict;
 use warnings;
 
 my $report;
 
 sub create {
-   my ($class, $type) = @_;
+  my ($class, $type) = @_;
 
-   if($report) { return $report; }
+  if($report) { return $report; }
 
-   $type ||= "Base";
+  $type ||= "Base";
 
-   my $c = "Rex::Report::$type";
-   eval "use $c";
+  my $c = "Rex::Report::$type";
+  eval "use $c";
 
-   if($@) {
-      die("No reporting class $type found.");
-   }
+  if($@) {
+    die("No reporting class $type found.");
+  }
 
-   $report = $c->new;
-   return $report;
+  $report = $c->new;
+  return $report;
 }
 
 sub destroy { $report = undef; }
@@ -6,63 +6,64 @@ use warnings;
 use Cwd qw(getcwd);
 use Rex::Commands::Fs;
 use Rex::Commands::Run;
+use File::Basename;
 
 use vars qw($CHECKOUT_COMMAND $CLONE_COMMAND);
 
-$CLONE_COMMAND    = "git clone %s %s";
+$CLONE_COMMAND   = "git clone %s %s";
 $CHECKOUT_COMMAND = "git checkout -b %s origin/%s";
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub checkout {
-   my ($self, $repo_info, $checkout_to, $checkout_opt) = @_;
-
-   if(! is_dir($checkout_to)) {
-      my $clone_cmd = sprintf($CLONE_COMMAND, $repo_info->{"url"}, $checkout_to);
-      Rex::Logger::debug("clone_cmd: $clone_cmd");
-
-      Rex::Logger::info("cloning " . $repo_info->{"url"} . " to " . ($checkout_to?$checkout_to:"."));
-      my $out = run "$clone_cmd";
-      unless($? == 0) {
-         Rex::Logger::info("Error cloning repository.", "warn");
-         Rex::Logger::info($out);
-         die("Error cloning repository.");
+  my ($self, $repo_info, $checkout_to, $checkout_opt) = @_;
+
+  if(! is_dir($checkout_to)) {
+    my $clone_cmd = sprintf($CLONE_COMMAND, $repo_info->{"url"}, $checkout_to);
+    Rex::Logger::debug("clone_cmd: $clone_cmd");
+
+    Rex::Logger::info("cloning " . $repo_info->{"url"} . " to " . ($checkout_to?$checkout_to:"."));
+    my $out = run "$clone_cmd", cwd => dirname($checkout_to);
+    unless($? == 0) {
+      Rex::Logger::info("Error cloning repository.", "warn");
+      Rex::Logger::info($out);
+      die("Error cloning repository.");
+    }
+
+    Rex::Logger::debug($out);
+
+    if(exists $checkout_opt->{"branch"}) {
+      unless($checkout_to) {
+        $checkout_to = [ split(/\//, $repo_info->{"url"}) ]->[-1];
+        $checkout_to =~ s/\.git$//;
       }
 
-      Rex::Logger::debug($out);
-
-      if(exists $checkout_opt->{"branch"}) {
-         unless($checkout_to) {
-            $checkout_to = [ split(/\//, $repo_info->{"url"}) ]->[-1];
-            $checkout_to =~ s/\.git$//;
-         }
-
-         my $checkout_cmd = sprintf($CHECKOUT_COMMAND, $checkout_opt->{"branch"}, $checkout_opt->{"branch"});
-         Rex::Logger::debug("checkout_cmd: $checkout_cmd");
+      my $checkout_cmd = sprintf($CHECKOUT_COMMAND, $checkout_opt->{"branch"}, $checkout_opt->{"branch"});
+      Rex::Logger::debug("checkout_cmd: $checkout_cmd");
 
-         Rex::Logger::info("switching to branch " . $checkout_opt->{"branch"});
+      Rex::Logger::info("switching to branch " . $checkout_opt->{"branch"});
 
 
-         $out = run "$checkout_cmd", cwd => $checkout_to;
-         Rex::Logger::debug($out);
-      }
-   }
-   elsif(is_dir("$checkout_to/.git")) {
-      my $branch = $checkout_opt->{"branch"} || "master";
-      run "git pull origin $branch", cwd => $checkout_to;
-   }
-   else {
-      Rex::Logger::info("Error checking out repository.", "warn");
-      die("Error checking out repository.");
-   }
+      $out = run "$checkout_cmd", cwd => $checkout_to;
+      Rex::Logger::debug($out);
+    }
+  }
+  elsif(is_dir("$checkout_to/.git")) {
+    my $branch = $checkout_opt->{"branch"} || "master";
+    run "git pull origin $branch", cwd => $checkout_to;
+  }
+  else {
+    Rex::Logger::info("Error checking out repository.", "warn");
+    die("Error checking out repository.");
+  }
 }
 
 1;
@@ -10,64 +10,64 @@ use Rex::Commands::Run;
 use vars qw($CHECKOUT_COMMAND);
 
 BEGIN {
-   my $version = qx{svn --version --quiet 2>/dev/null};
-   if($version) {
-      my @parts = split(/\./, $version);
-
-      if($parts[1] <= 5) {
-         $CHECKOUT_COMMAND = "svn --non-interactive %s checkout %s %s";
-      }
-      else {
-         $CHECKOUT_COMMAND = "svn --non-interactive --trust-server-cert %s checkout %s %s";
-      }
-   }
+  my $version = qx{svn --version --quiet 2>/dev/null};
+  if($version) {
+    my @parts = split(/\./, $version);
+
+    if($parts[1] <= 5) {
+      $CHECKOUT_COMMAND = "svn --non-interactive %s checkout %s %s";
+    }
+    else {
+      $CHECKOUT_COMMAND = "svn --non-interactive --trust-server-cert %s checkout %s %s";
+    }
+  }
 };
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub checkout {
-   my ($self, $repo_info, $checkout_to, $checkout_opt) = @_;
-
-   my $special_opts = "";
-
-   if(exists $repo_info->{"username"}) {
-      $special_opts = " --username  '" . $repo_info->{"username"} . "'";
-   }
-
-   if(exists $repo_info->{"password"}) {
-      $special_opts .= " --password  '" . $repo_info->{"password"} . "'";
-   }
-
-
-   my $checkout_cmd;
-
-   if(! is_dir($checkout_to)) {
-      $checkout_cmd = sprintf($CHECKOUT_COMMAND, $special_opts, $repo_info->{"url"}, $checkout_to);
-   }
-   elsif(is_dir("$checkout_to/.svn")) {
-      $checkout_cmd = "svn up $checkout_to";
-   }
-   else {
-      Rex::Logger::info("Error checking out repository.", "warn");
-      die("Error checking out repository.");
-   }
-   Rex::Logger::debug("checkout_cmd: $checkout_cmd");
-
-   Rex::Logger::info("cloning " . $repo_info->{"url"} . " to " . ($checkout_to?$checkout_to:"."));
-   my $out = run "$checkout_cmd";
-   unless($? == 0) {
-      Rex::Logger::info("Error checking out repository.", "warn");
-      Rex::Logger::info($out);
-      die("Error checking out repository.");
-   }
+  my ($self, $repo_info, $checkout_to, $checkout_opt) = @_;
+
+  my $special_opts = "";
+
+  if(exists $repo_info->{"username"}) {
+    $special_opts = " --username  '" . $repo_info->{"username"} . "'";
+  }
+
+  if(exists $repo_info->{"password"}) {
+    $special_opts .= " --password  '" . $repo_info->{"password"} . "'";
+  }
+
+
+  my $checkout_cmd;
+
+  if(! is_dir($checkout_to)) {
+    $checkout_cmd = sprintf($CHECKOUT_COMMAND, $special_opts, $repo_info->{"url"}, $checkout_to);
+  }
+  elsif(is_dir("$checkout_to/.svn")) {
+    $checkout_cmd = "svn up $checkout_to";
+  }
+  else {
+    Rex::Logger::info("Error checking out repository.", "warn");
+    die("Error checking out repository.");
+  }
+  Rex::Logger::debug("checkout_cmd: $checkout_cmd");
+
+  Rex::Logger::info("cloning " . $repo_info->{"url"} . " to " . ($checkout_to?$checkout_to:"."));
+  my $out = run "$checkout_cmd";
+  unless($? == 0) {
+    Rex::Logger::info("Error checking out repository.", "warn");
+    Rex::Logger::info($out);
+    die("Error checking out repository.");
+  }
 
 }
 
@@ -15,13 +15,13 @@ use Rex::Service::Redhat::systemd;
 use base qw(Rex::Service::Redhat::systemd);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -11,95 +11,95 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/service $service start >/dev/null";
+  i_run "/sbin/service $service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/service $service restart >/dev/null";
+  i_run "/sbin/service $service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/service $service stop >/dev/null";
+  i_run "/sbin/service $service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/service $service reload >/dev/null";
+  i_run "/sbin/service $service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/service $service status >/dev/null";
+  i_run "/sbin/service $service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "/sbin/chkconfig $service off";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "/sbin/chkconfig $service on";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "/sbin/chkconfig $service off";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "/sbin/chkconfig $service on";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/sbin/service $service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/sbin/service $service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Debian;
@@ -14,95 +14,95 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service start >/dev/null";
+  i_run "/etc/init.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service restart >/dev/null";
+  i_run "/etc/init.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service stop >/dev/null";
+  i_run "/etc/init.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service reload >/dev/null";
+  i_run "/etc/init.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service status >/dev/null";
+  i_run "/etc/init.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "update-rc.d -f $service remove";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "update-rc.d $service defaults";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "update-rc.d -f $service remove";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "update-rc.d $service defaults";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/init.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/init.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::FreeBSD;
@@ -15,95 +15,95 @@ use Rex::Commands::File;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service onestart >/dev/null";
+  i_run "/usr/local/etc/rc.d/$service onestart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service onerestart >/dev/null";
+  i_run "/usr/local/etc/rc.d/$service onerestart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service onestop >/dev/null";
+  i_run "/usr/local/etc/rc.d/$service onestop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service onereload >/dev/null";
+  i_run "/usr/local/etc/rc.d/$service onereload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service onestatus >/dev/null";
+  i_run "/usr/local/etc/rc.d/$service onestatus >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      delete_lines_matching "/etc/rc.conf", matching => qr/${service}_enable="YES"/;
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      append_if_no_such_line "/etc/rc.conf", "${service}_enable=\"YES\"\n";
-   }
-
-   return 1;
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    delete_lines_matching "/etc/rc.conf", matching => qr/${service}_enable="YES"/;
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    append_if_no_such_line "/etc/rc.conf", "${service}_enable=\"YES\"\n";
+  }
+
+  return 1;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/usr/local/etc/rc.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/usr/local/etc/rc.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -15,13 +15,13 @@ use Rex::Service::Redhat::systemd;
 use base qw(Rex::Service::Redhat::systemd);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Gentoo;
@@ -14,95 +14,95 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service start >/dev/null";
+  i_run "/etc/init.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service restart >/dev/null";
+  i_run "/etc/init.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service stop >/dev/null";
+  i_run "/etc/init.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service reload >/dev/null";
+  i_run "/etc/init.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service status >/dev/null";
+  i_run "/etc/init.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "rc-update del $service";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "rc-update add $service";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "rc-update del $service";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "rc-update add $service";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/init.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/init.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Mageia::systemd;
@@ -17,13 +17,13 @@ use Rex::Service::Redhat::systemd;
 use base qw(Rex::Service::Redhat::systemd);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Mageia;
@@ -14,95 +14,95 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service start >/dev/null";
+  i_run "/etc/rc.d/init.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service restart >/dev/null";
+  i_run "/etc/rc.d/init.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service stop >/dev/null";
+  i_run "/etc/rc.d/init.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service reload >/dev/null";
+  i_run "/etc/rc.d/init.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service status >/dev/null";
+  i_run "/etc/rc.d/init.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "chkconfig $service off";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "chkconfig $service on";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "chkconfig $service off";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "chkconfig $service on";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/rc.d/init.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/rc.d/init.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::NetBSD;
@@ -15,95 +15,95 @@ use Rex::Commands::File;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service onestart >/dev/null";
+  i_run "/etc/rc.d/$service onestart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service onerestart >/dev/null";
+  i_run "/etc/rc.d/$service onerestart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service onestop >/dev/null";
+  i_run "/etc/rc.d/$service onestop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service onereload >/dev/null";
+  i_run "/etc/rc.d/$service onereload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service onestatus >/dev/null";
+  i_run "/etc/rc.d/$service onestatus >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      delete_lines_matching "/etc/rc.conf", matching => qr/${service}=YES/;
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      append_if_no_such_line "/etc/rc.conf", "${service}=YES\n";
-   }
-
-   return 1;
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    delete_lines_matching "/etc/rc.conf", matching => qr/${service}=YES/;
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    append_if_no_such_line "/etc/rc.conf", "${service}=YES\n";
+  }
+
+  return 1;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/rc.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/rc.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::OpenBSD;
@@ -15,95 +15,95 @@ use Rex::Commands::File;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service start >/dev/null";
+  i_run "/etc/rc.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service restart >/dev/null";
+  i_run "/etc/rc.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service stop >/dev/null";
+  i_run "/etc/rc.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service reload >/dev/null";
+  i_run "/etc/rc.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service status >/dev/null";
+  i_run "/etc/rc.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      delete_lines_matching "/etc/rc.conf", matching => qr/rc_scripts="\${rc_scripts} ${service}"/;
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      append_if_no_such_line "/etc/rc.conf", "rc_scripts=\"\${rc_scripts} ${service}\"\n";
-   }
-
-   return 1;
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    delete_lines_matching "/etc/rc.conf", matching => qr/rc_scripts="\${rc_scripts} ${service}"/;
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    append_if_no_such_line "/etc/rc.conf", "rc_scripts=\"\${rc_scripts} ${service}\"\n";
+  }
+
+  return 1;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/rc.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/rc.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::OpenWrt;
@@ -17,40 +17,40 @@ use Rex::Service::Debian;
 use base qw(Rex::Service::Debian);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/sbin/start-stop-daemon -K -t -q -n $service";
+  i_run "/sbin/start-stop-daemon -K -t -q -n $service";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "/etc/init.d/$service disable";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "/etc/init.d/$service enable";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "/etc/init.d/$service disable";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "/etc/init.d/$service enable";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Redhat::systemd;
@@ -15,113 +15,113 @@ use Rex::Logger;
 use Rex::Commands::Fs;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
-   $service = _prepare_service_name($service);
+  my($self, $service) = @_;
+  $service = _prepare_service_name($service);
 
-   i_run "systemctl start $service >/dev/null";
+  i_run "systemctl start $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
-   $service = _prepare_service_name($service);
+  my($self, $service) = @_;
+  $service = _prepare_service_name($service);
 
-   i_run "systemctl restart $service >/dev/null";
+  i_run "systemctl restart $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
-   $service = _prepare_service_name($service);
+  my($self, $service) = @_;
+  $service = _prepare_service_name($service);
 
-   i_run "systemctl stop $service >/dev/null";
+  i_run "systemctl stop $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
-   $service = _prepare_service_name($service);
+  my($self, $service) = @_;
+  $service = _prepare_service_name($service);
 
-   i_run "systemctl reload $service >/dev/null";
+  i_run "systemctl reload $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
-   $service = _prepare_service_name($service);
+  my($self, $service) = @_;
+  $service = _prepare_service_name($service);
 
-   i_run "systemctl status $service >/dev/null";
+  i_run "systemctl status $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-   $service = _prepare_service_name($service);
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "systemctl disable $service";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "systemctl enable $service";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+  $service = _prepare_service_name($service);
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "systemctl disable $service";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "systemctl enable $service";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 # all systemd services must end with .service
 # so it will be appended if there is no "." in the name.
 sub _prepare_service_name {
-   my ($service) = @_;
+  my ($service) = @_;
 
-   unless($service =~ m/\./) {
-      $service .= ".service";
-   }
+  unless($service =~ m/\./) {
+    $service .= ".service";
+  }
 
-   return $service;
+  return $service;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "systemctl $action $service >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "systemctl $action $service >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Redhat;
@@ -14,97 +14,97 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service start >/dev/null";
+  i_run "/etc/rc.d/init.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   # sometimes we need to sleep a little bit... because
-   # the ssh channel gets closed too fast... i don't know why, yet.
-   i_run "/etc/rc.d/init.d/$service restart >/dev/null ; f=\$?; sleep .1 ; exit \$f";
+  # sometimes we need to sleep a little bit... because
+  # the ssh channel gets closed too fast... i don't know why, yet.
+  i_run "/etc/rc.d/init.d/$service restart >/dev/null ; f=\$?; sleep .1 ; exit \$f";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service stop >/dev/null";
+  i_run "/etc/rc.d/init.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service reload >/dev/null";
+  i_run "/etc/rc.d/init.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/init.d/$service status >/dev/null";
+  i_run "/etc/rc.d/init.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "chkconfig $service off";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "chkconfig $service on";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "chkconfig $service off";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "chkconfig $service on";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/rc.d/init.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/rc.d/init.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::SuSE::systemd;
@@ -17,13 +17,13 @@ use Rex::Service::Redhat::systemd;
 use base qw(Rex::Service::Redhat::systemd);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $proto->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $proto->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::SuSE;
@@ -14,95 +14,95 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service start >/dev/null";
+  i_run "/etc/rc.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service restart >/dev/null";
+  i_run "/etc/rc.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service stop >/dev/null";
+  i_run "/etc/rc.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service reload >/dev/null";
+  i_run "/etc/rc.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/rc.d/$service status >/dev/null";
+  i_run "/etc/rc.d/$service status >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "chkconfig $service off";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "chkconfig $service on";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "chkconfig $service off";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "chkconfig $service on";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/rc.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/rc.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::SunOS::svcadm;
@@ -15,93 +15,93 @@ use Rex::Logger;
 use Rex::Commands::Fs;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "svcadm enable $service >/dev/null";
+  i_run "svcadm enable $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "svcadm restart $service >/dev/null";
+  i_run "svcadm restart $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "svcadm disable $service >/dev/null";
+  i_run "svcadm disable $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "svcadm refresh $service >/dev/null";
+  i_run "svcadm refresh $service >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   my ($state) = grep { $_=$1 if /state\s+([a-z]+)/ } i_run "svcs -l $service";
+  my ($state) = grep { $_=$1 if /state\s+([a-z]+)/ } i_run "svcs -l $service";
 
-   if($state eq "online") {
-      return 1;
-   }
+  if($state eq "online") {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
+  my ($self, $service, $what) = @_;
 
-   if($what =~  /^stop/) {
-      $self->stop($service);
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-   }
+  if($what =~  /^stop/) {
+    $self->stop($service);
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+  }
 
-   return 1;
+  return 1;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "svcadm $action $service >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "svcadm $action $service >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::SunOS;
@@ -15,96 +15,96 @@ use Rex::Logger;
 use Rex::Commands::Fs;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service start >/dev/null";
+  i_run "/etc/init.d/$service start >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service restart >/dev/null";
+  i_run "/etc/init.d/$service restart >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service stop >/dev/null";
+  i_run "/etc/init.d/$service stop >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "/etc/init.d/$service reload >/dev/null";
+  i_run "/etc/init.d/$service reload >/dev/null";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   my $ret = i_run "/etc/init.d/$service status >/dev/null";
+  my $ret = i_run "/etc/init.d/$service status >/dev/null";
 
-   if($ret =~ m/online/) {
-      return 1;
-   }
+  if($ret =~ m/online/) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "rm /etc/rc*.d/S*$service";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      my ($runlevel) = grep { $_=$1 if m/run\-level (\d)/ } i_run "who -r";
-      ln "/etc/init.d/$service", "/etc/rc${runlevel}.d/S99$service";
-   }
-
-   return 1;
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "rm /etc/rc*.d/S*$service";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    my ($runlevel) = grep { $_=$1 if m/run\-level (\d)/ } i_run "who -r";
+    ln "/etc/init.d/$service", "/etc/rc${runlevel}.d/S99$service";
+  }
+
+  return 1;
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "/etc/init.d/$service $action >/dev/null";
-   if($? == 0) { return 1; }
+  i_run "/etc/init.d/$service $action >/dev/null";
+  if($? == 0) { return 1; }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service::Ubuntu;
@@ -14,100 +14,100 @@ use Rex::Helper::Run;
 use Rex::Logger;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub start {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "service $service start";
+  i_run "service $service start";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub restart {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "service $service restart";
+  i_run "service $service restart";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub stop {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "service $service stop";
+  i_run "service $service stop";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub reload {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   i_run "service $service reload";
+  i_run "service $service reload";
 
-   if($? == 0) {
-      return 1;
-   }
+  if($? == 0) {
+    return 1;
+  }
 
-   return 0;
+  return 0;
 }
 
 sub status {
-   my($self, $service) = @_;
+  my($self, $service) = @_;
 
-   my @ret = i_run "service $service status";
+  my @ret = i_run "service $service status";
 
-   # bad... really bad ...
-   if($? != 0) {
-      return 0;
-   }
+  # bad... really bad ...
+  if($? != 0) {
+    return 0;
+  }
 
-   if(grep { /NOT running|stop\// } @ret) {
-      return 0;
-   }
+  if(grep { /NOT running|stop\// } @ret) {
+    return 0;
+  }
 
-   return 1;
+  return 1;
 }
 
 sub ensure {
-   my ($self, $service, $what) = @_;
-
-   if($what =~  /^stop/) {
-      $self->stop($service);
-      i_run "update-rc.d -f $service remove";
-   }
-   elsif($what =~ /^start/ || $what =~ m/^run/) {
-      $self->start($service);
-      i_run "update-rc.d $service defaults";
-   }
-
-   if($? == 0) { return 1; } else { return 0; }
+  my ($self, $service, $what) = @_;
+
+  if($what =~  /^stop/) {
+    $self->stop($service);
+    i_run "update-rc.d -f $service remove";
+  }
+  elsif($what =~ /^start/ || $what =~ m/^run/) {
+    $self->start($service);
+    i_run "update-rc.d $service defaults";
+  }
+
+  if($? == 0) { return 1; } else { return 0; }
 }
 
 sub action {
-   my ($self, $service, $action) = @_;
+  my ($self, $service, $action) = @_;
 
-   i_run "service $service $action";
-   if($? == 0) { return 1; }
+  i_run "service $service $action";
+  if($? == 0) { return 1; }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Service;
@@ -18,55 +18,55 @@ use Rex::Logger;
 
 my %SERVICE_PROVIDER;
 sub register_service_provider {
-   my ($class, $service_name, $service_class) = @_;
-   $SERVICE_PROVIDER{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $SERVICE_PROVIDER{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub get {
 
-   my $operatingsystem = Rex::Hardware::Host->get_operating_system();
-   my $can_run_systemctl = can_run("systemctl");
-   my $class;
-
-   $class = "Rex::Service::" . $operatingsystem;
-   if(is_redhat($operatingsystem) && $can_run_systemctl) {
-      $class = "Rex::Service::Redhat::systemd";
-   } elsif (is_redhat($operatingsystem)) {
-      # this also counts for fedora, centos, ...
-      $class = "Rex::Service::Redhat";
-   } elsif(is_suse($operatingsystem) && $can_run_systemctl) {
-      $class = "Rex::Service::SuSE::systemd";
-   } elsif (is_alt($operatingsystem) && $can_run_systemctl) {
-      $class = "Rex::Service::ALT::systemd";
-   } elsif (is_gentoo($operatingsystem) && $can_run_systemctl) {
-      $class = "Rex::Service::Gentoo::systemd";
-   } elsif (is_mageia($operatingsystem) && $can_run_systemctl) {
-      $class = "Rex::Service::Mageia::systemd";
-   }
-
-   my $provider_for = Rex::Config->get("service_provider") || {};
-   my $provider;
-
-   if(ref($provider_for) && exists $provider_for->{$operatingsystem}) {
-      $provider = $provider_for->{$operatingsystem};
-      $class .= "::\L$provider";
-   }
-   elsif(exists $SERVICE_PROVIDER{$provider_for}) {
-      $class = $SERVICE_PROVIDER{$provider_for};
-   }
-
-   Rex::Logger::debug("service using class: $class");
-   eval "use $class";
-
-   if($@) {
-
-      Rex::Logger::info("OS ($operatingsystem) not supported");
-      exit 1;
-
-   }
-
-   return $class->new;
+  my $operatingsystem = Rex::Hardware::Host->get_operating_system();
+  my $can_run_systemctl = can_run("systemctl");
+  my $class;
+
+  $class = "Rex::Service::" . $operatingsystem;
+  if(is_redhat($operatingsystem) && $can_run_systemctl) {
+    $class = "Rex::Service::Redhat::systemd";
+  } elsif (is_redhat($operatingsystem)) {
+    # this also counts for fedora, centos, ...
+    $class = "Rex::Service::Redhat";
+  } elsif(is_suse($operatingsystem) && $can_run_systemctl) {
+    $class = "Rex::Service::SuSE::systemd";
+  } elsif (is_alt($operatingsystem) && $can_run_systemctl) {
+    $class = "Rex::Service::ALT::systemd";
+  } elsif (is_gentoo($operatingsystem) && $can_run_systemctl) {
+    $class = "Rex::Service::Gentoo::systemd";
+  } elsif (is_mageia($operatingsystem) && $can_run_systemctl) {
+    $class = "Rex::Service::Mageia::systemd";
+  }
+
+  my $provider_for = Rex::Config->get("service_provider") || {};
+  my $provider;
+
+  if(ref($provider_for) && exists $provider_for->{$operatingsystem}) {
+    $provider = $provider_for->{$operatingsystem};
+    $class .= "::\L$provider";
+  }
+  elsif(exists $SERVICE_PROVIDER{$provider_for}) {
+    $class = $SERVICE_PROVIDER{$provider_for};
+  }
+
+  Rex::Logger::debug("service using class: $class");
+  eval "use $class";
+
+  if($@) {
+
+    Rex::Logger::info("OS ($operatingsystem) not supported");
+    exit 1;
+
+  }
+
+  return $class->new;
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Shared::Var::Array;
-   
+  
 use strict;
 use warnings;
 
@@ -19,146 +19,146 @@ sub __retr;
 sub __store;
 
 sub TIEARRAY {
-   my $self = {
-      varname => $_[1],
-   };
+  my $self = {
+    varname => $_[1],
+  };
 
-   bless $self, $_[0];
+  bless $self, $_[0];
 
 }
 
 sub STORE {
-   my $self = shift;
-   my $index = shift;
-   my $value = shift;
+  my $self = shift;
+  my $index = shift;
+  my $value = shift;
 
 
-   return __lock {
-      my $ref = __retr;
-      my $ret = $ref->{$self->{varname}}->{data}->[$index] = $value;
-      __store $ref;
+  return __lock {
+    my $ref = __retr;
+    my $ret = $ref->{$self->{varname}}->{data}->[$index] = $value;
+    __store $ref;
 
-      return $ret;
-   };
+    return $ret;
+  };
 
 }
 
 sub FETCH {
-   my $self = shift;
-   my $index = shift;
+  my $self = shift;
+  my $index = shift;
 
-   return __lock {
-      my $ref = __retr;
-      my $ret = $ref->{$self->{varname}}->{data}->[$index];
+  return __lock {
+    my $ref = __retr;
+    my $ret = $ref->{$self->{varname}}->{data}->[$index];
 
-      return $ret;
-   };
+    return $ret;
+  };
 }
 
 sub CLEAR {
-   my $self = shift;
+  my $self = shift;
 
-   __lock {
-      my $ref = __retr;
-      $ref->{$self->{varname}} = { data => [] };
-      __store $ref;
-   };
+  __lock {
+    my $ref = __retr;
+    $ref->{$self->{varname}} = { data => [] };
+    __store $ref;
+  };
 
 }
 
 sub DELETE {
-   my $self = shift;
-   my $index = shift;
+  my $self = shift;
+  my $index = shift;
 
 
-   __lock {
-      my $ref = __retr;
-      delete $ref->{$self->{varname}}->{data}->[$index];
-      __store $ref;
-   };
+  __lock {
+    my $ref = __retr;
+    delete $ref->{$self->{varname}}->{data}->[$index];
+    __store $ref;
+  };
 
 }
 
 sub EXISTS {
-   my $self = shift;
-   my $index = shift;
+  my $self = shift;
+  my $index = shift;
 
-   return __lock {
-      my $ref = __retr;
-      return exists $ref->{$self->{varname}}->{data}->[$index];
-   };
+  return __lock {
+    my $ref = __retr;
+    return exists $ref->{$self->{varname}}->{data}->[$index];
+  };
 
 }
 
 sub PUSH {
-   my $self = shift;
-   my @data = @_;
+  my $self = shift;
+  my @data = @_;
 
-   __lock {
-      my $ref = __retr;
+  __lock {
+    my $ref = __retr;
 
-      if(! ref($ref->{$self->{varname}}->{data}) eq "ARRAY") {
-         $ref->{$self->{varname}}->{data} = [];
-      }
+    if(! ref($ref->{$self->{varname}}->{data}) eq "ARRAY") {
+      $ref->{$self->{varname}}->{data} = [];
+    }
 
-      push(@{ $ref->{$self->{varname}}->{data} }, @data);
+    push(@{ $ref->{$self->{varname}}->{data} }, @data);
 
-      __store $ref;
-   };
+    __store $ref;
+  };
 
 }
 
 sub EXTEND {
-   my $self = shift;
-   my $count = shift;
+  my $self = shift;
+  my $count = shift;
 }
 
 sub STORESIZE {
-   my $self = shift;
-   my $newsize = shift;
+  my $self = shift;
+  my $newsize = shift;
 }
 
 sub FETCHSIZE {
-   my $self = shift;
+  my $self = shift;
 
-   return __lock {
-      my $ref = __retr;
-      if(! exists $ref->{$self->{varname}}) {
-         return 0;
-      }
-      return scalar(@{ $ref->{$self->{varname}}->{data} });
-   };
+  return __lock {
+    my $ref = __retr;
+    if(! exists $ref->{$self->{varname}}) {
+      return 0;
+    }
+    return scalar(@{ $ref->{$self->{varname}}->{data} });
+  };
 
 }
 
 sub DESTROY {
-   my $self = shift;
+  my $self = shift;
 }
 
 sub __lock(&) {
 
-   sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
-   flock($dblock, LOCK_SH) or die($!);
+  sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
+  flock($dblock, LOCK_SH) or die($!);
 
-   my $ret = &{ $_[0] }();
+  my $ret = &{ $_[0] }();
 
-   close($dblock);
-   
-   return $ret;
+  close($dblock);
+  
+  return $ret;
 }
 
 sub __store {
-   my $ref = shift;
-   store($ref, "vars.db");
+  my $ref = shift;
+  store($ref, "vars.db");
 }
 
 sub __retr {
 
-   if(! -f "vars.db") {
-      return {};
-   }
+  if(! -f "vars.db") {
+    return {};
+  }
 
-   return retrieve("vars.db");
+  return retrieve("vars.db");
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Shared::Var::Hash;
-   
+  
 use strict;
 use warnings;
 
@@ -22,122 +22,122 @@ sub __store;
 
 
 sub TIEHASH {
-   my $self = {
-      varname => $_[1],
-   };
+  my $self = {
+    varname => $_[1],
+  };
 
-   bless $self, $_[0];
+  bless $self, $_[0];
 }
 
 sub STORE {
-   my $self = shift;
-   my $key = shift;
-   my $value = shift;
-
-   return __lock {
-      my $ref = __retr;
-      my $ret = $ref->{$self->{varname}}->{$key} = $value;
-      __store $ref;
-
-      return $ret;
-   };
-   
+  my $self = shift;
+  my $key = shift;
+  my $value = shift;
+
+  return __lock {
+    my $ref = __retr;
+    my $ret = $ref->{$self->{varname}}->{$key} = $value;
+    __store $ref;
+
+    return $ret;
+  };
+  
 }
 
 sub FETCH {
-   my $self = shift;
-   my $key = shift;
+  my $self = shift;
+  my $key = shift;
 
-   return __lock {
-      my $ref = __retr;
-      return $ref->{$self->{varname}}->{$key};
-   };
+  return __lock {
+    my $ref = __retr;
+    return $ref->{$self->{varname}}->{$key};
+  };
 
 }
 
 sub DELETE {
-   my $self = shift;
-   my $key = shift;
+  my $self = shift;
+  my $key = shift;
 
-   __lock {
-      my $ref = __retr;
-      delete $ref->{$self->{varname}}->{$key};
-      __store $ref;
-   };
+  __lock {
+    my $ref = __retr;
+    delete $ref->{$self->{varname}}->{$key};
+    __store $ref;
+  };
 
 }
 
 sub CLEAR {
-   my $self = shift;
+  my $self = shift;
 
-   __lock {
-      my $ref = __retr;
-      $ref->{$self->{varname}} = {};
-      __store $ref;
-   };
+  __lock {
+    my $ref = __retr;
+    $ref->{$self->{varname}} = {};
+    __store $ref;
+  };
 
 }
 
 sub EXISTS {
-   my $self = shift;
-   my $key = shift;
+  my $self = shift;
+  my $key = shift;
 
-   return __lock {
-      my $ref = __retr;
-      return exists $ref->{$self->{varname}}->{$key};
-   };
+  return __lock {
+    my $ref = __retr;
+    return exists $ref->{$self->{varname}}->{$key};
+  };
 
 }
 
 sub FIRSTKEY {
-   my $self = shift;
+  my $self = shift;
 
-   return __lock {
-      my $ref = __retr;
-      $self->{__iter__} = $ref->{$self->{varname}};
+  return __lock {
+    my $ref = __retr;
+    $self->{__iter__} = $ref->{$self->{varname}};
 
-      my $temp = keys %{ $self->{__iter__} };
-      return scalar each %{ $self->{__iter__} };
-   };
+    my $temp = keys %{ $self->{__iter__} };
+    return scalar each %{ $self->{__iter__} };
+  };
 
 }
 
 sub NEXTKEY {
-   my $self = shift;
-   my $prevkey = shift;
+  my $self = shift;
+  my $prevkey = shift;
 
-   return scalar each %{ $self->{__iter__} };
+  return scalar each %{ $self->{__iter__} };
 }
 
 sub DESTROY {
-   my $self = shift;
+  my $self = shift;
 }
 
 
 sub __lock(&) {
 
-   sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
-   flock($dblock, LOCK_SH) or die($!);
+  sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
+  flock($dblock, LOCK_SH) or die($!);
 
-   my $ret = &{ $_[0] }();
+  my $ret = &{ $_[0] }();
 
-   close($dblock);
-   
-   return $ret;
+  close($dblock);
+  
+  return $ret;
 }
 
 sub __store {
-   my $ref = shift;
-   store($ref, "vars.db");
+  my $ref = shift;
+  store($ref, "vars.db");
 }
 
 sub __retr {
 
-   if(! -f "vars.db") {
-      return {};
-   }
+  if(! -f "vars.db") {
+    return {};
+  }
 
-   return retrieve("vars.db");
+  return retrieve("vars.db");
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Shared::Var::Scalar;
-   
+  
 use strict;
 use warnings;
 
@@ -19,61 +19,61 @@ sub __retr;
 sub __store;
 
 sub TIESCALAR {
-   my $self = {
-      varname => $_[1],
-   };
-   bless $self, $_[0];
+  my $self = {
+    varname => $_[1],
+  };
+  bless $self, $_[0];
 }
 
 sub STORE {
-   my $self = shift;
-   my $value = shift;
+  my $self = shift;
+  my $value = shift;
 
-   return __lock {
-      my $ref = __retr;
-      my $ret = $ref->{$self->{varname}} = $value;
-      __store $ref;
+  return __lock {
+    my $ref = __retr;
+    my $ret = $ref->{$self->{varname}} = $value;
+    __store $ref;
 
-      return $ret;
-   };
+    return $ret;
+  };
 
 }
 
 sub FETCH {
-   my $self = shift;
+  my $self = shift;
 
-   return __lock {
-      my $ref = __retr;
-      return $ref->{$self->{varname}};
-   };
+  return __lock {
+    my $ref = __retr;
+    return $ref->{$self->{varname}};
+  };
 
 }
 
 sub __lock(&) {
 
-   sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
-   flock($dblock, LOCK_SH) or die($!);
+  sysopen(my $dblock, "vars.db.lock", O_RDONLY | O_CREAT) or die($!);
+  flock($dblock, LOCK_SH) or die($!);
 
-   my $ret = &{ $_[0] }();
+  my $ret = &{ $_[0] }();
 
-   close($dblock);
-   
-   return $ret;
+  close($dblock);
+  
+  return $ret;
 }
 
 sub __store {
-   my $ref = shift;
-   print Dumper($ref);
-   store($ref, "vars.db");
+  my $ref = shift;
+  print Dumper($ref);
+  store($ref, "vars.db");
 }
 
 sub __retr {
 
-   if(! -f "vars.db") {
-      return {};
-   }
+  if(! -f "vars.db") {
+    return {};
+  }
 
-   return retrieve("vars.db");
+  return retrieve("vars.db");
 
 }
 
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Shared::Var;
-   
+  
 use strict qw(vars subs);
 use warnings::register;
 
@@ -14,37 +14,37 @@ use base qw(Exporter);
 use vars qw(@EXPORT);
 
 use Data::Dumper;
-    
+   
 @EXPORT = qw(share);
 
 sub share {
-   my @vars = @_;
-   my ($package, $file, $line) = caller;
+  my @vars = @_;
+  my ($package, $file, $line) = caller;
 
-   my ($sigil, $sym);
-   for my $var (@vars) {
-      
-      if (($sigil, $sym) = ($var =~ /^([\$\@\%\*\&])(.+)/)) {
-         $sym = "${package}::$sym";
+  my ($sigil, $sym);
+  for my $var (@vars) {
+    
+    if (($sigil, $sym) = ($var =~ /^([\$\@\%\*\&])(.+)/)) {
+      $sym = "${package}::$sym";
 
-         if($sigil eq "\$") {
-            eval "use Rex::Shared::Var::Scalar;";
-            tie $$sym, "Rex::Shared::Var::Scalar", $sym;
-            *$sym = \$$sym;
-         }
-         elsif($sigil eq "\@") {
-            eval "use Rex::Shared::Var::Array;";
-            tie @$sym, "Rex::Shared::Var::Array", $sym;
-            *$sym = \@$sym;
-         }
-         elsif($sigil eq "\%") {
-            eval "use Rex::Shared::Var::Hash;";
-            tie %$sym, "Rex::Shared::Var::Hash", $sym;
-            *$sym = \%$sym;
-         } 
+      if($sigil eq "\$") {
+        eval "use Rex::Shared::Var::Scalar;";
+        tie $$sym, "Rex::Shared::Var::Scalar", $sym;
+        *$sym = \$$sym;
+      }
+      elsif($sigil eq "\@") {
+        eval "use Rex::Shared::Var::Array;";
+        tie @$sym, "Rex::Shared::Var::Array", $sym;
+        *$sym = \@$sym;
       }
+      elsif($sigil eq "\%") {
+        eval "use Rex::Shared::Var::Hash;";
+        tie %$sym, "Rex::Shared::Var::Hash", $sym;
+        *$sym = \%$sym;
+      } 
+    }
 
-   }
+  }
 }
 
 1;
@@ -1,14 +1,14 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 
 ###### DEPRECATED
-   
+  
 package Rex::Sudo::File;
-   
+  
 use strict;
 use warnings;
 
@@ -20,95 +20,95 @@ use Rex::Helper::Path;
 use IO::File;
 
 sub open {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = {};
-
-   $self->{mode} = shift;
-   $self->{file} = shift;
-   $self->{rndfile} = get_tmp_file;
-
-   if(my $sftp = Rex::get_sftp()) {
-      if($self->{mode} eq ">") {
-         $self->{fh} = $sftp->open($self->{rndfile}, O_WRONLY | O_CREAT | O_TRUNC );
-      }
-      elsif($self->{mode} eq ">>") {
-         cp($self->{file}, $self->{rndfile});
-         chmod(666, $self->{rndfile});
-         $self->{fh} = $sftp->open($self->{rndfile}, O_WRONLY | O_APPEND );
-         my %stat = stat $self->{rndfile};
-         $self->{fh}->seek($stat{size});
-      }
-      else {
-         cp($self->{file}, $self->{rndfile});
-         chmod(666, $self->{rndfile});
-         $self->{fh} = $sftp->open($self->{rndfile}, O_RDONLY);
-      }
-   }
-   else {
-      $self->{fh} = IO::File->new;
-      $self->{fh}->open($self->{mode} . " " . $self->{rndfile});
-   }
-
-   bless($self, $proto);
-
-   return $self;
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = {};
+
+  $self->{mode} = shift;
+  $self->{file} = shift;
+  $self->{rndfile} = get_tmp_file;
+
+  if(my $sftp = Rex::get_sftp()) {
+    if($self->{mode} eq ">") {
+      $self->{fh} = $sftp->open($self->{rndfile}, O_WRONLY | O_CREAT | O_TRUNC );
+    }
+    elsif($self->{mode} eq ">>") {
+      cp($self->{file}, $self->{rndfile});
+      chmod(666, $self->{rndfile});
+      $self->{fh} = $sftp->open($self->{rndfile}, O_WRONLY | O_APPEND );
+      my %stat = stat $self->{rndfile};
+      $self->{fh}->seek($stat{size});
+    }
+    else {
+      cp($self->{file}, $self->{rndfile});
+      chmod(666, $self->{rndfile});
+      $self->{fh} = $sftp->open($self->{rndfile}, O_RDONLY);
+    }
+  }
+  else {
+    $self->{fh} = IO::File->new;
+    $self->{fh}->open($self->{mode} . " " . $self->{rndfile});
+  }
+
+  bless($self, $proto);
+
+  return $self;
 }
 
 sub write {
-   my ($self, $content) = @_;
-
-   if(ref($self->{fh}) eq "Net::SSH2::File") {
-      $self->{fh}->write($content);
-   }
-   else {
-      $self->{fh}->print($content);
-   }
+  my ($self, $content) = @_;
+
+  if(ref($self->{fh}) eq "Net::SSH2::File") {
+    $self->{fh}->write($content);
+  }
+  else {
+    $self->{fh}->print($content);
+  }
 }
 
 sub seek {
-   my ($self, $offset) = @_;
-
-   if(ref($self->{fh}) eq "Net::SSH2::File") {
-      $self->{fh}->seek($offset);
-   }
-   else {
-      $self->{fh}->seek($offset, 0);
-   }
+  my ($self, $offset) = @_;
+
+  if(ref($self->{fh}) eq "Net::SSH2::File") {
+    $self->{fh}->seek($offset);
+  }
+  else {
+    $self->{fh}->seek($offset, 0);
+  }
 }
 
 sub read {
-   my ($self, $len) = @_;
-   $len ||= 64;
+  my ($self, $len) = @_;
+  $len ||= 64;
 
-   my $buf;
-   $self->{fh}->read($buf, $len);
+  my $buf;
+  $self->{fh}->read($buf, $len);
 
-   return $buf;
+  return $buf;
 }
 
 sub close {
-   my ($self) = @_;
-
-   return unless $self->{fh};
-
-   if(ref($self->{fh}) eq "Net::SSH2::File") {
-      $self->{fh} = undef;
-   }
-   else {
-      $self->{fh}->close;
-   }
-
-   # use cat to not overwrite attributes/owner/group
-   if($self->{mode} eq ">" || $self->{mode} eq ">>") {
-      run "cat " . $self->{rndfile} . " >" . $self->{file};
-      rm($self->{rndfile});
-   }
+  my ($self) = @_;
+
+  return unless $self->{fh};
+
+  if(ref($self->{fh}) eq "Net::SSH2::File") {
+    $self->{fh} = undef;
+  }
+  else {
+    $self->{fh}->close;
+  }
+
+  # use cat to not overwrite attributes/owner/group
+  if($self->{mode} eq ">" || $self->{mode} eq ">>") {
+    run "cat " . $self->{rndfile} . " >" . $self->{file};
+    rm($self->{rndfile});
+  }
 }
 
 sub DESTROY {
-   my ($self) = @_;
-   $self->close;
+  my ($self) = @_;
+  $self->close;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 =head1 NAME
 
@@ -14,7 +14,7 @@ The Task Object. Typically you only need this class if you want to manipulate ta
 =head1 SYNOPSIS
 
  use Rex::Task
-     
+ 
   my $task = Rex::Task->new(name => "testtask");
   $task->set_server("remoteserver");
   $task->set_code(sub { say "Hello"; });
@@ -41,6 +41,7 @@ use Rex::Hardware;
 use Rex::Interface::Cache;
 use Rex::Report;
 use Rex::Helper::Run;
+use Rex::Notify;
 
 require Rex::Commands;
 
@@ -50,50 +51,50 @@ require Rex::Args;
 
 This is the constructor.
 
-   $task = Rex::Task->new(
-      func => sub { some_code_here },
-      server => [ @server ],
-      desc => $description,
-      no_ssh => $no_ssh,
-      hidden => $hidden,
-      auth => {
-         user        => $user,
-         password    => $password,
-         private_key => $private_key,
-         public_key  => $public_key,
-      },
-      before => [sub {}, sub {}, ...],
-      after  => [sub {}, sub {}, ...],
-      around => [sub {}, sub {}, ...],
-      name => $task_name,
-      executor => Rex::Interface::Executor->create,
-   );
+  $task = Rex::Task->new(
+    func => sub { some_code_here },
+    server => [ @server ],
+    desc => $description,
+    no_ssh => $no_ssh,
+    hidden => $hidden,
+    auth => {
+      user      => $user,
+      password   => $password,
+      private_key => $private_key,
+      public_key  => $public_key,
+    },
+    before => [sub {}, sub {}, ...],
+    after  => [sub {}, sub {}, ...],
+    around => [sub {}, sub {}, ...],
+    name => $task_name,
+    executor => Rex::Interface::Executor->create,
+  );
 
 
 =cut
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   if(! exists $self->{name}) {
-      die("You have to define a task name.");
-   }
+  if(! exists $self->{name}) {
+    die("You have to define a task name.");
+  }
 
-   $self->{no_ssh} ||= 0;
-   $self->{func}   ||= sub {};
-   $self->{executor} ||= Rex::Interface::Executor->create;
+  $self->{no_ssh} ||= 0;
+  $self->{func}  ||= sub {};
+  $self->{executor} ||= Rex::Interface::Executor->create;
 
-   $self->{connection} = undef;
+  $self->{connection} = undef;
 
-   # set to true as default
-   if(! exists $self->{exit_on_connect_fail}) {
-      $self->{exit_on_connect_fail} = 1;
-   }
+  # set to true as default
+  if(! exists $self->{exit_on_connect_fail}) {
+    $self->{exit_on_connect_fail} = 1;
+  }
 
-   return $self;
+  return $self;
 }
 
 =item connection
@@ -102,13 +103,13 @@ Returns the current connection object.
 
 =cut
 sub connection {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   if(! exists $self->{connection} || ! $self->{connection}) {
-      $self->{connection} = Rex::Interface::Connection->create($self->get_connection_type);
-   }
+  if(! exists $self->{connection} || ! $self->{connection}) {
+    $self->{connection} = Rex::Interface::Connection->create($self->get_connection_type);
+  }
 
-   $self->{connection};
+  $self->{connection};
 }
 
 =item executor
@@ -117,9 +118,9 @@ Returns the current executor object.
 
 =cut
 sub executor {
-   my ($self) = @_;
-   $self->{executor}->set_task($self);
-   return $self->{executor};
+  my ($self) = @_;
+  $self->{executor}->set_task($self);
+  return $self->{executor};
 }
 
 =item hidden
@@ -128,8 +129,8 @@ Returns true if the task is hidden. (Should not be displayed on ,,rex -T''.)
 
 =cut
 sub hidden {
-   my ($self) = @_;
-   return $self->{hidden};
+  my ($self) = @_;
+  return $self->{hidden};
 }
 
 =item server
@@ -138,49 +139,49 @@ Returns the servers on which the task should be executed as an ArrayRef.
 
 =cut
 sub server {
-   my ($self) = @_;
-
-   my @server = @{ $self->{server} };
-   my @ret = ();
-
-   if(ref($server[-1]) eq "HASH") {
-      Rex::deprecated(undef, "0.40", "Defining extra credentials within the task creation is deprecated.",
-                                     "Please use set auth => task => 'taskname' instead.");
-
-      # use extra defined credentials
-      my $data = pop(@server);
-      $self->set_auth("user", $data->{'user'});
-      $self->set_auth("password", $data->{'password'});
-
-      if(exists $data->{"private_key"}) {
-         $self->set_auth("private_key", $data->{"private_key"});
-         $self->set_auth("public_key", $data->{"public_key"});
+  my ($self) = @_;
+
+  my @server = @{ $self->{server} };
+  my @ret = ();
+
+  if(ref($server[-1]) eq "HASH") {
+    Rex::deprecated(undef, "0.40", "Defining extra credentials within the task creation is deprecated.",
+                         "Please use set auth => task => 'taskname' instead.");
+
+    # use extra defined credentials
+    my $data = pop(@server);
+    $self->set_auth("user", $data->{'user'});
+    $self->set_auth("password", $data->{'password'});
+
+    if(exists $data->{"private_key"}) {
+      $self->set_auth("private_key", $data->{"private_key"});
+      $self->set_auth("public_key", $data->{"public_key"});
+    }
+  }
+
+  if(ref($self->{server}) eq "ARRAY" && scalar(@{ $self->{server} }) > 0) {
+    for my $srv (@{ $self->{server} }) {
+      if(ref($srv) eq "CODE") {
+        push(@ret, &$srv());
       }
-   }
-
-   if(ref($self->{server}) eq "ARRAY" && scalar(@{ $self->{server} }) > 0) {
-      for my $srv (@{ $self->{server} }) {
-         if(ref($srv) eq "CODE") {
-            push(@ret, &$srv());
-         }
-         else {
-            if(ref($srv) eq "Rex::Group::Entry::Server") {
-               push(@ret, $srv->get_servers);
-            }
-            else {
-               push(@ret, $srv);
-            }
-         }
+      else {
+        if(ref($srv) eq "Rex::Group::Entry::Server") {
+          push(@ret, $srv->get_servers);
+        }
+        else {
+          push(@ret, $srv);
+        }
       }
-   }
-   elsif(ref($self->{server}) eq "CODE") {
-      push(@ret, &{ $self->{server} }());
-   }
-   else {
-      push(@ret, Rex::Group::Entry::Server->new(name => "<local>"));
-   }
+    }
+  }
+  elsif(ref($self->{server}) eq "CODE") {
+    push(@ret, &{ $self->{server} }());
+  }
+  else {
+    push(@ret, Rex::Group::Entry::Server->new(name => "<local>"));
+  }
 
-   return [@ret];
+  return [@ret];
 }
 
 =item set_server(@server)
@@ -189,8 +190,8 @@ With this method you can set new servers on which the task should be executed on
 
 =cut
 sub set_server {
-   my ($self, @server) = @_;
-   $self->{server} = \@server;
+  my ($self, @server) = @_;
+  $self->{server} = \@server;
 }
 
 =item delete_server
@@ -199,10 +200,10 @@ Delete every server registered to the task.
 
 =cut
 sub delete_server {
-   my ($self) = @_;
-   delete $self->{current_server};
-   delete $self->{server};
-   $self->rethink_connection;
+  my ($self) = @_;
+  delete $self->{current_server};
+  delete $self->{server};
+  $self->rethink_connection;
 }
 
 =item current_server
@@ -211,8 +212,8 @@ Returns the current server on which the tasks gets executed right now.
 
 =cut
 sub current_server {
-   my ($self) = @_;
-   return $self->{current_server} || Rex::Group::Entry::Server->new(name => "<local>");
+  my ($self) = @_;
+  return $self->{current_server} || Rex::Group::Entry::Server->new(name => "<local>");
 }
 
 =item desc
@@ -221,8 +222,8 @@ Returns the description of a task.
 
 =cut
 sub desc {
-   my ($self) = @_;
-   return $self->{desc};
+  my ($self) = @_;
+  return $self->{desc};
 }
 
 =item set_desc($description)
@@ -231,8 +232,8 @@ Set the description of a task.
 
 =cut
 sub set_desc {
-   my ($self, $desc) = @_;
-   $self->{desc} = $desc;
+  my ($self, $desc) = @_;
+  $self->{desc} = $desc;
 }
 
 =item is_remote
@@ -241,18 +242,18 @@ Returns true (1) if the task will be executed remotely.
 
 =cut
 sub is_remote {
-   my ($self) = @_;
-   if(exists $self->{current_server}) {
-      if($self->{current_server} ne '<local>') {
-         return 1;
-      }
-   } else {
-      if(exists $self->{server} && scalar(@{ $self->{server} }) > 0) {
-         return 1;
-      }
-   }
+  my ($self) = @_;
+  if(exists $self->{current_server}) {
+    if($self->{current_server} ne '<local>') {
+      return 1;
+    }
+  } else {
+    if(exists $self->{server} && scalar(@{ $self->{server} }) > 0) {
+      return 1;
+    }
+  }
 
-   return 0;
+  return 0;
 }
 
 =item is_local
@@ -261,8 +262,8 @@ Returns true (1) if the task gets executed on the local host.
 
 =cut
 sub is_local {
-   my ($self) = @_;
-   return $self->is_remote() == 0 ? 1 : 0;
+  my ($self) = @_;
+  return $self->is_remote() == 0 ? 1 : 0;
 }
 
 =item is_http
@@ -272,18 +273,18 @@ Returns true (1) if the task gets executed over http protocol.
 =cut
 
 sub is_http {
-   my ($self) = @_;
-   return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "http");
+  my ($self) = @_;
+  return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "http");
 }
 
 sub is_https {
-   my ($self) = @_;
-   return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "https");
+  my ($self) = @_;
+  return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "https");
 }
 
 sub is_openssh {
-   my ($self) = @_;
-   return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "openssh");
+  my ($self) = @_;
+  return ($self->{"connection_type"} && lc($self->{"connection_type"}) eq "openssh");
 }
 
 =item want_connect
@@ -292,15 +293,15 @@ Returns true (1) if the task will establish a connection to a remote system.
 
 =cut
 sub want_connect {
-   my ($self) = @_;
-   return $self->{no_ssh} == 0 ? 1 : 0;
+  my ($self) = @_;
+  return $self->{no_ssh} == 0 ? 1 : 0;
 }
 
 =item get_connection_type
 
 This method tries to guess the right connection type for the task and returns it.
 
-Current return values are SSH, Fake and Local. 
+Current return values are SSH, Fake and Local.
 
 SSH - will create a ssh connection to the remote server
 
@@ -310,26 +311,26 @@ Fake - will not create any connections. But it populates the connection properti
 
 =cut
 sub get_connection_type {
-   my ($self) = @_;
-
-   if($self->is_http) {
-      return "HTTP";
-   }
-   elsif($self->is_https) {
-      return "HTTPS";
-   }
-   elsif($self->is_remote && $self->is_openssh && $self->want_connect) {
-      return "OpenSSH";
-   }
-   elsif($self->is_remote && $self->want_connect) {
-      return "SSH";
-   }
-   elsif($self->is_remote) {
-      return "Fake";
-   }
-   else {
-      return "Local";
-   }
+  my ($self) = @_;
+
+  if($self->is_http) {
+    return "HTTP";
+  }
+  elsif($self->is_https) {
+    return "HTTPS";
+  }
+  elsif($self->is_remote && $self->is_openssh && $self->want_connect) {
+    return "OpenSSH";
+  }
+  elsif($self->is_remote && $self->want_connect) {
+    return "SSH";
+  }
+  elsif($self->is_remote) {
+    return "Fake";
+  }
+  else {
+    return "Local";
+  }
 }
 
 =item modify($key, $value)
@@ -338,22 +339,22 @@ With this method you can modify values of the task.
 
 =cut
 sub modify {
-   my ($self, $key, $value) = @_;
+  my ($self, $key, $value) = @_;
 
-   if(ref($self->{$key}) eq "ARRAY") {
-      push(@{ $self->{$key} }, $value);
-   }
-   else {
-      $self->{$key} = $value;
-   }
+  if(ref($self->{$key}) eq "ARRAY") {
+    push(@{ $self->{$key} }, $value);
+  }
+  else {
+    $self->{$key} = $value;
+  }
 
-   $self->rethink_connection;
+  $self->rethink_connection;
 }
 
 sub rethink_connection {
-   my($self) = @_;
-   delete $self->{connection};
-   $self->connection;
+  my($self) = @_;
+  delete $self->{connection};
+  $self->connection;
 }
 
 =item user
@@ -362,10 +363,10 @@ Returns the current user the task will use.
 
 =cut
 sub user {
-   my ($self) = @_;
-   if(exists $self->{auth} && $self->{auth}->{user}) {
-      return $self->{auth}->{user};
-   }
+  my ($self) = @_;
+  if(exists $self->{auth} && $self->{auth}->{user}) {
+    return $self->{auth}->{user};
+  }
 }
 
 =item set_user($user)
@@ -374,8 +375,8 @@ Set the user of a task.
 
 =cut
 sub set_user {
-   my ($self, $user) = @_;
-   $self->{auth}->{user} = $user;
+  my ($self, $user) = @_;
+  $self->{auth}->{user} = $user;
 }
 
 =item password
@@ -384,10 +385,10 @@ Returns the password that will be used.
 
 =cut
 sub password {
-   my ($self) = @_;
-   if(exists $self->{auth} && $self->{auth}->{password}) {
-      return $self->{auth}->{password};
-   }
+  my ($self) = @_;
+  if(exists $self->{auth} && $self->{auth}->{password}) {
+    return $self->{auth}->{password};
+  }
 }
 
 =item set_password($password)
@@ -396,8 +397,8 @@ Set the password of the task.
 
 =cut
 sub set_password {
-   my ($self, $password) = @_;
-   $self->{auth}->{password} = $password;
+  my ($self, $password) = @_;
+  $self->{auth}->{password} = $password;
 }
 
 =item name
@@ -406,8 +407,8 @@ Returns the name of the task.
 
 =cut
 sub name {
-   my ($self) = @_;
-   return $self->{name};
+  my ($self) = @_;
+  return $self->{name};
 }
 
 =item code
@@ -416,8 +417,8 @@ Returns the code of the task.
 
 =cut
 sub code {
-   my ($self) = @_;
-   return $self->{func};
+  my ($self) = @_;
+  return $self->{func};
 }
 
 =item set_code(\&code_ref)
@@ -426,8 +427,8 @@ Set the code of the task.
 
 =cut
 sub set_code {
-   my ($self, $code) = @_;
-   $self->{func} = $code;
+  my ($self, $code) = @_;
+  $self->{func} = $code;
 }
 
 =item run_hook($server, $hook)
@@ -436,20 +437,20 @@ This method is used internally to execute the specified hooks.
 
 =cut
 sub run_hook {
-   my ($self, $server, $hook) = @_;
-
-   for my $code (@{ $self->{$hook} }) {
-      if($hook eq "after") { # special case for after hooks
-         &$code($$server, ($self->{"__was_authenticated"} ? undef : 1), { Rex::Args->get });
-      }
-      else {
-         my $old_server = $$server if $server;
-         &$code($$server, $server, { Rex::Args->get });
-         if($old_server && $old_server ne $$server) {
-            $self->{current_server} = $$server;
-         }
+  my ($self, $server, $hook) = @_;
+
+  for my $code (@{ $self->{$hook} }) {
+    if($hook eq "after") { # special case for after hooks
+      &$code($$server, ($self->{"__was_authenticated"} ? undef : 1), { Rex::Args->get });
+    }
+    else {
+      my $old_server = $$server if $server;
+      &$code($$server, $server, { Rex::Args->get });
+      if($old_server && $old_server ne $$server) {
+        $self->{current_server} = $$server;
       }
-   }
+    }
+  }
 }
 
 =item set_auth($key, $value)
@@ -461,15 +462,15 @@ Set the authentication of the task.
 
 =cut
 sub set_auth {
-   my ($self, $key, $value) = @_;
+  my ($self, $key, $value) = @_;
 
-   if(scalar(@_) > 3) {
-      my $_d = shift;
-      $self->{auth} = { @_ };
-   }
-   else {
-      $self->{auth}->{$key} = $value;
-   }
+  if(scalar(@_) > 3) {
+    my $_d = shift;
+    $self->{auth} = { @_ };
+  }
+  else {
+    $self->{auth}->{$key} = $value;
+  }
 }
 
 =item merge_auth($server)
@@ -479,22 +480,22 @@ Tasks authentication information have precedence.
 
 =cut
 sub merge_auth {
-   my ($self, $server) = @_;
+  my ($self, $server) = @_;
 
-   # merge auth hashs
-   # task auth as precedence
-   my %auth = $server->merge_auth($self->{auth});
+  # merge auth hashs
+  # task auth as precedence
+  my %auth = $server->merge_auth($self->{auth});
 
-   return \%auth;
+  return \%auth;
 }
 
 sub get_sudo_password {
-   my ($self) = @_;
+  my ($self) = @_;
 
-   my $server = $self->connection->server;
-   my %auth = $server->merge_auth($self->{auth});
+  my $server = $self->connection->server;
+  my %auth = $server->merge_auth($self->{auth});
 
-   return $auth{sudo_password};
+  return $auth{sudo_password};
 }
 
 =item parallelism
@@ -503,8 +504,8 @@ Get the parallelism count of a task.
 
 =cut
 sub parallelism {
-   my ($self) = @_;
-   return $self->{parallelism};
+  my ($self) = @_;
+  return $self->{parallelism};
 }
 
 
@@ -514,8 +515,8 @@ Set the parallelism of the task.
 
 =cut
 sub set_parallelism {
-   my ($self, $para) = @_;
-   $self->{parallelism} = $para;
+  my ($self, $para) = @_;
+  $self->{parallelism} = $para;
 }
 
 =item connect($server)
@@ -524,57 +525,60 @@ Initiate the connection to $server.
 
 =cut
 sub connect {
-   my ($self, $server) = @_;
+  my ($self, $server) = @_;
 
-   if(ref($server) ne "Rex::Group::Entry::Server") {
-      $server = Rex::Group::Entry::Server->new(name => $server);
-   }
-   $self->{current_server} = $server;
+  if(ref($server) ne "Rex::Group::Entry::Server") {
+    $server = Rex::Group::Entry::Server->new(name => $server);
+  }
+  $self->{current_server} = $server;
+
+  my $user = $self->user;
+  my $password = $self->password;
+  my $public_key = "";
+  my $private_key = "";
 
-   my $user = $self->user;
-   my $password = $self->password;
-   my $public_key = "";
-   my $private_key = "";
+  #print Dumper($self);
+  my $auth = $self->merge_auth($server);
 
-   #print Dumper($self);
-   my $auth = $self->merge_auth($server);
+  my $rex_int_conf = Rex::Commands::get("rex_internals");
+  Rex::Logger::debug(Dumper($rex_int_conf));
+  Rex::Logger::debug(Dumper($auth));
 
-   my $rex_int_conf = Rex::Commands::get("rex_internals");
-   Rex::Logger::debug(Dumper($rex_int_conf));
-   Rex::Logger::debug(Dumper($auth));
+  my $profiler = Rex::Profiler->new;
 
-   my $profiler = Rex::Profiler->new;
+  # task specific auth rules over all
+  my %connect_hash = %{ $auth };
+  $connect_hash{server} = $server;
 
-   # task specific auth rules over all
-   my %connect_hash = %{ $auth };
-   $connect_hash{server} = $server;
+  # need to get rid of this
+  Rex::push_connection({
+      conn  => $self->connection,
+      ssh   => $self->connection->get_connection_object,
+      server => $server,
+      cache => Rex::Interface::Cache->create(),
+      task  => $self,
+      profiler => $profiler,
+      reporter => Rex::Report->create(Rex::Config->get_report_type),
+      notify  => Rex::Notify->new(),
+  });
 
-   $profiler->start("connect");
-      $self->connection->connect(%connect_hash);
-   $profiler->end("connect");
+  $profiler->start("connect");
+    $self->connection->connect(%connect_hash);
+  $profiler->end("connect");
 
-   if($self->connection->is_authenticated) {
-      Rex::Logger::info("Successfully authenticated on $server.") if($self->connection->get_connection_type ne "Local");
-      $self->{"__was_authenticated"} = 1;
-   }
-   else {
-      die("Wrong username/password or wrong key on $server.");
-   }
+  if($self->connection->is_authenticated) {
+    Rex::Logger::info("Successfully authenticated on $server.") if($self->connection->get_connection_type ne "Local");
+    $self->{"__was_authenticated"} = 1;
+  }
+  else {
+    Rex::pop_connection();
+    die("Wrong username/password or wrong key on $server.");
+  }
 
-   # need to get rid of this
-   Rex::push_connection({
-         conn   => $self->connection, 
-         ssh    => $self->connection->get_connection_object, 
-         server => $server, 
-         cache => Rex::Interface::Cache->create(),
-         task  => $self,
-         profiler => $profiler,
-         reporter => Rex::Report->create(Rex::Config->get_report_type),
-   });
 
-   Rex::get_current_connection()->{reporter}->register_reporting_hooks;
+  Rex::get_current_connection()->{reporter}->register_reporting_hooks;
 
-   $self->run_hook(\$server, "around");
+  $self->run_hook(\$server, "around");
 
 }
 
@@ -584,40 +588,40 @@ Disconnect from the current connection.
 
 =cut
 sub disconnect {
-   my ($self, $server) = @_;
+  my ($self, $server) = @_;
 
-   $self->run_hook(\$server, "around");
-   $self->connection->disconnect;
+  $self->run_hook(\$server, "around");
+  $self->connection->disconnect;
 
-   my %args = Rex::Args->getopts;
+  my %args = Rex::Args->getopts;
 
-   if(defined $args{'d'} && $args{'d'} > 2) {
-      Rex::Commands::profiler()->report;
-   }
+  if(defined $args{'d'} && $args{'d'} > 2) {
+    Rex::Commands::profiler()->report;
+  }
 
-   delete $self->{connection};
+  delete $self->{connection};
 
-   # need to get rid of this
-   Rex::pop_connection();
+  # need to get rid of this
+  Rex::pop_connection();
 }
 
 sub get_data {
-   my ($self) = @_;
-
-   return {
-      func => $self->{func},
-      server => $self->{server},
-      desc => $self->{desc},
-      no_ssh => $self->{no_ssh},
-      hidden => $self->{hidden},
-      auth => $self->{auth},
-      before => $self->{before},
-      after  => $self->{after},
-      around => $self->{around},
-      name => $self->{name},
-      executor => $self->{executor},
-      connection_type => $self->{connection_type},
-   };
+  my ($self) = @_;
+
+  return {
+    func => $self->{func},
+    server => $self->{server},
+    desc => $self->{desc},
+    no_ssh => $self->{no_ssh},
+    hidden => $self->{hidden},
+    auth => $self->{auth},
+    before => $self->{before},
+    after  => $self->{after},
+    around => $self->{around},
+    name => $self->{name},
+    executor => $self->{executor},
+    connection_type => $self->{connection_type},
+  };
 }
 
 #####################################
@@ -631,125 +635,127 @@ Run the task on $server.
 
 =cut
 sub run {
-   # someone used this function directly... bail out
+  # someone used this function directly... bail out
 
 
-   if(ref($_[0])) {
-      my ($self, $server, %options) = @_;
+  if(ref($_[0])) {
+    my ($self, $server, %options) = @_;
 
-      if(ref($server) ne "Rex::Group::Entry::Server") {
-         $server = Rex::Group::Entry::Server->new(name => $server);
-      }
+    if(ref($server) ne "Rex::Group::Entry::Server") {
+      $server = Rex::Group::Entry::Server->new(name => $server);
+    }
 
-      if(! $_[1]) {
-         # run is called without any server.
-         # so just connect to any servers.
-         return Rex::TaskList->create()->run($self->name, %options);
-      }
+    if(! $_[1]) {
+      # run is called without any server.
+      # so just connect to any servers.
+      return Rex::TaskList->create()->run($self->name, %options);
+    }
 
-      # this is a method call
-      # so run the task
+    # this is a method call
+    # so run the task
 
-      my $in_transaction = $options{in_transaction};
+    my $in_transaction = $options{in_transaction};
 
-      $self->run_hook(\$server, "before");
-      $self->connect($server);
+    $self->run_hook(\$server, "before");
+    $self->connect($server);
 
-      my $reporter = Rex::get_current_connection()->{reporter};
-      my $start_time = time;
+    my $reporter = Rex::get_current_connection()->{reporter};
+    my $start_time = time;
 
-      if(Rex::Args->is_opt("c")) {
-         # get and cache all os info
-         if(! Rex::get_cache()->load()) {
-            Rex::Logger::debug("No cache found, need to collect new data.");
-            $server->gather_information;
-         }
+    if(Rex::Args->is_opt("c")) {
+      # get and cache all os info
+      if(! Rex::get_cache()->load()) {
+        Rex::Logger::debug("No cache found, need to collect new data.");
+        $server->gather_information;
       }
+    }
+
+    if(! $server->test_perl) {
+      Rex::Logger::info("There is no perl interpreter found on this system. Some commands may not work. Sudo won't work.", "warn");
+      sleep 3;
+    }
+
+    # execute code
+    my $ret;
+
+    eval {
+      $ret = $self->executor->exec($options{params});
+      my $notify = Rex::get_current_connection()->{notify};
+      $notify->run_postponed();
+    } or do {
+      if($@) {
+        my $error = $@;
+
+        $reporter->report({
+            command   => "run_task",
+            module    => "Rex::TaskList::Base",
+            start_time => $start_time,
+            end_time  => time,
+            success   => 0,
+          }) if ($reporter);
 
-      if(! $server->test_perl) {
-         Rex::Logger::info("There is no perl interpreter found on this system. Some commands may not work. Sudo won't work.", "warn");
-         sleep 3;
-      }
-
-      # execute code
-      my $ret;
-
-      eval {
-         $ret = $self->executor->exec($options{params});
-      } or do {
-         if($@) {
-            my $error = $@;
-
-            $reporter->report({
-                  command    => "run_task",
-                  module     => "Rex::TaskList::Base",
-                  start_time => $start_time,
-                  end_time   => time,
-                  success    => 0,
-               }) if ($reporter);
-
-            $reporter->write_report if ($reporter);
-
-            die($error);
-         }
-      };
+        $reporter->write_report if ($reporter);
 
-      if(Rex::Args->is_opt("c")) {
-         # get and cache all os info
-         Rex::get_cache()->save();
+        die($error);
       }
+    };
 
-      $reporter->report({
-            command    => "run_task",
-            module     => "Rex::TaskList::Base",
-            start_time => $start_time,
-            end_time   => time,
-            success    => 1,
-         }) if ($reporter);
+    if(Rex::Args->is_opt("c")) {
+      # get and cache all os info
+      Rex::get_cache()->save();
+    }
 
-      $reporter->write_report if ($reporter);
+    $reporter->report({
+        command   => "run_task",
+        module    => "Rex::TaskList::Base",
+        start_time => $start_time,
+        end_time  => time,
+        success   => 1,
+      }) if ($reporter);
 
-      $self->disconnect($server) unless($in_transaction);
-      $self->run_hook(\$server, "after");
+    $reporter->write_report if ($reporter);
 
-      return $ret;
-   }
+    $self->disconnect($server) unless($in_transaction);
+    $self->run_hook(\$server, "after");
 
-   else {
-      my ($class, $task, $server_overwrite, $params) = @_;
-      Rex::deprecated("Rex::Task->run()", "0.40");
+    return $ret;
+  }
 
-      if($server_overwrite) {
-         Rex::TaskList->create()->get_task($task)->set_server($server_overwrite);
-      }
+  else {
+    my ($class, $task, $server_overwrite, $params) = @_;
+    Rex::deprecated("Rex::Task->run()", "0.40");
+
+    if($server_overwrite) {
+      Rex::TaskList->create()->get_task($task)->set_server($server_overwrite);
+    }
 
-      # this is a deprecated static call
-      Rex::TaskList->create()->run($task, params => $params);
-   }
+    # this is a deprecated static call
+    Rex::TaskList->create()->run($task, params => $params);
+  }
 }
 
 sub modify_task {
-   my $class = shift;
-   my $task  = shift;
-   my $key   = shift;
-   my $value = shift;
+  my $class = shift;
+  my $task  = shift;
+  my $key  = shift;
+  my $value = shift;
 
-   Rex::TaskList->create()->get_task($task)->modify($key => $value);
+  Rex::TaskList->create()->get_task($task)->modify($key => $value);
 }
 
 sub is_task {
-   my ($class, $task) = @_;
-   return Rex::TaskList->create()->is_task($task);
+  my ($class, $task) = @_;
+  return Rex::TaskList->create()->is_task($task);
 }
 
 sub get_tasks {
-   my ($class, @tmp) = @_;
-   return Rex::TaskList->create()->get_tasks(@tmp);
+  my ($class, @tmp) = @_;
+  return Rex::TaskList->create()->get_tasks(@tmp);
 }
 
 sub get_desc {
-   my ($class, @tmp) = @_;
-   return Rex::TaskList->create()->get_desc(@tmp);
+  my ($class, @tmp) = @_;
+  return Rex::TaskList->create()->get_desc(@tmp);
 }
 
 =item exit_on_connect_fail()
@@ -758,13 +764,13 @@ Returns true if rex should exit on connect failure.
 
 =cut
 sub exit_on_connect_fail {
-   my ($self) = @_;
-   return $self->{exit_on_connect_fail};
+  my ($self) = @_;
+  return $self->{exit_on_connect_fail};
 }
 
 sub set_exit_on_connect_fail {
-   my ($self, $exit) = @_;
-   $self->{exit_on_connect_fail} = $exit;
+  my ($self, $exit) = @_;
+  $self->{exit_on_connect_fail} = $exit;
 }
 
 =back
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::TaskList::Base;
-   
+  
 use strict;
 use warnings;
 
@@ -19,260 +19,260 @@ use Rex::Report;
 use Time::HiRes qw(time);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   $self->{IN_TRANSACTION} = 0;
-   $self->{DEFAULT_AUTH} = 1;
-   $self->{tasks} = {};
+  $self->{IN_TRANSACTION} = 0;
+  $self->{DEFAULT_AUTH} = 1;
+  $self->{tasks} = {};
 
-   return $self;
+  return $self;
 }
 
 sub create_task {
-   my $self     = shift;
-   my $task_name = shift;
-   my $options   = pop;
-   my $desc      = pop;
-
-   if(exists $self->{tasks}->{$task_name}) {
-      Rex::Logger::info("Task $task_name already exists. Overwriting...", "warn");
-   }
-
-   Rex::Logger::debug("Creating task: $task_name");
-
-   my $func;
-   if(ref($desc) eq "CODE") {
-      $func = $desc;
-      $desc = "";
-   } else {
-      $func = pop;
-   }
-
-   my @server = ();
-
-   if($::FORCE_SERVER) {
-
-      if($::FORCE_SERVER =~ m/^\0/) {
-         push(@server, map { Rex::Group::Entry::Server->new(name => $_); } Rex::Group->get_group(substr($::FORCE_SERVER, 1)));
+  my $self    = shift;
+  my $task_name = shift;
+  my $options  = pop;
+  my $desc    = pop;
+
+  if(exists $self->{tasks}->{$task_name}) {
+    Rex::Logger::info("Task $task_name already exists. Overwriting...", "warn");
+  }
+
+  Rex::Logger::debug("Creating task: $task_name");
+
+  my $func;
+  if(ref($desc) eq "CODE") {
+    $func = $desc;
+    $desc = "";
+  } else {
+    $func = pop;
+  }
+
+  my @server = ();
+
+  if($::FORCE_SERVER) {
+
+    if($::FORCE_SERVER =~ m/^\0/) {
+      push(@server, map { Rex::Group::Entry::Server->new(name => $_); } Rex::Group->get_group(substr($::FORCE_SERVER, 1)));
+    }
+    else {
+      my @servers = split(/\s+/, $::FORCE_SERVER);
+      push(@server, map { Rex::Group::Entry::Server->new(name => $_); } @servers);
+
+      Rex::Logger::debug("\tserver: $_") for @server;
+    }
+
+  }
+
+  else {
+
+    if(scalar(@_) >= 1) {
+      if($_[0] eq "group") {
+        my $groups;
+        if(ref($_[1]) eq "ARRAY") {
+          $groups = $_[1];
+        }
+        else {
+          $groups = [ $_[1] ];
+        }
+   
+        for my $group (@{$groups}) {
+          if(Rex::Group->is_group($group)) {
+            my @group_server = Rex::Group->get_group($group);
+            # check if the group is empty. this is mostly due to a failure.
+            # so report it, and exit.
+            if(scalar @group_server == 0 && Rex::Config->get_allow_empty_groups() == 0) {
+              Rex::Logger::info("The group $group is empty. This is mostly due to a failure.", "warn");
+              Rex::Logger::info("If this is an expected behaviour, please add the feature flag 'empty_groups'.", "warn");
+              CORE::exit(1);
+            }
+            push(@server, @group_server);
+          }
+        }
       }
       else {
-         my @servers = split(/\s+/, $::FORCE_SERVER);
-         push(@server, map { Rex::Group::Entry::Server->new(name => $_); } @servers);
-
-         Rex::Logger::debug("\tserver: $_") for @server;
-      }
-
-   }
-
-   else {
-
-      if(scalar(@_) >= 1) {
-         if($_[0] eq "group") {
-            my $groups;
-            if(ref($_[1]) eq "ARRAY") {
-               $groups = $_[1];
-            }
-            else {
-               $groups = [ $_[1] ];
-            }
-    
-            for my $group (@{$groups}) {
-               if(Rex::Group->is_group($group)) {
-                  my @group_server = Rex::Group->get_group($group);
-                  # check if the group is empty. this is mostly due to a failure.
-                  # so report it, and exit.
-                  if(scalar @group_server == 0 && Rex::Config->get_allow_empty_groups() == 0) {
-                     Rex::Logger::info("The group $group is empty. This is mostly due to a failure.", "warn");
-                     Rex::Logger::info("If this is an expected behaviour, please add the feature flag 'empty_groups'.", "warn");
-                     CORE::exit(1);
-                  }
-                  push(@server, @group_server);
-               }
-            }
-         }
-         else {
-            for my $entry (@_) {
-               push(@server, (ref($entry) eq "Rex::Group::Entry" ? $entry : Rex::Group::Entry::Server->new(name => $entry)));
-            }
-         }
+        for my $entry (@_) {
+          push(@server, (ref($entry) eq "Rex::Group::Entry" ? $entry : Rex::Group::Entry::Server->new(name => $entry)));
+        }
       }
-
-   }
-
-   my %task_hash = (
-      func => $func,
-      server => [ @server ],
-      desc => $desc,
-      no_ssh => ($options->{"no_ssh"}?1:0),
-      hidden => ($options->{"dont_register"}?1:0),
-      exit_on_connect_fail => (exists $options->{exit_on_connect_fail}?$options->{exit_on_connect_fail}:1),
-      before => [],
-      after  => [],
-      around => [],
-      name => $task_name,
-      executor => Rex::Interface::Executor->create,
-      connection_type => Rex::Config->get_connection_type,
-   );
-
-   if($self->{DEFAULT_AUTH}) {
-      $task_hash{auth} = {
-         user        => Rex::Config->get_user,
-         password    => Rex::Config->get_password,
-         private_key => Rex::Config->get_private_key,
-         public_key  => Rex::Config->get_public_key,
-         sudo_password => Rex::Config->get_sudo_password,
-      };
-   }
-
-   $self->{tasks}->{$task_name} = Rex::Task->new(%task_hash);
+    }
+
+  }
+
+  my %task_hash = (
+    func => $func,
+    server => [ @server ],
+    desc => $desc,
+    no_ssh => ($options->{"no_ssh"}?1:0),
+    hidden => ($options->{"dont_register"}?1:0),
+    exit_on_connect_fail => (exists $options->{exit_on_connect_fail}?$options->{exit_on_connect_fail}:1),
+    before => [],
+    after  => [],
+    around => [],
+    name => $task_name,
+    executor => Rex::Interface::Executor->create,
+    connection_type => Rex::Config->get_connection_type,
+  );
+
+  if($self->{DEFAULT_AUTH}) {
+    $task_hash{auth} = {
+      user      => Rex::Config->get_user,
+      password   => Rex::Config->get_password,
+      private_key => Rex::Config->get_private_key,
+      public_key  => Rex::Config->get_public_key,
+      sudo_password => Rex::Config->get_sudo_password,
+    };
+  }
+
+  $self->{tasks}->{$task_name} = Rex::Task->new(%task_hash);
 
 }
 
 
 sub get_tasks {
-   my $self = shift;
-   return grep { $self->{tasks}->{$_}->hidden() == 0 } sort { $a cmp $b } keys %{ $self->{tasks} };
+  my $self = shift;
+  return grep { $self->{tasks}->{$_}->hidden() == 0 } sort { $a cmp $b } keys %{ $self->{tasks} };
 }
 
 sub get_tasks_for {
-   my $self = shift;
-   my $host = shift;
+  my $self = shift;
+  my $host = shift;
 
-   my @tasks;
-   for my $task_name (keys %{ $self->{tasks} }) {
-      my @servers = @{ $self->{tasks}->{$task_name}->server() };
+  my @tasks;
+  for my $task_name (keys %{ $self->{tasks} }) {
+    my @servers = @{ $self->{tasks}->{$task_name}->server() };
 
-      if( (grep { /^$host$/ } @servers) || $#servers == -1) {
-         push @tasks, $task_name;
-      }
-   }
+    if( (grep { /^$host$/ } @servers) || $#servers == -1) {
+      push @tasks, $task_name;
+    }
+  }
 
-   return sort { $a cmp $b } @tasks;
+  return sort { $a cmp $b } @tasks;
 }
 
 sub get_task {
-   my ($self, $task) = @_;
-   return $self->{tasks}->{$task};
+  my ($self, $task) = @_;
+  return $self->{tasks}->{$task};
 }
 
 sub clear_tasks {
-   my $self = shift;
-   $self->{tasks} = {};
+  my $self = shift;
+  $self->{tasks} = {};
 }
 
 sub get_desc {
-   my $self = shift;
-   my $task = shift;
+  my $self = shift;
+  my $task = shift;
 
-   return $self->{tasks}->{$task}->desc();
+  return $self->{tasks}->{$task}->desc();
 }
 
 sub is_task {
-   my $self = shift;
-   my $task = shift;
-   
-   if(exists $self->{tasks}->{$task}) { return 1; }
-   return 0;
+  my $self = shift;
+  my $task = shift;
+  
+  if(exists $self->{tasks}->{$task}) { return 1; }
+  return 0;
 }
 
 sub run {
-   my ($self, $task_name, %option) = @_;
-   my $task = $self->get_task($task_name);
+  my ($self, $task_name, %option) = @_;
+  my $task = $self->get_task($task_name);
 
-   $option{params} ||= { Rex::Args->get };
+  $option{params} ||= { Rex::Args->get };
 
-   my @all_server = @{ $task->server };
+  my @all_server = @{ $task->server };
 
-   my $fm = Rex::Fork::Manager->new(max => $task->parallelism || Rex::Config->get_parallelism);
+  my $fm = Rex::Fork::Manager->new(max => $task->parallelism || Rex::Config->get_parallelism);
 
-   for my $server (@all_server) {
+  for my $server (@all_server) {
 
-      my $forked_sub = sub {
+    my $forked_sub = sub {
 
-         Rex::Logger::init();
-         # create a single task object for the run on $server
+      Rex::Logger::init();
+      # create a single task object for the run on $server
 
-         Rex::Logger::info("Running task $task_name on $server");
-         my $run_task = Rex::Task->new( %{$task->get_data} );
+      Rex::Logger::info("Running task $task_name on $server");
+      my $run_task = Rex::Task->new( %{$task->get_data} );
 
-         $run_task->run($server,
-                     in_transaction => $self->{IN_TRANSACTION},
-                     params => $option{params});
+      $run_task->run($server,
+              in_transaction => $self->{IN_TRANSACTION},
+              params => $option{params});
 
-        # destroy cached os info
-         Rex::Logger::debug("Destroying all cached os information");
+      # destroy cached os info
+      Rex::Logger::debug("Destroying all cached os information");
 
-         Rex::Logger::shutdown();
+      Rex::Logger::shutdown();
 
-      };
+    };
 
-      # add the worker (forked_sub) to the fork queue
-      unless($self->{IN_TRANSACTION}) {
-         # not inside a transaction, so lets fork happyly...
-         $fm->add($forked_sub, 1);
-      }
-      else {
-         # inside a transaction, no little small funny kids, ... and no chance to get zombies :(
-         &$forked_sub();
-      }
+    # add the worker (forked_sub) to the fork queue
+    unless($self->{IN_TRANSACTION}) {
+      # not inside a transaction, so lets fork happyly...
+      $fm->add($forked_sub, 1);
+    }
+    else {
+      # inside a transaction, no little small funny kids, ... and no chance to get zombies :(
+      &$forked_sub();
+    }
 
-   }
+  }
 
-   Rex::Logger::debug("Waiting for children to finish");
-   my $ret = $fm->wait_for_all;
+  Rex::Logger::debug("Waiting for children to finish");
+  my $ret = $fm->wait_for_all;
 
-   Rex::reconnect_lost_connections();
+  Rex::reconnect_lost_connections();
 
-   return $ret;
+  return $ret;
 }
 
 sub modify {
-   my ($self, $type, $task, $code, $package, $file, $line) = @_;
-
-   if($package ne "main" && $package ne "Rex::CLI") {
-      if($task !~ m/:/) {
-         #do we need to detect for base -Rex ?
-         $package =~ s/^Rex:://;
-         $package =~ s/::/:/g;
-         $task = $package . ":" . $task;
-      }
-   }
-
-   my $taskref = $self->get_task($task);
-   if (defined($taskref)) {
-      $taskref->modify($type => $code);
-   } else {
-      Rex::Logger::info("can't add $type $task, as its not yet defined\nsee $file line $line");
-   }
+  my ($self, $type, $task, $code, $package, $file, $line) = @_;
+
+  if($package ne "main" && $package ne "Rex::CLI") {
+    if($task !~ m/:/) {
+      #do we need to detect for base -Rex ?
+      $package =~ s/^Rex:://;
+      $package =~ s/::/:/g;
+      $task = $package . ":" . $task;
+    }
+  }
+
+  my $taskref = $self->get_task($task);
+  if (defined($taskref)) {
+    $taskref->modify($type => $code);
+  } else {
+    Rex::Logger::info("can't add $type $task, as its not yet defined\nsee $file line $line");
+  }
 }
 
 sub set_default_auth {
-   my ($self, $auth) = @_;
-   $self->{DEFAULT_AUTH} = $auth;
+  my ($self, $auth) = @_;
+  $self->{DEFAULT_AUTH} = $auth;
 }
 
 sub is_default_auth {
-   my ($self) = @_;
-   return $self->{DEFAULT_AUTH};
+  my ($self) = @_;
+  return $self->{DEFAULT_AUTH};
 }
 
 sub set_in_transaction {
-   my ($self, $val) = @_;
-   $self->{IN_TRANSACTION} = $val;
+  my ($self, $val) = @_;
+  $self->{IN_TRANSACTION} = $val;
 }
 
 sub is_transaction {
-   my ($self) = @_;
-   return $self->{IN_TRANSACTION};
+  my ($self) = @_;
+  return $self->{IN_TRANSACTION};
 }
 
 sub get_exit_codes {
-   my ($self) = @_;
-   return @Rex::Fork::Task::PROCESS_LIST;
+  my ($self) = @_;
+  return @Rex::Fork::Task::PROCESS_LIST;
 }
 
 1;
@@ -1,11 +1,11 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::TaskList;
-   
+  
 use strict;
 use warnings;
 
@@ -20,28 +20,28 @@ use vars qw(%tasks);
 our $task_list = {};
 
 sub create {
-   my ($class) = @_;
+  my ($class) = @_;
 
-   # create only one object
-   if(ref($task_list) =~ m/^Rex::TaskList::/) {
-      Rex::Logger::debug("Returning existing distribution class of type: " . ref($task_list));
-      return $task_list;
-   }
+  # create only one object
+  if(ref($task_list) =~ m/^Rex::TaskList::/) {
+    Rex::Logger::debug("Returning existing distribution class of type: " . ref($task_list));
+    return $task_list;
+  }
 
-   my $type = Rex::Config->get_distributor;
-   Rex::Logger::debug("Creating new distribution class of type: $type");
+  my $type = Rex::Config->get_distributor;
+  Rex::Logger::debug("Creating new distribution class of type: $type");
 
-   my $class_name = "Rex::TaskList::$type";
+  my $class_name = "Rex::TaskList::$type";
 
-   eval "use $class_name";
-   if($@) {
-      die("TaskList module not found.");
-   }
+  eval "use $class_name";
+  if($@) {
+    die("TaskList module not found.");
+  }
 
-   $task_list = $class_name->new;
+  $task_list = $class_name->new;
 
-   Rex::Logger::debug("new distribution class of type " . ref($task_list) . " created.");
+  Rex::Logger::debug("new distribution class of type " . ref($task_list) . " created.");
 
-   return $task_list;
+  return $task_list;
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -38,191 +38,191 @@ our $DO_CHOMP = 0;
 our $BE_LOCAL = 1;
 
 sub function {
-   my ($class, $name, $code) = @_;
-   
-   no strict 'refs';
-   *{ $class . "::" . $name } = $code;
-   use strict;
+  my ($class, $name, $code) = @_;
+  
+  no strict 'refs';
+  *{ $class . "::" . $name } = $code;
+  use strict;
 }
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub parse {
-   my $self = shift;
-   my $data = shift;
-
-   my $vars = {};
-
-   if(ref($_[0]) eq "HASH") {
-      $vars = shift;
-   }
-   else {
-      $vars = { @_ };
-   }
+  my $self = shift;
+  my $data = shift;
+
+  my $vars = {};
+
+  if(ref($_[0]) eq "HASH") {
+    $vars = shift;
+  }
+  else {
+    $vars = { @_ };
+  }
+
+  my $new_data;
+  my $___r="";
+
+  my $config_values = Rex::Config->get_all;
+  for my $key (keys %{ $config_values }) {
+    if(! exists $vars->{$key}) {
+      $vars->{$key} = $config_values->{$key};
+    }
+  }
+
+  my $do_chomp = 0;
+  $new_data = join("\n", map {
+    my ($code, $type, $text) = ($_ =~ m/(\<%)*([+=])*(.+)%\>/s);
+
+    if($code) {
+      my $pcmd = substr($text, -1);
+      if($pcmd eq "-") {
+        $text = substr($text, 0, -1);
+        $do_chomp = 1;
+      }
 
-   my $new_data;
-   my $___r="";
+      my($var_type, $var_name) = ($text =~ m/([\$])::([a-zA-Z0-9_]+)/);
 
-   my $config_values = Rex::Config->get_all;
-   for my $key (keys %{ $config_values }) {
-      if(! exists $vars->{$key}) {
-         $vars->{$key} = $config_values->{$key};
+      if($var_name && ! ref($vars->{$var_name}) && ! $BE_LOCAL) {
+        $text =~ s/([\$])::([a-zA-Z0-9_]+)/$1\{\$$2\}/g;
+      }
+      elsif($var_name && ! ref($vars->{$var_name}) && $BE_LOCAL) {
+        $text =~ s/([\$])::([a-zA-Z0-9_]+)/$1$2/g;
       }
-   }
-
-   my $do_chomp = 0;
-   $new_data = join("\n", map {
-      my ($code, $type, $text) = ($_ =~ m/(\<%)*([+=])*(.+)%\>/s);
-
-      if($code) {
-         my $pcmd = substr($text, -1);
-         if($pcmd eq "-") {
-            $text = substr($text, 0, -1);
-            $do_chomp = 1;
-         }
-
-         my($var_type, $var_name) = ($text =~ m/([\$])::([a-zA-Z0-9_]+)/);
-
-         if($var_name && ! ref($vars->{$var_name}) && ! $BE_LOCAL) {
-            $text =~ s/([\$])::([a-zA-Z0-9_]+)/$1\{\$$2\}/g;
-         }
-         elsif($var_name && ! ref($vars->{$var_name}) && $BE_LOCAL) {
-            $text =~ s/([\$])::([a-zA-Z0-9_]+)/$1$2/g;
-         }
-         else {
-            $text =~ s/([\$])::([a-zA-Z0-9_]+)/\$$2/g;
-         }
-
-         if($type && $type =~ m/^[+=]$/) {
-            $_ = "\$___r .= $text;";
-         }
-         else {
-            $_ = $text;
-         }
-
-      } 
-      
       else {
-         if($DO_CHOMP || $do_chomp) {
-            chomp $_;
-            $do_chomp = 0;
-         }
-         $_ = '$___r .= "' . _quote($_) . '";';
+        $text =~ s/([\$])::([a-zA-Z0-9_]+)/\$$2/g;
+      }
 
+      if($type && $type =~ m/^[+=]$/) {
+        $_ = "\$___r .= $text;";
+      }
+      else {
+        $_ = $text;
+      }
 
+    } 
+    
+    else {
+      if($DO_CHOMP || $do_chomp) {
+        chomp $_;
+        $do_chomp = 0;
       }
+      $_ = '$___r .= "' . _quote($_) . '";';
 
-   } split(/(\<%.*?%\>)/s, $data));
 
-   eval {
-      no strict 'refs';
-      no strict 'vars';
+    }
 
-      for my $var (keys %{$vars}) {
-         Rex::Logger::debug("Registering: $var");
-         unless(ref($vars->{$var})) {
-            $$var = \$vars->{$var};
-         } else {
-            $$var = $vars->{$var};
-         }
-      }
+  } split(/(\<%.*?%\>)/s, $data));
 
-      if($BE_LOCAL == 1) {
-         my $var_data = '
-        
-        return sub {
-           my $___r = "";
-           my (
-         
-         ';
+  eval {
+    no strict 'refs';
+    no strict 'vars';
 
-         my @code_values;
-         for my $var (keys %{$vars}) {
-            my $new_var = _normalize_var_name($var);
-            Rex::Logger::debug("Registering local: $new_var");
-            $var_data .= '$' . $new_var . ", \n";
-            push(@code_values, $vars->{$var});
-         }
+    for my $var (keys %{$vars}) {
+      Rex::Logger::debug("Registering: $var");
+      unless(ref($vars->{$var})) {
+        $$var = \$vars->{$var};
+      } else {
+        $$var = $vars->{$var};
+      }
+    }
 
-         $var_data .= '$this_is_really_nothing) = @_;';
-         $var_data .= "\n";
+    if($BE_LOCAL == 1) {
+      my $var_data = '
+      
+      return sub {
+        my $___r = "";
+        my (
+      
+      ';
 
-         $var_data .= $new_data;
+      my @code_values;
+      for my $var (keys %{$vars}) {
+        my $new_var = _normalize_var_name($var);
+        Rex::Logger::debug("Registering local: $new_var");
+        $var_data .= '$' . $new_var . ", \n";
+        push(@code_values, $vars->{$var});
+      }
 
-         $var_data .= "\n";
-         $var_data .= ' return $___r;';
-         $var_data .= "\n};";
+      $var_data .= '$this_is_really_nothing) = @_;';
+      $var_data .= "\n";
 
-         Rex::Logger::debug("BE_LOCAL==1");
+      $var_data .= $new_data;
 
-         my %args = Rex::Args->getopts;
-         if(defined $args{'d'} && $args{'d'} > 1) {
-            Rex::Logger::debug($var_data);
-         }
+      $var_data .= "\n";
+      $var_data .= ' return $___r;';
+      $var_data .= "\n};";
 
-         my $tpl_code = eval($var_data);
+      Rex::Logger::debug("BE_LOCAL==1");
 
-         if($@) {
-            Rex::Logger::info($@);
-         }
+      my %args = Rex::Args->getopts;
+      if(defined $args{'d'} && $args{'d'} > 1) {
+        Rex::Logger::debug($var_data);
+      }
 
-         $___r = $tpl_code->(@code_values);
+      my $tpl_code = eval($var_data);
 
+      if($@) {
+        Rex::Logger::info($@);
       }
-      else {
-         Rex::Logger::debug("BE_LOCAL==0");
-         my %args = Rex::Args->getopts;
-         if(defined $args{'d'} && $args{'d'} > 1) {
-            Rex::Logger::debug($new_data);
-         }
 
-         $___r = eval($new_data);
+      $___r = $tpl_code->(@code_values);
 
-         if($@) {
-            Rex::Logger::info($@);
-         }
+    }
+    else {
+      Rex::Logger::debug("BE_LOCAL==0");
+      my %args = Rex::Args->getopts;
+      if(defined $args{'d'} && $args{'d'} > 1) {
+        Rex::Logger::debug($new_data);
       }
 
-      # undef the vars
-      for my $var (keys %{$vars}) {
-         $$var = undef;
+      $___r = eval($new_data);
+
+      if($@) {
+        Rex::Logger::info($@);
       }
+    }
+
+    # undef the vars
+    for my $var (keys %{$vars}) {
+      $$var = undef;
+    }
 
-   };
+  };
 
-   if(! $___r) {
-      Rex::Logger::info("It seems that there was an error processing the template", "warn");
-      Rex::Logger::info("because the result is empty.", "warn");
-      die("Error processing template");
-   }
+  if(! $___r) {
+    Rex::Logger::info("It seems that there was an error processing the template", "warn");
+    Rex::Logger::info("because the result is empty.", "warn");
+    die("Error processing template");
+  }
 
-   return $___r;
+  return $___r;
 }
 
 sub _quote {
-   my ($str) = @_;
+  my ($str) = @_;
 
-   $str =~ s/\\/\\\\/g;
-   $str =~ s/"/\\"/g;
-   $str =~ s/\@/\\@/g;
-   $str =~ s/\%/\\%/g;
-   $str =~ s/\$/\\\$/g;
+  $str =~ s/\\/\\\\/g;
+  $str =~ s/"/\\"/g;
+  $str =~ s/\@/\\@/g;
+  $str =~ s/\%/\\%/g;
+  $str =~ s/\$/\\\$/g;
 
-   return $str;
+  return $str;
 }
 
 sub _normalize_var_name {
-   my($input) = @_;
-   $input =~ s/[^A-Za-z0-9_]/_/g;
-   return $input;
+  my($input) = @_;
+  $input =~ s/[^A-Za-z0-9_]/_/g;
+  return $input;
 }
 
 =item is_defined($variable, $default_value)
@@ -236,10 +236,10 @@ You can use this function inside your templates.
 =cut
 
 sub is_defined {
-   my ($check_var, $default) = @_;
-   if(defined $check_var) { return $check_var; }
+  my ($check_var, $default) = @_;
+  if(defined $check_var) { return $check_var; }
 
-   return $default;
+  return $default;
 }
 
 =back
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,16 +15,16 @@ With this module you can define transactions and rollback szenarios on failure.
 =head1 SYNOPSIS
 
  task "do-something", "server01", sub {
-   on_rollback {
-      rmdir "/tmp/mydata";
-   };
-
-   transaction {
-      mkdir "/tmp/mydata";
-      upload "files/myapp.tar.gz", "/tmp/mydata";
-      run "cd /tmp/mydata; tar xzf myapp.tar.gz";
-      if($? != 0) { die("Error extracting myapp.tar.gz"); }
-   };
+  on_rollback {
+    rmdir "/tmp/mydata";
+  };
+ 
+  transaction {
+    mkdir "/tmp/mydata";
+    upload "files/myapp.tar.gz", "/tmp/mydata";
+    run "cd /tmp/mydata; tar xzf myapp.tar.gz";
+    if($? != 0) { die("Error extracting myapp.tar.gz"); }
+  };
  };
 
 =head1 EXPORTED FUNCTIONS
@@ -56,58 +56,58 @@ use Data::Dumper;
 Start a transaction for $codeRef. If $codeRef dies it will rollback the transaction.
 
  task "deploy", group => "frontend", sub {
-     on_rollback {
-         rmdir "...";
-     };
-     deploy "myapp.tar.gz";
+    on_rollback {
+      rmdir "...";
+    };
+    deploy "myapp.tar.gz";
  };
-   
+  
  task "restart_server", group => "frontend", sub {
-     run "/etc/init.d/apache2 restart";
+    run "/etc/init.d/apache2 restart";
  };
-   
+  
  task "all", group => "frontend", sub {
-     transaction {
-         do_task [qw/deploy restart_server/];
-     };
+    transaction {
+      do_task [qw/deploy restart_server/];
+    };
  };
 
 =cut
 
 sub transaction(&) {
-   my ($code) = @_;
-   my $ret = 1;
+  my ($code) = @_;
+  my $ret = 1;
 
-   Rex::Logger::debug("Cleaning ROLLBACKS array");
-   @ROLLBACKS = ();
+  Rex::Logger::debug("Cleaning ROLLBACKS array");
+  @ROLLBACKS = ();
 
-   Rex::TaskList->create()->set_in_transaction(1);
+  Rex::TaskList->create()->set_in_transaction(1);
 
-   eval {
-      &$code();
-   };
+  eval {
+    &$code();
+  };
 
-   if($@) {
-      Rex::Logger::info("Transaction failed. Rolling back.");
+  if($@) {
+    Rex::Logger::info("Transaction failed. Rolling back.");
 
-      $ret = 0;
-      for my $rollback_code (reverse @ROLLBACKS) {
-         # push the connection of the task back
-         Rex::push_connection($rollback_code->{"connection"});
+    $ret = 0;
+    for my $rollback_code (reverse @ROLLBACKS) {
+      # push the connection of the task back
+      Rex::push_connection($rollback_code->{"connection"});
 
-         # run the rollback code
-         &{ $rollback_code->{"code"} }();
+      # run the rollback code
+      &{ $rollback_code->{"code"} }();
 
-         # and pop it away
-         Rex::pop_connection();
-      }
+      # and pop it away
+      Rex::pop_connection();
+    }
 
-      die("Transaction failed. Rollback done.");
-   }
+    die("Transaction failed. Rollback done.");
+  }
 
-   Rex::TaskList->create()->set_in_transaction(0);
+  Rex::TaskList->create()->set_in_transaction(0);
 
-   return $ret;
+  return $ret;
 
 }
 
@@ -120,12 +120,12 @@ See I<transaction>.
 =cut
 
 sub on_rollback(&) {
-   my ($code) = @_;
+  my ($code) = @_;
 
-   push (@ROLLBACKS, {
-      code       => $code,
-      connection => Rex::get_current_connection()
-   });
+  push (@ROLLBACKS, {
+    code     => $code,
+    connection => Rex::get_current_connection()
+  });
 }
 
 =back
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::User::FreeBSD;
 
 use strict;
@@ -24,244 +24,244 @@ use JSON::XS;
 use base qw(Rex::User::Linux);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub create_user {
-   my ($self, $user, $data) = @_;
-
-   my $cmd;
-
-
-   if(! defined $self->get_uid($user)) {
-      Rex::Logger::debug("User $user does not exists. Creating it now.");
-      $cmd = "pw useradd ";
-   }
-   else {
-      Rex::Logger::debug("User $user already exists. Updating...");
-      $cmd = "pw usermod ";
-   }
-
-   if($data->{"uid"}) {
-      $cmd .= " -u " . $data->{"uid"}
-   }
-
-   if($data->{"home"}) {
-      $cmd .= " -d " . $data->{"home"};
-      
-      if(
-         ! (
-            (exists $data->{"no-create-home"} && $data->{"no-create-home"})
-               ||
-            (exists $data->{"no_create_home"} && $data->{"no_create_home"})
-         )
-        ) {
-         if(! $self->get_uid($user)) {
-            $cmd .= " -m ";
-         }
+  my ($self, $user, $data) = @_;
+
+  my $cmd;
+
+
+  if(! defined $self->get_uid($user)) {
+    Rex::Logger::debug("User $user does not exists. Creating it now.");
+    $cmd = "pw useradd ";
+  }
+  else {
+    Rex::Logger::debug("User $user already exists. Updating...");
+    $cmd = "pw usermod ";
+  }
+
+  if($data->{"uid"}) {
+    $cmd .= " -u " . $data->{"uid"}
+  }
+
+  if($data->{"home"}) {
+    $cmd .= " -d " . $data->{"home"};
+    
+    if(
+      ! (
+        (exists $data->{"no-create-home"} && $data->{"no-create-home"})
+          ||
+        (exists $data->{"no_create_home"} && $data->{"no_create_home"})
+      )
+      ) {
+      if(! $self->get_uid($user)) {
+        $cmd .= " -m ";
       }
+    }
 
-   }
+  }
 
-   if(exists $data->{shell}) {
-      $cmd .= " -s " . $data->{shell};
-   }
+  if(exists $data->{shell}) {
+    $cmd .= " -s " . $data->{shell};
+  }
 
-   if($data->{"comment"}) {
-      $cmd .= " -c \"" . $data->{"comment"} . "\" ";
-   }
+  if($data->{"comment"}) {
+    $cmd .= " -c \"" . $data->{"comment"} . "\" ";
+  }
 
 
-   if($data->{"expire"}) {
-      $cmd .= " -e " . $data->{"expire"};
-   }
+  if($data->{"expire"}) {
+    $cmd .= " -e " . $data->{"expire"};
+  }
 
-   if($data->{"groups"}) {
-      my @groups = @{$data->{groups}};
-      $cmd .= " -g " . $groups[0];
-      $cmd .= " -G " . join(",", @groups);
-   }
+  if($data->{"groups"}) {
+    my @groups = @{$data->{groups}};
+    $cmd .= " -g " . $groups[0];
+    $cmd .= " -G " . join(",", @groups);
+  }
 
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write("$cmd -n $user\nexit \$?\n");
-   $fh->close;
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write("$cmd -n $user\nexit \$?\n");
+  $fh->close;
 
-   i_run "/bin/sh $rnd_file";
-   if($? == 0) {
-      Rex::Logger::debug("User $user created/updated.");
-   }
-   else {
-      Rex::Logger::info("Error creating/updating user $user", "warn");
-      die("Error creating/updating user $user");
-   }
+  i_run "/bin/sh $rnd_file";
+  if($? == 0) {
+    Rex::Logger::debug("User $user created/updated.");
+  }
+  else {
+    Rex::Logger::info("Error creating/updating user $user", "warn");
+    die("Error creating/updating user $user");
+  }
 
-   Rex::Interface::Fs->create()->unlink($rnd_file);
+  Rex::Interface::Fs->create()->unlink($rnd_file);
 
-   if(exists $data->{password}) {
-      Rex::Logger::debug("Changing password of $user.");
+  if(exists $data->{password}) {
+    Rex::Logger::debug("Changing password of $user.");
 
-      $rnd_file = get_tmp_file;
-      $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("echo '".$data->{password} . "' | pw usermod $user -h 0\nexit \$?\n");
-      $fh->close;
+    $rnd_file = get_tmp_file;
+    $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("echo '".$data->{password} . "' | pw usermod $user -h 0\nexit \$?\n");
+    $fh->close;
 
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
 
-      Rex::Interface::Fs->create()->unlink($rnd_file);
-   }
+    Rex::Interface::Fs->create()->unlink($rnd_file);
+  }
 
-   return $self->get_uid($user);
+  return $self->get_uid($user);
 
 }
 
 sub rm_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   Rex::Logger::debug("Removing user $user");
+  Rex::Logger::debug("Removing user $user");
 
-   my $cmd = "pw userdel";
+  my $cmd = "pw userdel";
 
-   if(exists $data->{delete_home}) {
-      $cmd .= " -r ";
-   }
+  if(exists $data->{delete_home}) {
+    $cmd .= " -r ";
+  }
 
-   i_run $cmd . " -n " . $user;
-   if($? != 0) {
-      die("Error deleting user $user");
-   }
+  i_run $cmd . " -n " . $user;
+  if($? != 0) {
+    die("Error deleting user $user");
+  }
 
 }
 
 sub get_uid {
-   my ($self, $user) = @_;
+  my ($self, $user) = @_;
 
-   my %data = $self->get_user($user);
-   return $data{uid};
+  my %data = $self->get_user($user);
+  return $data{uid};
 }
 
 sub get_user {
-   my ($self, $user) = @_;
-
-   Rex::Logger::debug("Getting information for $user");
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   my $script = q|
-      unlink $0;
-      print to_json([ getpwnam($ARGV[0]) ]);
-   |;
-   $fh->open(">", $rnd_file);
-   $fh->write($script);
-   $fh->write(func_to_json());
-   $fh->close;
-
-   my $data_str = i_run "perl $rnd_file $user";
-   if($? != 0) {
-      die("Error getting  user information for $user");
-   }
-
-   Rex::Interface::Fs->create()->unlink($rnd_file);
-
-   my $data = decode_json($data_str);
-
-   return ( 
-      name => $data->[0],
-      password => $data->[1],
-      uid => $data->[2],
-      gid => $data->[3],
-      comment => $data->[5],
-      home => $data->[7],
-      shell => $data->[8],
-      expire => exists $data->[9]?$data->[9]:0,
-   );
+  my ($self, $user) = @_;
+
+  Rex::Logger::debug("Getting information for $user");
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  my $script = q|
+    unlink $0;
+    print to_json([ getpwnam($ARGV[0]) ]);
+  |;
+  $fh->open(">", $rnd_file);
+  $fh->write($script);
+  $fh->write(func_to_json());
+  $fh->close;
+
+  my $data_str = i_run "perl $rnd_file $user";
+  if($? != 0) {
+    die("Error getting  user information for $user");
+  }
+
+  Rex::Interface::Fs->create()->unlink($rnd_file);
+
+  my $data = decode_json($data_str);
+
+  return ( 
+    name => $data->[0],
+    password => $data->[1],
+    uid => $data->[2],
+    gid => $data->[3],
+    comment => $data->[5],
+    home => $data->[7],
+    shell => $data->[8],
+    expire => exists $data->[9]?$data->[9]:0,
+  );
 }
 
 sub create_group {
-   my ($self, $group, $data) = @_;
+  my ($self, $group, $data) = @_;
 
-   my $cmd;
+  my $cmd;
 
-   if(! defined $self->get_gid($group)) {
-      Rex::Logger::debug("Creating new group $group");
+  if(! defined $self->get_gid($group)) {
+    Rex::Logger::debug("Creating new group $group");
 
-      $cmd = "pw groupadd ";
-   }
-   else {
-      Rex::Logger::debug("Group $group already exists. Updating...");
-      $cmd = "pw groupmod ";
-   }
-   
-   if(exists $data->{gid}) {
-      $cmd .= " -g " . $data->{gid};
-   }
+    $cmd = "pw groupadd ";
+  }
+  else {
+    Rex::Logger::debug("Group $group already exists. Updating...");
+    $cmd = "pw groupmod ";
+  }
+  
+  if(exists $data->{gid}) {
+    $cmd .= " -g " . $data->{gid};
+  }
 
-   i_run $cmd . " -n " . $group;
-   if($? != 0) {
-      die("Error creating/modifying group $group");
-   }
+  i_run $cmd . " -n " . $group;
+  if($? != 0) {
+    die("Error creating/modifying group $group");
+  }
 
-   return $self->get_gid($group);
+  return $self->get_gid($group);
 
 }
 
 sub get_gid {
-   my ($self, $group) = @_;
+  my ($self, $group) = @_;
 
-   my %data = $self->get_group($group);
-   return $data{gid};
+  my %data = $self->get_group($group);
+  return $data{gid};
 }
 
 sub get_group {
-   my ($self, $group) = @_;
-
-   Rex::Logger::debug("Getting information for $group");
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   my $script = q|
-      unlink $0;
-      print to_json([ getgrnam($ARGV[0]) ]);
-   |;
-   $fh->open(">", $rnd_file);
-   $fh->write($script);
-   $fh->write(func_to_json());
-   $fh->close;
-
-   my $data_str = i_run "perl $rnd_file $group";
-   if($? != 0) {
-      die("Error getting group information");
-   }
-
-   Rex::Interface::Fs->create()->unlink($rnd_file);
-
-   my $data = decode_json($data_str);
-
-   return (
-      name => $data->[0],
-      password => $data->[1],
-      gid => $data->[2],
-      members => $data->[3],
-   );
+  my ($self, $group) = @_;
+
+  Rex::Logger::debug("Getting information for $group");
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  my $script = q|
+    unlink $0;
+    print to_json([ getgrnam($ARGV[0]) ]);
+  |;
+  $fh->open(">", $rnd_file);
+  $fh->write($script);
+  $fh->write(func_to_json());
+  $fh->close;
+
+  my $data_str = i_run "perl $rnd_file $group";
+  if($? != 0) {
+    die("Error getting group information");
+  }
+
+  Rex::Interface::Fs->create()->unlink($rnd_file);
+
+  my $data = decode_json($data_str);
+
+  return (
+    name => $data->[0],
+    password => $data->[1],
+    gid => $data->[2],
+    members => $data->[3],
+  );
 
 }
 
 sub rm_group {
-   my ($self, $group) = @_;
+  my ($self, $group) = @_;
 
-   i_run "pw groupdel $group";
-   if($? != 0) {
-      die("Error deleting group $group");
-   }
+  i_run "pw groupdel $group";
+  if($? != 0) {
+    die("Error deleting group $group");
+  }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::User::Linux;
@@ -23,395 +23,395 @@ use Rex::Helper::Path;
 use JSON::XS;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub create_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   my $cmd;
+  my $cmd;
 
-   my $uid = $self->get_uid($user);
+  my $uid = $self->get_uid($user);
 
-   my $run_cmd = 0;
+  my $run_cmd = 0;
 
-   if(! defined $uid) {
-      Rex::Logger::debug("User $user does not exists. Creating it now.");
-      $cmd = "/usr/sbin/useradd ";
+  if(! defined $uid) {
+    Rex::Logger::debug("User $user does not exists. Creating it now.");
+    $cmd = "/usr/sbin/useradd ";
 
-      if(exists $data->{system}) {
-         $cmd .= " -r";
-      }
-
-      $run_cmd = 1;
-   }
-   else {
-      # only the user should be there, no modifications. 
-      # so just return
-      if(! defined $data) {
-         if(Rex::Config->get_do_reporting) {
-            return {
-               changed => 0,
-               uid     => $uid,
-            };
-         }
-
-         return $uid;
-      }
-
-      Rex::Logger::debug("User $user already exists. Updating...");
-
-      if(exists $data->{uid} && $data->{uid} == $uid) {
-         delete $data->{uid};
-      }
-
-      $cmd = "/usr/sbin/usermod ";
-   }
-
-   if(exists $data->{non_uniq}) { 
-      $cmd .= " -o ";
-      $run_cmd = 1;
-   }
-
-   if(exists $data->{uid}) {
-      $cmd .= " --uid " . $data->{uid};
-      $run_cmd = 1;
-   }
-
-   if(exists $data->{home}) {
-      $run_cmd = 1;
-      $cmd .= " -d " . $data->{home};
-
-      if(
-         (exists $data->{"no-create-home"} && $data->{"no-create-home"})
-            ||
-         (exists $data->{"no_create_home"} && $data->{"no_create_home"})
-        ) {
-         if(! $self->get_uid($user)) {
-            $cmd .= " -M";
-         }
-      }
-      elsif(!is_dir($data->{home})) {
-         $cmd .= " -m";
-      }
-   }
-
-   if(exists $data->{shell}) {
-      $run_cmd = 1;
-      $cmd .= " --shell " . $data->{shell};
-   }
-
-   if(exists $data->{comment}) {
-      $run_cmd = 1;
-      $cmd .= " --comment '" . $data->{comment} . "'";
-   }
-
-   if(exists $data->{expire}) {
-      $run_cmd = 1;
-      $cmd .= " --expiredate '" . $data->{expire} . "'";
-   }
-
-   if(exists $data->{groups}) {
-      $run_cmd = 1;
-      my @groups = @{$data->{groups}};
-      my $pri_group = shift @groups;
-
-      $cmd .= " --gid $pri_group";
-
-      if(@groups) {
-         $cmd .= " --groups " . join(",", @groups);
-      }
-   }
-
-   my $old_pw_md5 = md5("/etc/passwd");
-   my $old_sh_md5 = md5("/etc/shadow");
+    if(exists $data->{system}) {
+      $cmd .= " -r";
+    }
 
-
-   # only run the cmd if needed
-   if($run_cmd) {
-      my $rnd_file = get_tmp_file;
-      my $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("rm \$0\n$cmd $user\nexit \$?\n");
-      $fh->close;
-
-      i_run "/bin/sh $rnd_file";
-      if($? == 0) {
-         Rex::Logger::debug("User $user created/updated.");
-      }
-      else {
-         Rex::Logger::info("Error creating/updating user $user", "warn");
-         die("Error creating/updating user $user");
+    $run_cmd = 1;
+  }
+  else {
+    # only the user should be there, no modifications. 
+    # so just return
+    if(! defined $data) {
+      if(Rex::Config->get_do_reporting) {
+        return {
+          changed => 0,
+          uid    => $uid,
+        };
       }
 
-   }
+      return $uid;
+    }
 
-   if(exists $data->{password}) {
-      my $rnd_file = get_tmp_file;
-      my $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("rm \$0\n/bin/echo -e '" . $data->{password} . "\\n" . $data->{password} . "' | /usr/bin/passwd $user\nexit \$?\n");
-      $fh->close;
+    Rex::Logger::debug("User $user already exists. Updating...");
 
-      Rex::Logger::debug("Changing password of $user.");
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
+    if(exists $data->{uid} && $data->{uid} == $uid) {
+      delete $data->{uid};
+    }
 
-   }
+    $cmd = "/usr/sbin/usermod ";
+  }
 
-   if(exists $data->{crypt_password} && $data->{crypt_password}) {
-      my $rnd_file = get_tmp_file;
-      my $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("rm \$0\nusermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
-      $fh->close;
+  if(exists $data->{non_uniq}) { 
+    $cmd .= " -o ";
+    $run_cmd = 1;
+  }
 
-      Rex::Logger::debug("Setting encrypted password of $user");
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
-   }
+  if(exists $data->{uid}) {
+    $cmd .= " --uid " . $data->{uid};
+    $run_cmd = 1;
+  }
 
-   my $new_pw_md5 = md5("/etc/passwd");
-   my $new_sh_md5 = md5("/etc/shadow");
+  if(exists $data->{home}) {
+    $run_cmd = 1;
+    $cmd .= " -d " . $data->{home};
 
-   if(Rex::Config->get_do_reporting) {
-      if($new_pw_md5 eq $old_pw_md5 && $new_sh_md5 eq $old_sh_md5) {
-         return {
-            changed => 0,
-            ret     => $self->get_uid($user),
-         };
-      }
-      else {
-         return {
-            changed => 1,
-            ret     => $self->get_uid($user),
-         },
+    if(
+      (exists $data->{"no-create-home"} && $data->{"no-create-home"})
+        ||
+      (exists $data->{"no_create_home"} && $data->{"no_create_home"})
+      ) {
+      if(! $self->get_uid($user)) {
+        $cmd .= " -M";
       }
-   }
-
-   return $self->get_uid($user);
+    }
+    elsif(!is_dir($data->{home})) {
+      $cmd .= " -m";
+    }
+  }
+
+  if(exists $data->{shell}) {
+    $run_cmd = 1;
+    $cmd .= " --shell " . $data->{shell};
+  }
+
+  if(exists $data->{comment}) {
+    $run_cmd = 1;
+    $cmd .= " --comment '" . $data->{comment} . "'";
+  }
+
+  if(exists $data->{expire}) {
+    $run_cmd = 1;
+    $cmd .= " --expiredate '" . $data->{expire} . "'";
+  }
+
+  if(exists $data->{groups}) {
+    $run_cmd = 1;
+    my @groups = @{$data->{groups}};
+    my $pri_group = shift @groups;
+
+    $cmd .= " --gid $pri_group";
+
+    if(@groups) {
+      $cmd .= " --groups " . join(",", @groups);
+    }
+  }
+
+  my $old_pw_md5 = md5("/etc/passwd");
+  my $old_sh_md5 = md5("/etc/shadow");
+
+
+  # only run the cmd if needed
+  if($run_cmd) {
+    my $rnd_file = get_tmp_file;
+    my $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("rm \$0\n$cmd $user\nexit \$?\n");
+    $fh->close;
+
+    i_run "/bin/sh $rnd_file";
+    if($? == 0) {
+      Rex::Logger::debug("User $user created/updated.");
+    }
+    else {
+      Rex::Logger::info("Error creating/updating user $user", "warn");
+      die("Error creating/updating user $user");
+    }
+
+  }
+
+  if(exists $data->{password}) {
+    my $rnd_file = get_tmp_file;
+    my $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("rm \$0\n/bin/echo -e '" . $data->{password} . "\\n" . $data->{password} . "' | /usr/bin/passwd $user\nexit \$?\n");
+    $fh->close;
+
+    Rex::Logger::debug("Changing password of $user.");
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+
+  }
+
+  if(exists $data->{crypt_password} && $data->{crypt_password}) {
+    my $rnd_file = get_tmp_file;
+    my $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("rm \$0\nusermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
+    $fh->close;
+
+    Rex::Logger::debug("Setting encrypted password of $user");
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+  }
+
+  my $new_pw_md5 = md5("/etc/passwd");
+  my $new_sh_md5 = md5("/etc/shadow");
+
+  if(Rex::Config->get_do_reporting) {
+    if($new_pw_md5 eq $old_pw_md5 && $new_sh_md5 eq $old_sh_md5) {
+      return {
+        changed => 0,
+        ret    => $self->get_uid($user),
+      };
+    }
+    else {
+      return {
+        changed => 1,
+        ret    => $self->get_uid($user),
+      },
+    }
+  }
+
+  return $self->get_uid($user);
 
 }
 
 sub rm_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   Rex::Logger::debug("Removing user $user");
+  Rex::Logger::debug("Removing user $user");
 
-   my $cmd = "/usr/sbin/userdel";
+  my $cmd = "/usr/sbin/userdel";
 
-   if(exists $data->{delete_home}) {
-      $cmd .= " --remove";
-   }
+  if(exists $data->{delete_home}) {
+    $cmd .= " --remove";
+  }
 
-   if(exists $data->{force}) {
-      $cmd .= " --force";
-   }
+  if(exists $data->{force}) {
+    $cmd .= " --force";
+  }
 
-   i_run $cmd . " " . $user;
-   if($? != 0) {
-      die("Error deleting user $user");
-   }
+  i_run $cmd . " " . $user;
+  if($? != 0) {
+    die("Error deleting user $user");
+  }
 
 }
 
 sub get_uid {
-   my ($self, $user) = @_;
+  my ($self, $user) = @_;
 
-   my %data = $self->get_user($user);
-   return $data{uid};
+  my %data = $self->get_user($user);
+  return $data{uid};
 }
 
 sub user_groups {
-   my ($self, $user) = @_;
+  my ($self, $user) = @_;
 
-   Rex::Logger::debug("Getting group membership of $user");
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   my $script = q|
-   unlink $0;
-   $exe = "/usr/bin/groups";
-   if(! -x $exe) {
-      $exe = "/bin/groups";
-   } print to_json([  map {chomp; $_ =~ s/^[^:]*:\s*(.*)\s*$/$1/; split / /, $_}  qx{$exe $ARGV[0]} ]);
+  Rex::Logger::debug("Getting group membership of $user");
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  my $script = q|
+  unlink $0;
+  $exe = "/usr/bin/groups";
+  if(! -x $exe) {
+    $exe = "/bin/groups";
+  } print to_json([  map {chomp; $_ =~ s/^[^:]*:\s*(.*)\s*$/$1/; split / /, $_}  qx{$exe $ARGV[0]} ]);
 
-   |;
+  |;
 
-   $fh->open(">", $rnd_file);
-   $fh->write($script);
-   $fh->write(func_to_json());
-   $fh->close;
+  $fh->open(">", $rnd_file);
+  $fh->write($script);
+  $fh->write(func_to_json());
+  $fh->close;
 
-   my $data_str = i_run "perl $rnd_file $user";
-   if($? != 0) {
-      die("Error getting group list");
-   }
+  my $data_str = i_run "perl $rnd_file $user";
+  if($? != 0) {
+    die("Error getting group list");
+  }
 
-   my $data = decode_json($data_str);
+  my $data = decode_json($data_str);
 
-   my $wantarray = wantarray();
+  my $wantarray = wantarray();
 
-   if(defined $wantarray && ! $wantarray) {
-      # arrayref
-      return $data;
-   }
+  if(defined $wantarray && ! $wantarray) {
+    # arrayref
+    return $data;
+  }
 
-   return @{ $data };
+  return @{ $data };
 }
 
 sub user_list {
-   my $self = shift;
-
-   Rex::Logger::debug("Getting user list");
-   my $rnd_file = get_tmp_file;
-   my $script = q|
-      unlink $0;
-      print to_json([ map {chomp; $_ =~ s/^([^:]*):.*$/$1/; $_}  qx{/usr/bin/getent passwd} ]);
-   |;
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write($script);
-   $fh->write(func_to_json());
-   $fh->close;
-
-   my $data_str = i_run "perl $rnd_file";
-   if($? != 0) {
-      die("Error getting user list");
-   }
-
-   my $data = decode_json($data_str);
-
-   return @$data;
+  my $self = shift;
+
+  Rex::Logger::debug("Getting user list");
+  my $rnd_file = get_tmp_file;
+  my $script = q|
+    unlink $0;
+    print to_json([ map {chomp; $_ =~ s/^([^:]*):.*$/$1/; $_}  qx{/usr/bin/getent passwd} ]);
+  |;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write($script);
+  $fh->write(func_to_json());
+  $fh->close;
+
+  my $data_str = i_run "perl $rnd_file";
+  if($? != 0) {
+    die("Error getting user list");
+  }
+
+  my $data = decode_json($data_str);
+
+  return @$data;
 }
 
 sub get_user {
-   my ($self, $user) = @_;
-
-   Rex::Logger::debug("Getting information for $user");
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   my $script = q|
-      unlink $0;
-      print to_json([ getpwnam($ARGV[0]) ]);
-   |;
-   $fh->open(">", $rnd_file);
-   $fh->write($script);
-   $fh->write(func_to_json());
-   $fh->close;
-
-   my $data_str = i_run "perl $rnd_file $user";
-   if($? != 0) {
-      die("Error getting user information for $user");
-   }
-
-   my $data = decode_json($data_str);
-
-   return (
-      name => $data->[0],
-      password => $data->[1],
-      uid => $data->[2],
-      gid => $data->[3],
-      comment => $data->[5],
-      home => $data->[7],
-      shell => $data->[8],
-      expire => exists $data->[9]?$data->[9]:0,
-   );
+  my ($self, $user) = @_;
+
+  Rex::Logger::debug("Getting information for $user");
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  my $script = q|
+    unlink $0;
+    print to_json([ getpwnam($ARGV[0]) ]);
+  |;
+  $fh->open(">", $rnd_file);
+  $fh->write($script);
+  $fh->write(func_to_json());
+  $fh->close;
+
+  my $data_str = i_run "perl $rnd_file $user";
+  if($? != 0) {
+    die("Error getting user information for $user");
+  }
+
+  my $data = decode_json($data_str);
+
+  return (
+    name => $data->[0],
+    password => $data->[1],
+    uid => $data->[2],
+    gid => $data->[3],
+    comment => $data->[5],
+    home => $data->[7],
+    shell => $data->[8],
+    expire => exists $data->[9]?$data->[9]:0,
+  );
 }
 
 sub create_group {
-   my ($self, $group, $data) = @_;
-
-   my $cmd;
-
-   my $gid = $self->get_gid($group);
-
-   if(! defined $gid) {
-      Rex::Logger::debug("Creating new group $group");
-
-      $cmd = "/usr/sbin/groupadd ";
-   }
-   elsif(exists $data->{gid} && $data->{gid} == $gid) {
+  my ($self, $group, $data) = @_;
+
+  my $cmd;
+
+  my $gid = $self->get_gid($group);
+
+  if(! defined $gid) {
+    Rex::Logger::debug("Creating new group $group");
+
+    $cmd = "/usr/sbin/groupadd ";
+  }
+  elsif(exists $data->{gid} && $data->{gid} == $gid) {
+    if(Rex::Config->get_do_reporting) {
+      return {
+        changed => 0,
+        ret    => $gid,
+      };
+    }
+    return $gid;
+  }
+  else {
+    if(! defined $data) {
       if(Rex::Config->get_do_reporting) {
-         return {
-            changed => 0,
-            ret     => $gid,
-         };
-      }
-      return $gid;
-   }
-   else {
-      if(! defined $data) {
-         if(Rex::Config->get_do_reporting) {
-            return {
-               changed => 0,
-               ret     => $gid,
-            };
-         }
-
-         return $gid;
+        return {
+          changed => 0,
+          ret    => $gid,
+        };
       }
-      Rex::Logger::debug("Group $group already exists. Updating...");
-      $cmd = "/usr/sbin/groupmod ";
-   }
-
-   if(exists $data->{gid}) {
-      $cmd .= " -g " . $data->{gid};
-      $gid = undef;
-   }
 
-   i_run $cmd . " " . $group;
-   if($? != 0) {
-      die("Error creating/modifying group $group");
-   }
-
-   if(defined $gid) {
       return $gid;
-   }
-
-   return $self->get_gid($group);
+    }
+    Rex::Logger::debug("Group $group already exists. Updating...");
+    $cmd = "/usr/sbin/groupmod ";
+  }
+
+  if(exists $data->{gid}) {
+    $cmd .= " -g " . $data->{gid};
+    $gid = undef;
+  }
+
+  i_run $cmd . " " . $group;
+  if($? != 0) {
+    die("Error creating/modifying group $group");
+  }
+
+  if(defined $gid) {
+    return $gid;
+  }
+
+  return $self->get_gid($group);
 }
 
 sub get_gid {
-   my ($self, $group) = @_;
+  my ($self, $group) = @_;
 
-   my %data = $self->get_group($group);
-   return $data{gid};
+  my %data = $self->get_group($group);
+  return $data{gid};
 }
 
 sub get_group {
-   my ($self, $group) = @_;
-
-   Rex::Logger::debug("Getting information for $group");
-   my @data = split(" ", "" . i_run("perl -le 'print join(\" \", getgrnam(\$ARGV[0]));' '$group'"), 4);
-   if($? != 0) {
-      die("Error getting group information");
-   }
-
-   return (
-      name => $data[0],
-      password => $data[1],
-      gid => $data[2],
-      members => $data[3],
-   );
+  my ($self, $group) = @_;
+
+  Rex::Logger::debug("Getting information for $group");
+  my @data = split(" ", "" . i_run("perl -le 'print join(\" \", getgrnam(\$ARGV[0]));' '$group'"), 4);
+  if($? != 0) {
+    die("Error getting group information");
+  }
+
+  return (
+    name => $data[0],
+    password => $data[1],
+    gid => $data[2],
+    members => $data[3],
+  );
 }
 
 sub rm_group {
-   my ($self, $group) = @_;
+  my ($self, $group) = @_;
 
-   i_run "/usr/sbin/groupdel $group";
-   if($? != 0) {
-      die("Error deleting group $group");
-   }
+  i_run "/usr/sbin/groupdel $group";
+  if($? != 0) {
+    die("Error deleting group $group");
+  }
 }
 
 
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::User::NetBSD;
 
 use strict;
@@ -22,156 +22,156 @@ use Rex::Helper::Path;
 use base qw(Rex::User::Linux);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub create_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   my $cmd;
+  my $cmd;
 
 
-   if(! defined $self->get_uid($user)) {
-      Rex::Logger::debug("User $user does not exists. Creating it now.");
-      $cmd = "useradd ";
+  if(! defined $self->get_uid($user)) {
+    Rex::Logger::debug("User $user does not exists. Creating it now.");
+    $cmd = "useradd ";
 
-      if(exists $data->{system}) {
-         $cmd .= " -r";
-      }
-   }
-   else {
-      Rex::Logger::debug("User $user already exists. Updating...");
-
-      $cmd = "usermod ";
-   }
-
-   if(exists $data->{uid}) {
-      $cmd .= " -u " . $data->{uid};
-   }
-
-   if(exists $data->{home}) {
-      $cmd .= " -d " . $data->{home};
-
-      if(
-         ! (
-            (exists $data->{"no-create-home"} && $data->{"no-create-home"})
-               ||
-            (exists $data->{"no_create_home"} && $data->{"no_create_home"})
-         )
-        ) {
-         if(! $self->get_uid($user)) {
-            $cmd .= " -m ";
-         }
+    if(exists $data->{system}) {
+      $cmd .= " -r";
+    }
+  }
+  else {
+    Rex::Logger::debug("User $user already exists. Updating...");
+
+    $cmd = "usermod ";
+  }
+
+  if(exists $data->{uid}) {
+    $cmd .= " -u " . $data->{uid};
+  }
+
+  if(exists $data->{home}) {
+    $cmd .= " -d " . $data->{home};
+
+    if(
+      ! (
+        (exists $data->{"no-create-home"} && $data->{"no-create-home"})
+          ||
+        (exists $data->{"no_create_home"} && $data->{"no_create_home"})
+      )
+      ) {
+      if(! $self->get_uid($user)) {
+        $cmd .= " -m ";
       }
-   }
+    }
+  }
 
-   if(exists $data->{shell}) {
-      $cmd .= " -s " . $data->{shell};
-   }
+  if(exists $data->{shell}) {
+    $cmd .= " -s " . $data->{shell};
+  }
 
-   if(exists $data->{comment}) {
-      $cmd .= " -c '" . $data->{comment} . "'";
-   }
+  if(exists $data->{comment}) {
+    $cmd .= " -c '" . $data->{comment} . "'";
+  }
 
-   if(exists $data->{expire}) {
-      $cmd .= " -e '" . $data->{expire} . "'";
-   }
+  if(exists $data->{expire}) {
+    $cmd .= " -e '" . $data->{expire} . "'";
+  }
 
-   if(exists $data->{groups}) {
-      my @groups = @{$data->{groups}};
-      my $pri_group = shift @groups;
+  if(exists $data->{groups}) {
+    my @groups = @{$data->{groups}};
+    my $pri_group = shift @groups;
 
-      $cmd .= " -g $pri_group";
+    $cmd .= " -g $pri_group";
 
-      if(@groups) {
-         $cmd .= " -G " . join(",", @groups);
-      }
-   }
+    if(@groups) {
+      $cmd .= " -G " . join(",", @groups);
+    }
+  }
  
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write("$cmd $user\nexit \$?\n");
-   $fh->close;
-
-   i_run "/bin/sh $rnd_file";
-   if($? == 0) {
-      Rex::Logger::debug("User $user created/updated.");
-   }
-   else {
-      Rex::Logger::info("Error creating/updating user $user", "warn");
-      die("Error creating/updating user $user");
-   }
-
-   Rex::Interface::Fs->create()->unlink($rnd_file);
-
-   if(exists $data->{password}) {
-      Rex::Logger::debug("Changing password of $user.");
-
-      $rnd_file = get_tmp_file;
-      $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("usermod -p \$(pwhash '" . $data->{password} . "') $user\nexit \$?\n");
-      $fh->close;
-
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
-
-      Rex::Interface::Fs->create()->unlink($rnd_file);
-   }
-
-   if(exists $data->{crypt_password}) {
-      Rex::Logger::debug("Setting encrypted password of $user");
-
-      $rnd_file = get_tmp_file;
-      $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("usermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
-      $fh->close;
-
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
-
-      Rex::Interface::Fs->create()->unlink($rnd_file);
-   }
-
-   return $self->get_uid($user);
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write("$cmd $user\nexit \$?\n");
+  $fh->close;
+
+  i_run "/bin/sh $rnd_file";
+  if($? == 0) {
+    Rex::Logger::debug("User $user created/updated.");
+  }
+  else {
+    Rex::Logger::info("Error creating/updating user $user", "warn");
+    die("Error creating/updating user $user");
+  }
+
+  Rex::Interface::Fs->create()->unlink($rnd_file);
+
+  if(exists $data->{password}) {
+    Rex::Logger::debug("Changing password of $user.");
+
+    $rnd_file = get_tmp_file;
+    $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("usermod -p \$(pwhash '" . $data->{password} . "') $user\nexit \$?\n");
+    $fh->close;
+
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+
+    Rex::Interface::Fs->create()->unlink($rnd_file);
+  }
+
+  if(exists $data->{crypt_password}) {
+    Rex::Logger::debug("Setting encrypted password of $user");
+
+    $rnd_file = get_tmp_file;
+    $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("usermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
+    $fh->close;
+
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+
+    Rex::Interface::Fs->create()->unlink($rnd_file);
+  }
+
+  return $self->get_uid($user);
 
 }
 
 sub rm_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   Rex::Logger::debug("Removing user $user");
+  Rex::Logger::debug("Removing user $user");
 
-   my %user_info = $self->get_user($user);
+  my %user_info = $self->get_user($user);
 
-   my $cmd = "userdel";
+  my $cmd = "userdel";
 
-   if(exists $data->{delete_home}) {
-      $cmd .= " -r";
-   }
+  if(exists $data->{delete_home}) {
+    $cmd .= " -r";
+  }
 
-   i_run $cmd . " " . $user;
+  i_run $cmd . " " . $user;
 
-   if(exists $data->{delete_home} && is_dir($user_info{home})) {
-      Rex::Logger::debug("userdel doesn't deleted home. removing it now by hand...");
-      rmdir $user_info{home};  
-   }
+  if(exists $data->{delete_home} && is_dir($user_info{home})) {
+    Rex::Logger::debug("userdel doesn't deleted home. removing it now by hand...");
+    rmdir $user_info{home};  
+  }
 
-   if($? != 0) {
-      die("Error deleting user $user");
-   }
+  if($? != 0) {
+    die("Error deleting user $user");
+  }
 
 }
 
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::User::OpenBSD;
 
 use strict;
@@ -23,129 +23,129 @@ use Rex::Helper::Path;
 use base qw(Rex::User::NetBSD);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub create_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   my $cmd;
+  my $cmd;
 
 
-   if(! defined $self->get_uid($user)) {
-      Rex::Logger::debug("User $user does not exists. Creating it now.");
-      $cmd = "useradd ";
+  if(! defined $self->get_uid($user)) {
+    Rex::Logger::debug("User $user does not exists. Creating it now.");
+    $cmd = "useradd ";
 
-      if(exists $data->{system}) {
-         $cmd .= " -r";
-      }
-   }
-   else {
-      Rex::Logger::debug("User $user already exists. Updating...");
-
-      $cmd = "usermod ";
-   }
-
-   if(exists $data->{uid}) {
-      $cmd .= " -u " . $data->{uid};
-   }
-
-   if(exists $data->{home}) {
-      $cmd .= " -d " . $data->{home};
-
-      if(
-         ! (
-            (exists $data->{"no-create-home"} && $data->{"no-create-home"})
-               ||
-            (exists $data->{"no_create_home"} && $data->{"no_create_home"})
-         )
-        ) {
-         if(!$self->get_uid($user)) {
-            $cmd .= " -m ";
-         }
-      }
-   }
-
-   if(exists $data->{shell}) {
-      $cmd .= " -s " . $data->{shell};
-   }
-
-   if(exists $data->{comment}) {
-      $cmd .= " -c '" . $data->{comment} . "'";
-   }
+    if(exists $data->{system}) {
+      $cmd .= " -r";
+    }
+  }
+  else {
+    Rex::Logger::debug("User $user already exists. Updating...");
 
-   if(exists $data->{expire}) {
-      $cmd .= " -e '" . $data->{expire} . "'";
-   }
+    $cmd = "usermod ";
+  }
 
-   if(exists $data->{groups}) {
-      my @groups = @{$data->{groups}};
-      my $pri_group = shift @groups;
+  if(exists $data->{uid}) {
+    $cmd .= " -u " . $data->{uid};
+  }
 
-      $cmd .= " -g $pri_group";
+  if(exists $data->{home}) {
+    $cmd .= " -d " . $data->{home};
 
-      if(@groups) {
-         $cmd .= " -G " . join(",", @groups);
-      }
-   }
- 
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write("$cmd $user\nexit \$?\n");
-   $fh->close;
-
-   i_run "/bin/sh $rnd_file";
-   if($? == 0) {
-      Rex::Logger::debug("User $user created/updated.");
-   }
-   else {
-      Rex::Logger::info("Error creating/updating user $user", "warn");
-      die("Error creating/updating user $user");
-   }
-
-   Rex::Interface::Fs->create()->unlink($rnd_file);
-
-   if(exists $data->{password}) {
-      Rex::Logger::debug("Changing password of $user.");
-      $rnd_file = get_tmp_file;
-      $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("usermod -p \$(encrypt -b 6 '" . $data->{password} . "') $user\nexit \$?\n");
-      $fh->close;
-
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
+    if(
+      ! (
+        (exists $data->{"no-create-home"} && $data->{"no-create-home"})
+          ||
+        (exists $data->{"no_create_home"} && $data->{"no_create_home"})
+      )
+      ) {
+      if(!$self->get_uid($user)) {
+        $cmd .= " -m ";
       }
+    }
+  }
 
-      Rex::Interface::Fs->create()->unlink($rnd_file);
-   }
+  if(exists $data->{shell}) {
+    $cmd .= " -s " . $data->{shell};
+  }
 
-   if(exists $data->{crypt_password}) {
-      Rex::Logger::debug("Setting encrypted password of $user");
-      $rnd_file = get_tmp_file;
-      $fh = Rex::Interface::File->create;
-      $fh->open(">", $rnd_file);
-      $fh->write("usermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
-      $fh->close;
+  if(exists $data->{comment}) {
+    $cmd .= " -c '" . $data->{comment} . "'";
+  }
 
-      i_run "/bin/sh $rnd_file";
-      if($? != 0) {
-         die("Error setting password for $user");
-      }
+  if(exists $data->{expire}) {
+    $cmd .= " -e '" . $data->{expire} . "'";
+  }
 
-      Rex::Interface::Fs->create()->unlink($rnd_file);
-   }
+  if(exists $data->{groups}) {
+    my @groups = @{$data->{groups}};
+    my $pri_group = shift @groups;
 
+    $cmd .= " -g $pri_group";
 
-   return $self->get_uid($user);
+    if(@groups) {
+      $cmd .= " -G " . join(",", @groups);
+    }
+  }
+ 
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write("$cmd $user\nexit \$?\n");
+  $fh->close;
+
+  i_run "/bin/sh $rnd_file";
+  if($? == 0) {
+    Rex::Logger::debug("User $user created/updated.");
+  }
+  else {
+    Rex::Logger::info("Error creating/updating user $user", "warn");
+    die("Error creating/updating user $user");
+  }
+
+  Rex::Interface::Fs->create()->unlink($rnd_file);
+
+  if(exists $data->{password}) {
+    Rex::Logger::debug("Changing password of $user.");
+    $rnd_file = get_tmp_file;
+    $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("usermod -p \$(encrypt -b 6 '" . $data->{password} . "') $user\nexit \$?\n");
+    $fh->close;
+
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+
+    Rex::Interface::Fs->create()->unlink($rnd_file);
+  }
+
+  if(exists $data->{crypt_password}) {
+    Rex::Logger::debug("Setting encrypted password of $user");
+    $rnd_file = get_tmp_file;
+    $fh = Rex::Interface::File->create;
+    $fh->open(">", $rnd_file);
+    $fh->write("usermod -p '" . $data->{crypt_password} . "' $user\nexit \$?\n");
+    $fh->close;
+
+    i_run "/bin/sh $rnd_file";
+    if($? != 0) {
+      die("Error setting password for $user");
+    }
+
+    Rex::Interface::Fs->create()->unlink($rnd_file);
+  }
+
+
+  return $self->get_uid($user);
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::User::OpenWrt;
@@ -23,65 +23,65 @@ use Rex::User::Linux;
 use base qw(Rex::User::Linux);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub get_user {
-   my ($self, $user) = @_;
-
-   Rex::Logger::debug("Getting information for $user");
-   my $o_data = i_run "perl -e 'print join(\";\", getpwnam(\"$user\"))'";
-   chomp $o_data;
-   my @data = split(/;/, $o_data);
-
-   return (
-      name => $data[0],
-      password => $data[1],
-      uid => $data[2],
-      gid => $data[3],
-      comment => $data[6],
-      home => $data[7],
-      shell => $data[8],
-   );
+  my ($self, $user) = @_;
+
+  Rex::Logger::debug("Getting information for $user");
+  my $o_data = i_run "perl -e 'print join(\";\", getpwnam(\"$user\"))'";
+  chomp $o_data;
+  my @data = split(/;/, $o_data);
+
+  return (
+    name => $data[0],
+    password => $data[1],
+    uid => $data[2],
+    gid => $data[3],
+    comment => $data[6],
+    home => $data[7],
+    shell => $data[8],
+  );
 }
 
 sub user_groups {
-   my ($self, $user) = @_;
+  my ($self, $user) = @_;
 
-   Rex::Logger::debug("Getting group membership of $user");
+  Rex::Logger::debug("Getting group membership of $user");
 
-   my $data_str = i_run "/usr/bin/id -Gn $user";
-   if($? != 0) {
-      die("Error getting group list");
-   }
+  my $data_str = i_run "/usr/bin/id -Gn $user";
+  if($? != 0) {
+    die("Error getting group list");
+  }
 
-   my $wantarray = wantarray();
+  my $wantarray = wantarray();
 
-   if(defined $wantarray && ! $wantarray) {
-      # arrayref
-      return [ split(/ /, $data_str) ];
-   }
+  if(defined $wantarray && ! $wantarray) {
+    # arrayref
+    return [ split(/ /, $data_str) ];
+  }
 
-   return split(/ /, $data_str);
+  return split(/ /, $data_str);
 }
 
 sub user_list {
-   my $self = shift;
+  my $self = shift;
 
-   Rex::Logger::debug("Getting user list");
+  Rex::Logger::debug("Getting user list");
 
-   my $data_str = i_run "cut -d':' -f1 /etc/passwd";
-   if($? != 0) {
-      die("Error getting user list");
-   }
+  my $data_str = i_run "cut -d':' -f1 /etc/passwd";
+  if($? != 0) {
+    die("Error getting user list");
+  }
 
-   return split(/\n/, $data_str);
+  return split(/\n/, $data_str);
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::User::SunOS;
 
 use strict;
@@ -24,116 +24,116 @@ use Rex::Helper::Path;
 use base qw(Rex::User::OpenBSD);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = $that->SUPER::new(@_);
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = $that->SUPER::new(@_);
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub create_user {
-   my ($self, $user, $data) = @_;
+  my ($self, $user, $data) = @_;
 
-   my $cmd;
+  my $cmd;
 
 
-   if(! defined $self->get_uid($user)) {
-      Rex::Logger::debug("User $user does not exists. Creating it now.");
-      $cmd = "useradd ";
+  if(! defined $self->get_uid($user)) {
+    Rex::Logger::debug("User $user does not exists. Creating it now.");
+    $cmd = "useradd ";
 
-      if(exists $data->{system}) {
-         $cmd .= " -r";
-      }
-   }
-   else {
-      Rex::Logger::debug("User $user already exists. Updating...");
-
-      $cmd = "usermod ";
-   }
-
-   if(exists $data->{uid}) {
-      $cmd .= " -u " . $data->{uid};
-   }
-
-   if(exists $data->{home}) {
-      $cmd .= " -d " . $data->{home};
-
-      if(
-         ! (
-            (exists $data->{"no-create-home"} && $data->{"no-create-home"})
-               ||
-            (exists $data->{"no_create_home"} && $data->{"no_create_home"})
-         )
-        ) {
-         if(! $self->get_uid($user)) {
-            $cmd .= " -m ";
-         }
+    if(exists $data->{system}) {
+      $cmd .= " -r";
+    }
+  }
+  else {
+    Rex::Logger::debug("User $user already exists. Updating...");
+
+    $cmd = "usermod ";
+  }
+
+  if(exists $data->{uid}) {
+    $cmd .= " -u " . $data->{uid};
+  }
+
+  if(exists $data->{home}) {
+    $cmd .= " -d " . $data->{home};
+
+    if(
+      ! (
+        (exists $data->{"no-create-home"} && $data->{"no-create-home"})
+          ||
+        (exists $data->{"no_create_home"} && $data->{"no_create_home"})
+      )
+      ) {
+      if(! $self->get_uid($user)) {
+        $cmd .= " -m ";
       }
-   }
+    }
+  }
 
-   if(exists $data->{shell}) {
-      $cmd .= " -s " . $data->{shell};
-   }
+  if(exists $data->{shell}) {
+    $cmd .= " -s " . $data->{shell};
+  }
 
-   if(exists $data->{comment}) {
-      $cmd .= " -c '" . $data->{comment} . "'";
-   }
+  if(exists $data->{comment}) {
+    $cmd .= " -c '" . $data->{comment} . "'";
+  }
 
-   if(exists $data->{expire}) {
-      $cmd .= " -e '" . $data->{expire} . "'";
-   }
+  if(exists $data->{expire}) {
+    $cmd .= " -e '" . $data->{expire} . "'";
+  }
 
-   if(exists $data->{groups}) {
-      my @groups = @{$data->{groups}};
-      my $pri_group = shift @groups;
+  if(exists $data->{groups}) {
+    my @groups = @{$data->{groups}};
+    my $pri_group = shift @groups;
 
-      $cmd .= " -g $pri_group";
+    $cmd .= " -g $pri_group";
 
-      if(@groups) {
-         $cmd .= " -G " . join(",", @groups);
-      }
-   }
+    if(@groups) {
+      $cmd .= " -G " . join(",", @groups);
+    }
+  }
  
-   my $rnd_file = get_tmp_file;
-   my $fh = Rex::Interface::File->create;
-   $fh->open(">", $rnd_file);
-   $fh->write("$cmd $user\nexit \$?\n");
-   $fh->close;
-
-   i_run "/bin/sh $rnd_file";
-   if($? == 0) {
-      Rex::Logger::debug("User $user created/updated.");
-   }
-   else {
-      Rex::Logger::info("Error creating/updating user $user", "warn");
-      die("Error creating/updating user $user");
-   }
-
-   Rex::Interface::Fs->create()->unlink($rnd_file);
-
-   if(exists $data->{password}) {
-      my $expect_path;
-
-      if(can_run("/usr/local/bin/expect")) {
-         $expect_path = "/usr/local/bin/expect";
-      }
-      elsif(can_run("/usr/bin/expect")) {
-         $expect_path = "/usr/bin/expect";
-      }
-
-      if($expect_path) {
-         my $chpasswd_file = get_tmp_file;
-         my $fh = file_write $chpasswd_file;
-         $fh->write(qq~#!$expect_path --
+  my $rnd_file = get_tmp_file;
+  my $fh = Rex::Interface::File->create;
+  $fh->open(">", $rnd_file);
+  $fh->write("$cmd $user\nexit \$?\n");
+  $fh->close;
+
+  i_run "/bin/sh $rnd_file";
+  if($? == 0) {
+    Rex::Logger::debug("User $user created/updated.");
+  }
+  else {
+    Rex::Logger::info("Error creating/updating user $user", "warn");
+    die("Error creating/updating user $user");
+  }
+
+  Rex::Interface::Fs->create()->unlink($rnd_file);
+
+  if(exists $data->{password}) {
+    my $expect_path;
+
+    if(can_run("/usr/local/bin/expect")) {
+      $expect_path = "/usr/local/bin/expect";
+    }
+    elsif(can_run("/usr/bin/expect")) {
+      $expect_path = "/usr/bin/expect";
+    }
+
+    if($expect_path) {
+      my $chpasswd_file = get_tmp_file;
+      my $fh = file_write $chpasswd_file;
+      $fh->write(qq~#!$expect_path --
 # Input: username password
 set USER [lindex \$argv 0]
 set PASS [lindex \$argv 1] 
 
 if { \$USER == "" || \$PASS == "" }  {
-   puts "Usage:  /tmp/chpasswd username password\n"
-   exit 1
+  puts "Usage:  /tmp/chpasswd username password\n"
+  exit 1
  }
 
 spawn passwd \$USER 
@@ -143,27 +143,27 @@ expect "assword:"
 send "\$PASS\r"
 expect eof
 ~);
-         $fh->close;
-
-         $rnd_file = get_tmp_file;
-         $fh = Rex::Interface::File->create;
-         $fh->open(">", $rnd_file);
-         $fh->write("$chpasswd_file $user '" . $data->{"password"} . "'\nexit \$?\n");
-         $fh->close;
-
-         chmod 700, $chpasswd_file;
-         i_run "/bin/sh $rnd_file";
-         if($? != 0) { die("Error changing user's password."); }
-
-         rm $chpasswd_file;
-         rm $rnd_file;
-      }
-      else {
-         die("No expect found in /usr/local/bin or /usr/bin. Can't set user password.");
-      }
-   }
-
-   return $self->get_uid($user);
+      $fh->close;
+
+      $rnd_file = get_tmp_file;
+      $fh = Rex::Interface::File->create;
+      $fh->open(">", $rnd_file);
+      $fh->write("$chpasswd_file $user '" . $data->{"password"} . "'\nexit \$?\n");
+      $fh->close;
+
+      chmod 700, $chpasswd_file;
+      i_run "/bin/sh $rnd_file";
+      if($? != 0) { die("Error changing user's password."); }
+
+      rm $chpasswd_file;
+      rm $rnd_file;
+    }
+    else {
+      die("No expect found in /usr/local/bin or /usr/bin. Can't set user password.");
+    }
+  }
+
+  return $self->get_uid($user);
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::User;
@@ -14,34 +14,34 @@ use Rex::Logger;
 
 sub get {
 
-   my $user_o = "Linux";
-   if(is_freebsd) {
-      $user_o = "FreeBSD";
-   }
-   elsif(is_netbsd) {
-      $user_o = "NetBSD";
-   }
-   elsif(is_openbsd) {
-      $user_o = "OpenBSD";
-   }
-   elsif(operating_system_is("SunOS")) {
-      $user_o = "SunOS";
-   }
-   elsif(is_openwrt) {
-      $user_o = "OpenWrt";
-   }
-
-   my $class = "Rex::User::" . $user_o;
-   eval "use $class";
-
-   if($@) {
-   
-      Rex::Logger::info("OS not supported");
-      die("OS not supported");
-   
-   }
-
-   return $class->new;
+  my $user_o = "Linux";
+  if(is_freebsd) {
+    $user_o = "FreeBSD";
+  }
+  elsif(is_netbsd) {
+    $user_o = "NetBSD";
+  }
+  elsif(is_openbsd) {
+    $user_o = "OpenBSD";
+  }
+  elsif(operating_system_is("SunOS")) {
+    $user_o = "SunOS";
+  }
+  elsif(is_openwrt) {
+    $user_o = "OpenWrt";
+  }
+
+  my $class = "Rex::User::" . $user_o;
+  eval "use $class";
+
+  if($@) {
+  
+    Rex::Logger::info("OS not supported");
+    die("OS not supported");
+  
+  }
+
+  return $class->new;
 
 }
 
@@ -1,29 +1,29 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 #
 # this is a simple helper class for the get() function
-   
+  
 package Rex::Value;
 
 use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub value {
-   my ($self) = @_;
-   return $self->{value};
+  my ($self) = @_;
+  return $self->{value};
 }
 
 1;
@@ -1,36 +1,36 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Virtualization::Base;
 
 use strict;
 use warnings;
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 sub execute {
-   my ($self, $action, $vmname, @opt) = @_;
+  my ($self, $action, $vmname, @opt) = @_;
 
-   my $mod = ref($self) . "::$action";
-   eval "use $mod;";
+  my $mod = ref($self) . "::$action";
+  eval "use $mod;";
 
-   if($@) {
-      Rex::Logger::info("No action $action available.");
-      die("No action $action available.");
-   }
+  if($@) {
+    Rex::Logger::info("No action $action available.");
+    die("No action $action available.");
+  }
 
-   return $mod->execute($vmname, @opt);
+  return $mod->execute($vmname, @opt);
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::create;
@@ -23,118 +23,118 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $name, %opt) = @_;
+  my ($class, $name, %opt) = @_;
 
-   my $opts = \%opt;
-   $opts->{name} = $name;
+  my $opts = \%opt;
+  $opts->{name} = $name;
 
-   unless($opts) {
-      die("You have to define the create options!");
-   }
+  unless($opts) {
+    die("You have to define the create options!");
+  }
 
-   if( ! exists $opts->{"image"} ) {
-      die("You have to set a base image.");
-   }
+  if( ! exists $opts->{"image"} ) {
+    die("You have to set a base image.");
+  }
 
-   if( ! exists $opts->{"command"} ) {
-      die("You have to define a command.");
-   }
+  if( ! exists $opts->{"command"} ) {
+    die("You have to define a command.");
+  }
 
-   my $options = _format_opts($opts);
+  my $options = _format_opts($opts);
 
-   my $id = i_run "docker run -d $options $opts->{'image'} $opts->{'command'}";
+  my $id = i_run "docker run -d $options $opts->{'image'} $opts->{'command'}";
 
-   return $id;
+  return $id;
 }
 
 sub _format_opts {
-   my ($opts) = @_;
-
-   # -name=""
-   # Assign the specified name to the container. If no name is specific docker will generate a random name
-   if( ! exists $opts->{"name"} ) {
-      die("You have to give a name.");
-   }
-
-   # -m=""
-   # Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
-   if( ! exists $opts->{"memory"} ) {
-      $opts->{"memory"} = '512m';
-   }
-   else {
-      $opts->{memory} = $opts->{memory};
-   }
-
-   # -c=0
-   # CPU shares (relative weight)
-   if( ! exists $opts->{"cpus"} ) {
-      $opts->{"cpus"} = 0;
-   }
-
-   my $str = "-name $opts->{'name'} -m $opts->{'memory'} -c $opts->{'cpus'} ";
-
-   # -e=[]
-   # Set environment variables
-   if( exists $opts->{"env"} ) {
-      $str .= '-e ' . join('-e ', @{ $opts->{'env'} }) . ' ';
-   }
-
-   # -h=""
-   # Container host name
-   if( exists $opts->{"hostname"} ) {
-      $str .= "-h $opts->{'hostname'} ";
-   }
-
-   # -privileged=false
-   # Give extended privileges to this container
-   if( exists $opts->{"privileged"} ) {
-      $str .= "-privileged $opts->{'privileged'} ";
-   }
-
-   # -p=[]
-   # Map a network port to the container
-   if( exists $opts->{"forward_port"} ) {
-      $str .= '-p ' . join('-p ', @{ $opts->{'forward_port'} }) . ' ';
-   }
-
-   # -expose=[]
-   # Expose a port from the container without publishing it to your host
-   if( exists $opts->{"expose_port"} ) {
-      $str .= "-expose $opts->{'expose_port'} ";
-   }
-
-   # -dns=[]
-   # Set custom dns servers for the container
-   if( exists $opts->{"dns"} ) {
-      $str .= '-dns ' . join('-dns ', @{ $opts->{'dns'} }) . ' ';
-   }
-
-   # -v=[]:
-   # Create a bind mount with: [host-dir]:[container-dir]:[rw|ro].
-   # If "container-dir" is missing, then docker creates a new volume.
-   if( exists $opts->{"share_folder"} ) {
-      $str .= '-v ' . join('-v ', @{ $opts->{'share_folder'} }) . ' ';
-   }
-
-   # -volumes-from=""
-   # Mount all volumes from the given container(s)
-   if( exists $opts->{"volumes-from"} ) {
-      $str .= "-volumes-from \"$opts->{'volumes-from'}\" ";
-   }
-
-   # -lxc-conf=[]
-   # Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
-   if( exists $opts->{"lxc-conf"} ) {
-      $str .= "-lxc-conf \"$opts->{'lxc-conf'}\" ";
-   }
-
-   # -link=""
-   # Add link to another container (name:alias)
-   if( exists $opts->{"link"} ) {
-      $str .= '-link ' . join('-link ', @{ $opts->{'linke'} }) . ' ';
-   }
-
-   return $str;
+  my ($opts) = @_;
+
+  # -name=""
+  # Assign the specified name to the container. If no name is specific docker will generate a random name
+  if( ! exists $opts->{"name"} ) {
+    die("You have to give a name.");
+  }
+
+  # -m=""
+  # Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
+  if( ! exists $opts->{"memory"} ) {
+    $opts->{"memory"} = '512m';
+  }
+  else {
+    $opts->{memory} = $opts->{memory};
+  }
+
+  # -c=0
+  # CPU shares (relative weight)
+  if( ! exists $opts->{"cpus"} ) {
+    $opts->{"cpus"} = 0;
+  }
+
+  my $str = "-name $opts->{'name'} -m $opts->{'memory'} -c $opts->{'cpus'} ";
+
+  # -e=[]
+  # Set environment variables
+  if( exists $opts->{"env"} ) {
+    $str .= '-e ' . join('-e ', @{ $opts->{'env'} }) . ' ';
+  }
+
+  # -h=""
+  # Container host name
+  if( exists $opts->{"hostname"} ) {
+    $str .= "-h $opts->{'hostname'} ";
+  }
+
+  # -privileged=false
+  # Give extended privileges to this container
+  if( exists $opts->{"privileged"} ) {
+    $str .= "-privileged $opts->{'privileged'} ";
+  }
+
+  # -p=[]
+  # Map a network port to the container
+  if( exists $opts->{"forward_port"} ) {
+    $str .= '-p ' . join('-p ', @{ $opts->{'forward_port'} }) . ' ';
+  }
+
+  # -expose=[]
+  # Expose a port from the container without publishing it to your host
+  if( exists $opts->{"expose_port"} ) {
+    $str .= "-expose $opts->{'expose_port'} ";
+  }
+
+  # -dns=[]
+  # Set custom dns servers for the container
+  if( exists $opts->{"dns"} ) {
+    $str .= '-dns ' . join('-dns ', @{ $opts->{'dns'} }) . ' ';
+  }
+
+  # -v=[]:
+  # Create a bind mount with: [host-dir]:[container-dir]:[rw|ro].
+  # If "container-dir" is missing, then docker creates a new volume.
+  if( exists $opts->{"share_folder"} ) {
+    $str .= '-v ' . join('-v ', @{ $opts->{'share_folder'} }) . ' ';
+  }
+
+  # -volumes-from=""
+  # Mount all volumes from the given container(s)
+  if( exists $opts->{"volumes-from"} ) {
+    $str .= "-volumes-from \"$opts->{'volumes-from'}\" ";
+  }
+
+  # -lxc-conf=[]
+  # Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
+  if( exists $opts->{"lxc-conf"} ) {
+    $str .= "-lxc-conf \"$opts->{'lxc-conf'}\" ";
+  }
+
+  # -link=""
+  # Add link to another container (name:alias)
+  if( exists $opts->{"link"} ) {
+    $str .= '-link ' . join('-link ', @{ $opts->{'linke'} }) . ' ';
+  }
+
+  return $str;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::start;
@@ -13,17 +13,17 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, %opt) = @_;
+  my ($class, %opt) = @_;
 
-   my $bind = $opt{bind} // '0.0.0.0';
-   my $host = $opt{host} // 'unix:///var/run/docker.sock';
+  my $bind = $opt{bind} // '0.0.0.0';
+  my $host = $opt{host} // 'unix:///var/run/docker.sock';
 
-   Rex::Logger::debug("starting docker daemon");
+  Rex::Logger::debug("starting docker daemon");
 
-   i_run "docker -d -H $host -ip $bind";
-   if($? != 0) {
-      die("Error starting docker daemon");
-   }
+  i_run "docker -d -H $host -ip $bind";
+  if($? != 0) {
+    die("Error starting docker daemon");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::delete;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the container ID!");
-   }
+  unless($arg1) {
+    die("You have to define the container ID!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("deleteing container $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("deleteing container $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "docker rm \"$dom\"";
-   if($? != 0) {
-      die("Error deleteing container $dom");
-   }
+  i_run "docker rm \"$dom\"";
+  if($? != 0) {
+    die("Error deleteing container $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::destroy;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the container ID!");
-   }
+  unless($arg1) {
+    die("You have to define the container ID!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("destroying container $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("destroying container $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "docker kill \"$dom\"";
-   if($? != 0) {
-      die("Error destroying container $dom");
-   }
+  i_run "docker kill \"$dom\"";
+  if($? != 0) {
+    die("Error destroying container $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::info;
@@ -14,21 +14,21 @@ use Rex::Helper::Run;
 use JSON::XS;
 
 sub execute {
-   my ($class, $arg1) = @_;
-   my @dominfo;
+  my ($class, $arg1) = @_;
+  my @dominfo;
 
-   if ( ! $arg1 ) {
-      die('Must define container ID');
-   }
+  if ( ! $arg1 ) {
+    die('Must define container ID');
+  }
 
-   Rex::Logger::debug("Getting docker info by inspect");
+  Rex::Logger::debug("Getting docker info by inspect");
 
-   my $ret = i_run "docker inspect $arg1";
-   if($? != 0) {
-      die("Error running docker inspect");
-   }
+  my $ret = i_run "docker inspect $arg1";
+  if($? != 0) {
+    die("Error running docker inspect");
+  }
 
-   return decode_json($ret);
+  return decode_json($ret);
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::list;
@@ -13,40 +13,40 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1) = @_;
-   my @domains;
-
-   Rex::Logger::debug("Getting docker list by ps");
-
-   if($arg1 eq "all") {
-      @domains = i_run "docker ps -a";
-      if($? != 0) {
-         die("Error running docker ps");
-      }
-   } elsif($arg1 eq "running") {
-      @domains = i_run "docker ps";
-      if($? != 0) {
-         die("Error running docker ps");
-      }
-   } else {
-      return;
-   }
-
-   my @ret = ();
-   for my $line (@domains) {
-      next if $line =~ m/^CONTAINER ID\s/;
-      my ($id, $images, $cmd, $created, $status, $comment) = split(/\s{2,}/, $line);
-      push( @ret, {
-         comment => $comment,
-         id      => $id,
-         images  => $images,
-         command => $cmd,
-         created => $created,
-         status  => $status,
-      });
-   } 
-
-   return \@ret;
+  my ($class, $arg1) = @_;
+  my @domains;
+
+  Rex::Logger::debug("Getting docker list by ps");
+
+  if($arg1 eq "all") {
+    @domains = i_run "docker ps -a";
+    if($? != 0) {
+      die("Error running docker ps");
+    }
+  } elsif($arg1 eq "running") {
+    @domains = i_run "docker ps";
+    if($? != 0) {
+      die("Error running docker ps");
+    }
+  } else {
+    return;
+  }
+
+  my @ret = ();
+  for my $line (@domains) {
+    next if $line =~ m/^CONTAINER ID\s/;
+    my ($id, $images, $cmd, $created, $status, $comment) = split(/\s{2,}/, $line);
+    push( @ret, {
+      comment => $comment,
+      id    => $id,
+      images  => $images,
+      command => $cmd,
+      created => $created,
+      status  => $status,
+    });
+  } 
+
+  return \@ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::reboot;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the container name!");
-   }
+  unless($arg1) {
+    die("You have to define the container name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("rebooting container $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("rebooting container $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "docker restart \"$dom\"";
-   if($? != 0) {
-      die("Error rebooting container $dom");
-   }
+  i_run "docker restart \"$dom\"";
+  if($? != 0) {
+    die("Error rebooting container $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::shutdown;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the container ID!");
-   }
+  unless($arg1) {
+    die("You have to define the container ID!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("shutdowning container $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("shutdowning container $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "docker stop \"$dom\"";
-   if($? != 0) {
-      die("Error shutdowning container $dom");
-   }
+  i_run "docker stop \"$dom\"";
+  if($? != 0) {
+    die("Error shutdowning container $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::Docker::start;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the container name!");
-   }
+  unless($arg1) {
+    die("You have to define the container name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("starting container $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("starting container $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "docker start \"$dom\"";
-   if($? != 0) {
-      die("Error starting container $dom");
-   }
+  i_run "docker start \"$dom\"";
+  if($? != 0) {
+    die("Error starting container $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,35 +15,35 @@ With this module you can manage Docker.
 =head1 SYNOPSIS
 
  use Rex::Commands::Virtualization;
-    
+   
  set virtualization => "Docker";
-    
- use Data::Dumper;   
    
+ use Data::Dumper;  
+  
  print Dumper vm list => "all";
  print Dumper vm list => "running";
-
+ 
  print Dumper vm info => "vm01";
-    
+   
  vm destroy => "vm01";
-    
+   
  vm delete => "vm01"; 
-     
- vm start => "vm01";
     
+ vm start => "vm01";
+   
  vm shutdown => "vm01";
-    
+   
  vm reboot => "vm01";
-    
+   
  # creating a vm 
  my $id = vm create => "vm01",
-      image => "ubuntu",
-      command => 'echo hello world',
-      memory => 512,
-      cpus => 1,
-      links => ['mysql:db'],
-      forward_port => [8080 => 80],
-      share_folder => ["hostdir" => "vmdir"],
+    image => "ubuntu",
+    command => 'echo hello world',
+    memory => 512,
+    cpus => 1,
+    links => ['mysql:db'],
+    forward_port => [8080 => 80],
+    share_folder => ["hostdir" => "vmdir"],
 
 =cut
 
@@ -57,13 +57,13 @@ use Rex::Virtualization::Base;
 use base qw(Rex::Virtualization::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::blklist;
@@ -16,52 +16,56 @@ use Rex::Helper::Run;
 use Data::Dumper;
 
 sub execute {
-   shift;
-   my $vmname = shift;
-   my %options = @_;
+  shift;
+  my $vmname        = shift;
+  my %options       = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   Rex::Logger::debug("Getting block list of domain: $vmname");
+  Rex::Logger::debug("Getting block list of domain: $vmname");
 
-   my @blklist = i_run "virsh domblklist $vmname --details";
+  my @blklist = i_run "virsh -c $uri domblklist $vmname --details";
 
-   if($? != 0) {
-      die("Error running virsh domblklist $vmname");
-   }
+  if ( $? != 0 ) {
+    die("Error running virsh domblklist $vmname");
+  }
 
-   my %ret = ();
-   my ($k, $v);
+  my %ret = ();
+  my ( $k, $v );
 
-   shift @blklist;
-   shift @blklist;
-   for my $line (@blklist) {
-      my ($type, $device, $target, $source) = split(/\s+/, $line);
-      $ret{$target} = {
-         type => $type,
-         device => $device,
-         source => $source
-      };
-   }
+  shift @blklist;
+  shift @blklist;
+  for my $line (@blklist) {
+    my ( $type, $device, $target, $source ) = split( /\s+/, $line );
+    $ret{$target} = {
+      type   => $type,
+      device => $device,
+      source => $source
+    };
+  }
 
-   if (%options) {
-      if ($options{details}) {
-         my $unit = $options{unit} || 1;
-         for my $target (keys %ret) {
-            my @infos = i_run "virsh domblkinfo $vmname $target 2>/dev/null";
-            if($? == 0) {
-               for my $line (@infos) {
-                  my ($k, $v) = split(/:\s+/, $line);
-                  $ret{$target}->{$k} = $v / $unit;
-               }
-            }
-         }
+  if (%options) {
+    if ( $options{details} ) {
+      my $unit = $options{unit} || 1;
+      for my $target ( keys %ret ) {
+        my @infos =
+          i_run "virsh -c $uri domblkinfo $vmname $target 2>/dev/null";
+        if ( $? == 0 ) {
+          for my $line (@infos) {
+            my ( $k, $v ) = split( /:\s+/, $line );
+            $ret{$target}->{$k} = $v / $unit;
+          }
+        }
       }
-   }
+    }
+  }
 
-   return \%ret;
+  return \%ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::clone;
@@ -18,17 +18,18 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $vmname, $newname) = @_;
+  my ( $class, $vmname, $newname ) = @_;
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   unless($newname) {
-      die("You have to define the new vm name!");
-   }
+  unless ($newname) {
+    die("You have to define the new vm name!");
+  }
 
-   i_run "/usr/bin/virt-clone --connect qemu:///system -o '$vmname' -n '$newname' --auto-clone";
+  i_run
+    "/usr/bin/virt-clone --connect qemu:///system -o '$vmname' -n '$newname' --auto-clone";
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::create;
@@ -26,358 +26,382 @@ use Rex::Virtualization::LibVirt::hypervisor;
 use Data::Dumper;
 
 my $QEMU_IMG;
-if(can_run("qemu-img")) {
-   $QEMU_IMG = "qemu-img";
+if ( can_run("qemu-img") ) {
+  $QEMU_IMG = "qemu-img";
 }
-elsif(can_run("qemu-img-xen")) {
-   $QEMU_IMG = "qemu-img-xen";
+elsif ( can_run("qemu-img-xen") ) {
+  $QEMU_IMG = "qemu-img-xen";
 }
 
 # read __DATA__ into an array
 my @data = <DATA>;
 
 sub execute {
-   my ($class, $name, %opt) = @_;
-
-   my $opts = \%opt;
-   $opts->{"name"} = $name;
-
-   unless($opts) {
-      die("You have to define the create options!");
-   }
-
-   ## detect the hypervisor caps
-   my $hypervisor = Rex::Virtualization::LibVirt::hypervisor->execute('capabilities');
-   my $virt_type = "unknown";
-
-   _set_defaults($opts, $hypervisor);
-
-   if(exists $hypervisor->{"kvm"}) {
-      $virt_type = "kvm";
-   }
-   elsif(exists $hypervisor->{"xen"}) {
-      $virt_type = "xen-" . $opts->{"type"};
-   }
-   else {
-      die("Hypervisor not supported.");
-   }
-
-   my $fp = Rex::File::Parser::Data->new(data => \@data);
-   my $create_xml = $fp->read("create-${virt_type}.xml");
-
-   my $template = Rex::Template->new;
-   my $parsed_template = $template->parse($create_xml, $opts);
-   
-   Rex::Logger::debug($parsed_template);
-
-   ## create storage devices
-   for (@{$opts->{'storage'}}) {
-      if(! exists $_->{"template"} && $_->{"size"} && $_->{"type"} eq "file") {
-         my $size = $_->{'size'};
-         if(!is_file($_->{"file"})) {
-            Rex::Logger::debug("creating storage disk: \"$_->{file}\"");            
-            i_run "$QEMU_IMG create -f raw $_->{'file'} $size";
-            if($? != 0) {
-               die("Error creating storage disk: $_->{'file'}");
-            }
-         }
-         else {
-            Rex::Logger::info("$_->{file} already exists. Using this.");
-         }
-      } elsif($_->{'template'} && $_->{'type'} eq "file") {
-          Rex::Logger::info("building domain: \"$opts->{'name'}\" from template: \"$_->{'template'}\"");
-          Rex::Logger::info("Please wait ...");
-          i_run "$QEMU_IMG convert -f raw $_->{'template'} -O raw $_->{'file'}";
-          if($? != 0) {
-             die("Error building domain: \"$opts->{'name'}\" from template: \"$_->{'template'}\"\n
-             Template doesn't exist or the qemu-img binary is missing")
-          }
+  my ( $class, $name, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  my $opts = \%opt;
+  $opts->{"name"} = $name;
+
+  unless ($opts) {
+    die("You have to define the create options!");
+  }
+
+  ## detect the hypervisor caps
+  my $hypervisor =
+    Rex::Virtualization::LibVirt::hypervisor->execute('capabilities');
+  my $virt_type = "unknown";
+
+  _set_defaults( $opts, $hypervisor );
+
+  if ( exists $hypervisor->{"kvm"} ) {
+    $virt_type = "kvm";
+  }
+  elsif ( exists $hypervisor->{"xen"} ) {
+    $virt_type = "xen-" . $opts->{"type"};
+  }
+  else {
+    die("Hypervisor not supported.");
+  }
+
+  my $fp = Rex::File::Parser::Data->new( data => \@data );
+  my $create_xml = $fp->read("create-${virt_type}.xml");
+
+  my $template = Rex::Template->new;
+  my $parsed_template = $template->parse( $create_xml, $opts );
+
+  Rex::Logger::debug($parsed_template);
+
+  ## create storage devices
+  for ( @{ $opts->{'storage'} } ) {
+
+    if ( !exists $_->{"template"} && $_->{"size"} && $_->{"type"} eq "file" ) {
+      my $size = $_->{'size'};
+      if ( !is_file( $_->{"file"} ) ) {
+        Rex::Logger::debug("creating storage disk: \"$_->{file}\"");
+        i_run "$QEMU_IMG create -f raw $_->{'file'} $size";
+        if ( $? != 0 ) {
+          die("Error creating storage disk: $_->{'file'}");
+        }
+      }
+      else {
+        Rex::Logger::info("$_->{file} already exists. Using this.");
+      }
+    }
+    elsif ( $_->{'template'} && $_->{'type'} eq "file" ) {
+      Rex::Logger::info(
+        "building domain: \"$opts->{'name'}\" from template: \"$_->{'template'}\""
+      );
+      Rex::Logger::info("Please wait ...");
+      i_run "$QEMU_IMG convert -f raw $_->{'template'} -O raw $_->{'file'}";
+      if ( $? != 0 ) {
+        die(
+          "Error building domain: \"$opts->{'name'}\" from template: \"$_->{'template'}\"\n
+             Template doesn't exist or the qemu-img binary is missing"
+        );
       }
-   } 
+    }
+    else {
+      Rex::Logger::info("$_->{file} already exists. Using this.");
+    }
+  }
 
-   Rex::Logger::info("creating domain: \"$opts->{'name'}\"");
+  Rex::Logger::info("creating domain: \"$opts->{'name'}\"");
 
-   $parsed_template =~ s/[\n\r]//gms;
+  $parsed_template =~ s/[\n\r]//gms;
 
-   my $file_name = get_tmp_file;
+  my $file_name = get_tmp_file;
 
-   file "$file_name",
-      content => $parsed_template;
+  file "$file_name", content => $parsed_template;
 
-   i_run "virsh define $file_name";
-   unlink($file_name);
-   if($? != 0) {
-     die("Error defining vm $opts->{name}");
-   }
+  i_run "virsh -c $uri define $file_name";
+  unlink($file_name);
+  if ( $? != 0 ) {
+    die("Error defining vm $opts->{name}");
+  }
 
-   return;
+  return;
 }
 
 sub _set_defaults {
-   my ($opts, $hyper) = @_;
+  my ( $opts, $hyper ) = @_;
 
-   if( ! exists $opts->{"name"} ) {
-      die("You have to give a name.");
-   }
+  if ( !exists $opts->{"name"} ) {
+    die("You have to give a name.");
+  }
 
-   if( ! exists $opts->{"storage"} ) {
-      die("You have to add at least one storage disk.");
-   }
+  if ( !exists $opts->{"storage"} ) {
+    die("You have to add at least one storage disk.");
+  }
 
-   if( ! exists $opts->{"type"} ) {
+  if ( !exists $opts->{"type"} ) {
 
-      if( exists $opts->{"os"} && exists $opts->{"os"}->{"kernel"} && ! exists $hyper->{"kvm"} ) {
-         $opts->{"type"} = "pvm";
-      }
-      else {
-         $opts->{"type"} = "hvm";
-      }
+    if ( exists $opts->{"os"}
+      && exists $opts->{"os"}->{"kernel"}
+      && !exists $hyper->{"kvm"} )
+    {
+      $opts->{"type"} = "pvm";
+    }
+    else {
+      $opts->{"type"} = "hvm";
+    }
 
-   }
+  }
 
-   if( ! exists $opts->{"memory"} ) {
-      $opts->{"memory"} = 512 * 1024;
-   }
+  if ( !exists $opts->{"memory"} ) {
+    $opts->{"memory"} = 512 * 1024;
+  }
 
-   if( ! exists $opts->{"cpus"} ) {
-      $opts->{"cpus"} = 1;
-   }
+  if ( !exists $opts->{"cpus"} ) {
+    $opts->{"cpus"} = 1;
+  }
 
-   if( ! exists $opts->{"clock"} ) {
-      $opts->{"clock"} = "utc";
-   }
+  if ( !exists $opts->{"clock"} ) {
+    $opts->{"clock"} = "utc";
+  }
 
-   if( ! exists $opts->{"arch"} ) {
-      if( exists $hyper->{"x86_64"} ) {
-         $opts->{"arch"} = "x86_64";
-      }
-      else {
-         $opts->{"arch"} = "i686";
-      }
-   }
+  if ( !exists $opts->{"arch"} ) {
+    if ( exists $hyper->{"x86_64"} ) {
+      $opts->{"arch"} = "x86_64";
+    }
+    else {
+      $opts->{"arch"} = "i686";
+    }
+  }
 
-   if( ! exists $opts->{"boot"} ) {
-      $opts->{"boot"} = "hd";
-   }
+  if ( !exists $opts->{"boot"} ) {
+    $opts->{"boot"} = "hd";
+  }
 
-   if( ! exists $opts->{"emulator"} ) {
-      $opts->{"emulator"} = $hyper->{"emulator"};
+  if ( !exists $opts->{"emulator"} ) {
+    $opts->{"emulator"} = $hyper->{"emulator"};
 
-      if(operating_system_is("Debian") && exists $hyper->{"xen"}) {
-         # fix for debian, because virsh capabilities don't give the correct
-         # emulator.
-         $opts->{"emulator"} = "/usr/lib/xen-4.0/bin/qemu-dm";
-      }
+    if ( operating_system_is("Debian") && exists $hyper->{"xen"} ) {
 
-   }
+      # fix for debian, because virsh capabilities don't give the correct
+      # emulator.
+      $opts->{"emulator"} = "/usr/lib/xen-4.0/bin/qemu-dm";
+    }
 
-   if(exists $hyper->{"loader"} && ! exists $opts->{"loader"}) {
-      $opts->{"loader"} = $hyper->{"loader"};
-   }
+  }
 
-   if( ! exists $opts->{"on_poweroff"} ) {
-      $opts->{"on_poweroff"} = "destroy";
-   }
+  if ( exists $hyper->{"loader"} && !exists $opts->{"loader"} ) {
+    $opts->{"loader"} = $hyper->{"loader"};
+  }
 
-   if( ! exists $opts->{"on_reboot"} ) {
-      $opts->{"on_reboot"} = "restart";
-   }
+  if ( !exists $opts->{"on_poweroff"} ) {
+    $opts->{"on_poweroff"} = "destroy";
+  }
 
-   if( ! exists $opts->{"on_crash"} ) {
-      $opts->{"on_crash"} = "restart";
-   }
+  if ( !exists $opts->{"on_reboot"} ) {
+    $opts->{"on_reboot"} = "restart";
+  }
 
-   if( exists $hyper->{"xen"} && $opts->{"type"} eq "pvm" ) {
+  if ( !exists $opts->{"on_crash"} ) {
+    $opts->{"on_crash"} = "restart";
+  }
 
-      if( ! exists $opts->{"os"}->{"type"} ) {
-         $opts->{"os"}->{"type"} = "linux";
-      }
+  if ( exists $hyper->{"xen"} && $opts->{"type"} eq "pvm" ) {
+
+    if ( !exists $opts->{"os"}->{"type"} ) {
+      $opts->{"os"}->{"type"} = "linux";
+    }
 
-      if( ! exists $opts->{"os"}->{"kernel"} ) {
-         my %hw = Rex::Hardware->get(qw/ Kernel /);
+    if ( !exists $opts->{"os"}->{"kernel"} ) {
+      my %hw = Rex::Hardware->get(qw/ Kernel /);
 
-         if(is_redhat()) {
-            $opts->{"os"}->{"kernel"} = "/boot/vmlinuz-" . $hw{"Kernel"}->{"kernelrelease"};
-         }
-         else {
-            $opts->{"os"}->{"kernel"} = "/boot/vmlinuz-" . $hw{"Kernel"}->{"kernelrelease"};
-         }
+      if ( is_redhat() ) {
+        $opts->{"os"}->{"kernel"} =
+          "/boot/vmlinuz-" . $hw{"Kernel"}->{"kernelrelease"};
       }
+      else {
+        $opts->{"os"}->{"kernel"} =
+          "/boot/vmlinuz-" . $hw{"Kernel"}->{"kernelrelease"};
+      }
+    }
 
-      if( ! exists $opts->{"os"}->{"initrd"} ) {
-         my %hw = Rex::Hardware->get(qw/ Kernel /);
+    if ( !exists $opts->{"os"}->{"initrd"} ) {
+      my %hw = Rex::Hardware->get(qw/ Kernel /);
 
-         if(is_redhat()) {
-            $opts->{"os"}->{"initrd"} = "/boot/initrd-" . $hw{"Kernel"}->{"kernelrelease"} . ".img";
-         }
-         else {
-            $opts->{"os"}->{"initrd"} = "/boot/initrd.img-" . $hw{"Kernel"}->{"kernelrelease"};
-         }
+      if ( is_redhat() ) {
+        $opts->{"os"}->{"initrd"} =
+          "/boot/initrd-" . $hw{"Kernel"}->{"kernelrelease"} . ".img";
       }
-
-      if( ! exists $opts->{"os"}->{"cmdline"} ) {
-         my @root_store = grep { $_->{"is_root"} && $_->{"is_root"} == 1 } @{ $opts->{"storage"} };
-         $opts->{"os"}->{"cmdline"} = "root=/dev/" . $root_store[0]->{"dev"} . " ro";
+      else {
+        $opts->{"os"}->{"initrd"} =
+          "/boot/initrd.img-" . $hw{"Kernel"}->{"kernelrelease"};
       }
+    }
 
-   }
+    if ( !exists $opts->{"os"}->{"cmdline"} ) {
+      my @root_store = grep { $_->{"is_root"} && $_->{"is_root"} == 1 }
+        @{ $opts->{"storage"} };
+      $opts->{"os"}->{"cmdline"} =
+        "root=/dev/" . $root_store[0]->{"dev"} . " ro";
+    }
 
-   _set_storage_defaults($opts, $hyper);
+  }
 
-   _set_network_defaults($opts, $hyper);
+  _set_storage_defaults( $opts, $hyper );
+
+  _set_network_defaults( $opts, $hyper );
 
 }
 
 sub _set_storage_defaults {
-   my ($opts, $hyper) = @_;
+  my ( $opts, $hyper ) = @_;
 
-   my $store_letter = "a";
-   for my $store ( @{ $opts->{"storage"} } ) {
+  my $store_letter = "a";
+  for my $store ( @{ $opts->{"storage"} } ) {
 
-      if( ! exists $store->{"type"} ) {
-         $store->{"type"} = "file";
-      }
+    if ( !exists $store->{"type"} ) {
+      $store->{"type"} = "file";
+    }
+
+    if ( !exists $store->{"driver_type"} ) {
+      $store->{"driver_type"} = "raw";
+    }
 
-      if( ! exists $store->{"driver_type"} ) {
-         $store->{"driver_type"} = "raw";
+    if ( !exists $store->{"size"} && $store->{"type"} eq "file" ) {
+
+      if ( $store->{"file"} =~ m/swap/ ) {
+        $store->{"size"} = "1G";
+      }
+      else {
+        $store->{"size"} = "10G";
       }
 
-      if( ! exists $store->{"size"} && $store->{"type"} eq "file" ) {
+    }
 
-         if($store->{"file"} =~ m/swap/) {
-            $store->{"size"} = "1G";
-         }
-         else {
-            $store->{"size"} = "10G";
-         }
+    if ( exists $store->{"file"}
+      && $store->{"file"} =~ m/\.iso$/
+      && !exists $store->{"device"} )
+    {
+      $store->{"device"} = "cdrom";
+    }
 
-      }
+    if ( !exists $store->{"device"} ) {
+      $store->{"device"} = "disk";
+    }
 
-      if( exists $store->{"file"} && $store->{"file"} =~ m/\.iso$/ && ! exists $store->{"device"} ) {
-         $store->{"device"} = "cdrom";
-      }
+    if ( !exists $store->{"dev"} && $store->{"device"} eq "cdrom" ) {
+      $store->{"dev"} = "hdc";
+    }
 
-      if( ! exists $store->{"device"} ) {
-         $store->{"device"} = "disk";
-      }
+    if ( !exists $store->{"dev"} ) {
 
-      if( ! exists $store->{"dev"} && $store->{"device"} eq "cdrom") {
-         $store->{"dev"} = "hdc"; 
+      if ( exists $hyper->{"kvm"} ) {
+        $store->{"dev"} = "vd${store_letter}";
+      }
+      else {
+        $store->{"dev"} = "hd${store_letter}";
       }
 
-      if( ! exists $store->{"dev"} ) {
+    }
 
-         if( exists $hyper->{"kvm"} ) {
-            $store->{"dev"} = "vd${store_letter}";
-         }
-         else {
-            $store->{"dev"} = "hd${store_letter}";
-         }
+    if ( !exists $store->{"bus"} ) {
 
+      if ( exists $hyper->{"kvm"} && $store->{"device"} eq "disk" ) {
+        $store->{"bus"} = "virtio";
+      }
+      else {
+        $store->{"bus"} = "ide";
       }
 
-      if( ! exists $store->{"bus"} ) {
+    }
 
-         if( exists $hyper->{"kvm"} && $store->{"device"} eq "disk" ) {
-            $store->{"bus"} = "virtio";
-         }
-         else {
-            $store->{"bus"} = "ide";
-         }
+    if ( exists $hyper->{"kvm"} ) {
 
+      if ( $store->{"bus"} eq "virtio" && !exists $store->{"address"} ) {
+        $store->{"address"} = {
+          type     => "pci",
+          domain   => "0x0000",
+          bus      => "0x00",
+          slot     => "0x05",
+          function => "0x0",
+        };
       }
-      
-      if( exists $hyper->{"kvm"} ) {
-         
-         if( $store->{"bus"} eq "virtio" && ! exists $store->{"address"} ) {
-            $store->{"address"} = {
-               type     => "pci",
-               domain   => "0x0000",
-               bus      => "0x00",
-               slot     => "0x05",
-               function => "0x0",
-            };
-         }
-         elsif( $store->{"bus"} eq "ide" && ! exists $store->{"address"} ) {
-            $store->{"address"} = {
-               type       => "drive",
-               controller => 0,
-               bus        => 1,
-               unit       => 0,
-            };
-         }
-
+      elsif ( $store->{"bus"} eq "ide" && !exists $store->{"address"} ) {
+        $store->{"address"} = {
+          type       => "drive",
+          controller => 0,
+          bus        => 1,
+          unit       => 0,
+        };
       }
 
-      if( $store->{"device"} eq "cdrom" ) {
-         $store->{"readonly"} = 1;
-      }
+    }
 
-      if( is_redhat() ) {
+    if ( $store->{"device"} eq "cdrom" ) {
+      $store->{"readonly"} = 1;
+    }
 
-         if( ! exists $store->{"aio"} ) {
-            $store->{"aio"} = 1;
-         }
+    if ( is_redhat() ) {
 
+      if ( !exists $store->{"aio"} ) {
+        $store->{"aio"} = 1;
       }
 
-      $store_letter++;
+    }
+
+    $store_letter++;
 
-   }
+  }
 
 }
 
 sub _set_network_defaults {
-   my ($opts, $hyper) = @_;
+  my ( $opts, $hyper ) = @_;
 
-   if( ! exists $opts->{"network"} ) {
-      $opts->{"network"} = [
-         {
-            type   => "bridge",
-            bridge => "virbr0",
-         },
-      ];
-   }
+  if ( !exists $opts->{"network"} ) {
+    $opts->{"network"} = [
+      {
+        type   => "bridge",
+        bridge => "virbr0",
+      },
+    ];
+  }
 
-   for my $netdev ( @{ $opts->{"network"} } ) {
+  for my $netdev ( @{ $opts->{"network"} } ) {
 
-      if( ! exists $netdev->{"type"} ) {
+    if ( !exists $netdev->{"type"} ) {
 
-         $netdev->{"type"} = "bridge";
+      $netdev->{"type"} = "bridge";
 
-      }
-
-      if( ! exists $netdev->{"bridge"} ) {
+    }
 
-         $netdev->{"bridge"} = "virbr0";
+    if ( !exists $netdev->{"bridge"} ) {
 
-      }
+      $netdev->{"bridge"} = "virbr0";
 
-      if( exists $hyper->{"kvm"} ) {
+    }
 
-         if( ! exists $netdev->{"model"} ) {
+    if ( exists $hyper->{"kvm"} ) {
 
-            $netdev->{"model"} = "virtio";
+      if ( !exists $netdev->{"model"} ) {
 
-         }
+        $netdev->{"model"} = "virtio";
 
-         if( ! exists $netdev->{"address"} ) {
+      }
 
-            $netdev->{"address"} = {
-               type     => "pci",
-               domain   => "0x0000",
-               bus      => "0x00",
-               slot     => "0x03",
-               function => "0x0",
-            };
+      if ( !exists $netdev->{"address"} ) {
 
-         }
+        $netdev->{"address"} = {
+          type     => "pci",
+          domain   => "0x0000",
+          bus      => "0x00",
+          slot     => "0x03",
+          function => "0x0",
+        };
 
       }
 
-   }
-}
+    }
 
+  }
+}
 
 1;
 
@@ -390,68 +414,68 @@ __DATA__
   <currentMemory><%= $::memory %></currentMemory>
   <vcpu><%= $::cpus %></vcpu>
   <os>
-    <type arch="<%= $::arch %>">hvm</type>
-    <boot dev="<%= $::boot %>"/>
+   <type arch="<%= $::arch %>">hvm</type>
+   <boot dev="<%= $::boot %>"/>
   </os>
   <features>
-    <acpi/>
-    <apic/>
-    <pae/>
+   <acpi/>
+   <apic/>
+   <pae/>
   </features>
   <clock offset="<%= $::clock %>"/>
   <on_poweroff><%= $::on_poweroff %></on_poweroff>
   <on_reboot><%= $::on_reboot %></on_reboot>
   <on_crash><%= $::on_crash %></on_crash>
   <devices>
-    <emulator><%= $::emulator %></emulator>
-
-    <% for my $disk (@{$::storage}) { %>
-    <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
-      <driver name="qemu" type="<%= $disk->{driver_type} %>"/>
-      <% if ($disk->{type} eq "file") { %>
-      <source file="<%= $disk->{file} %>"/>
-      <% } elsif ($disk->{file} eq "block") { %>
-      <source dev="<%= $disk->{file} %>"/>
-      <% } %>
-      <% if(exists $disk->{readonly}) { %>
-      <readonly/>
-      <% } %>
-      <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
-      <address <% for my $key (keys %{$disk->{address}}) { %> <%= $key %>="<%= $disk->{address}->{$key} %>" <% } %> />
-    </disk>
+   <emulator><%= $::emulator %></emulator>
+
+   <% for my $disk (@{$::storage}) { %>
+   <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
+    <driver name="qemu" type="<%= $disk->{driver_type} %>"/>
+    <% if ($disk->{type} eq "file") { %>
+    <source file="<%= $disk->{file} %>"/>
+    <% } elsif ($disk->{file} eq "block") { %>
+    <source dev="<%= $disk->{file} %>"/>
     <% } %>
-    <controller type="ide" index="0">
-      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
-    </controller>
-    <% for my $netdev (@{$::network}) { %>
-    <interface type="<%= $netdev->{type} %>">
-      <% if(exists $netdev->{mac}) { %>
-      <mac address='<%= $netdev->{mac} %>'/>
-      <% } %>
-      <% if($netdev->{type} eq "bridge") { %>
-      <source bridge="<%= $netdev->{bridge} %>"/>
-      <% } elsif($netdev->{type} eq "network") { %>
-      <source network="<%= $netdev->{network} %>"/>
-      <% } %>
-      <model type="<%= $netdev->{model} %>"/>
-      <address <% for my $key (keys %{$netdev->{address}}) { %> <%= $key %>="<%= $netdev->{address}->{$key} %>" <% } %> />
-    </interface>
+    <% if(exists $disk->{readonly}) { %>
+    <readonly/>
     <% } %>
-    <serial type="pty">
-      <target port="0"/>
-    </serial>
-    <console type="pty">
-      <target port="0"/>
-    </console>
-    <input type="mouse" bus="ps2"/>
-    <graphics type="vnc" autoport="yes" listen="*"/>
-    <video>
-      <model type="cirrus" vram="9216" heads="1"/>
-      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
-    </video>
-    <memballoon model="virtio">
-      <address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/>
-    </memballoon>
+    <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
+    <address <% for my $key (keys %{$disk->{address}}) { %> <%= $key %>="<%= $disk->{address}->{$key} %>" <% } %> />
+   </disk>
+   <% } %>
+   <controller type="ide" index="0">
+    <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
+   </controller>
+   <% for my $netdev (@{$::network}) { %>
+   <interface type="<%= $netdev->{type} %>">
+    <% if(exists $netdev->{mac}) { %>
+    <mac address='<%= $netdev->{mac} %>'/>
+    <% } %>
+    <% if($netdev->{type} eq "bridge") { %>
+    <source bridge="<%= $netdev->{bridge} %>"/>
+    <% } elsif($netdev->{type} eq "network") { %>
+    <source network="<%= $netdev->{network} %>"/>
+    <% } %>
+    <model type="<%= $netdev->{model} %>"/>
+    <address <% for my $key (keys %{$netdev->{address}}) { %> <%= $key %>="<%= $netdev->{address}->{$key} %>" <% } %> />
+   </interface>
+   <% } %>
+   <serial type="pty">
+    <target port="0"/>
+   </serial>
+   <console type="pty">
+    <target port="0"/>
+   </console>
+   <input type="mouse" bus="ps2"/>
+   <graphics type="vnc" autoport="yes" listen="*"/>
+   <video>
+    <model type="cirrus" vram="9216" heads="1"/>
+    <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
+   </video>
+   <memballoon model="virtio">
+    <address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/>
+   </memballoon>
   </devices>
 </domain>
 @end
@@ -463,54 +487,54 @@ __DATA__
   <currentMemory><%= $::memory %></currentMemory>
   <vcpu><%= $::cpus %></vcpu>
   <os>
-    <type>hvm</type>
-    <loader><%= $::loader %></loader>
-    <boot dev="<%= $::boot %>"/>
+   <type>hvm</type>
+   <loader><%= $::loader %></loader>
+   <boot dev="<%= $::boot %>"/>
   </os>
   <features>
-    <acpi/>
-    <apic/>
-    <pae/>
+   <acpi/>
+   <apic/>
+   <pae/>
   </features>
   <clock offset="<%= $::clock %>">
-    <timer name="hpet" present="no"/>
+   <timer name="hpet" present="no"/>
   </clock>
   <on_poweroff><%= $::on_poweroff %></on_poweroff>
   <on_reboot><%= $::on_reboot %></on_reboot>
   <on_crash><%= $::on_crash %></on_crash>
   <devices>
-    <emulator><%= $::emulator %></emulator>
-
-    <% for my $disk (@{$::storage}) { %>
-    <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
-      <% if(exists $disk->{file}) { %>
-      <driver name="file"/>
-      <source file="<%= $disk->{file} %>"/>
-      <% } %>
-      <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
-      <% if(exists $disk->{readonly}) { %>
-      <readonly/>
-      <% } %>
-    </disk>
+   <emulator><%= $::emulator %></emulator>
+
+   <% for my $disk (@{$::storage}) { %>
+   <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
+    <% if(exists $disk->{file}) { %>
+    <driver name="file"/>
+    <source file="<%= $disk->{file} %>"/>
+    <% } %>
+    <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
+    <% if(exists $disk->{readonly}) { %>
+    <readonly/>
     <% } %>
+   </disk>
+   <% } %>
 
-    <% for my $netdev (@{$::network}) { %>
-    <interface type="<%= $netdev->{type} %>">
-      <% if(exists $netdev->{mac}) { %>
-      <mac address='<%= $netdev->{mac} %>'/>
-      <% } %>
-      <% if($netdev->{type} eq "bridge") { %>
-      <source bridge="<%= $netdev->{bridge} %>"/>
-      <% } %>
-    </interface>
+   <% for my $netdev (@{$::network}) { %>
+   <interface type="<%= $netdev->{type} %>">
+    <% if(exists $netdev->{mac}) { %>
+    <mac address='<%= $netdev->{mac} %>'/>
     <% } %>
-    <graphics type="vnc" autoport="yes"/>
-    <serial type="pty">
-      <target port="0"/>
-    </serial>
-    <console type="pty">
-      <target port="0"/>
-    </console>
+    <% if($netdev->{type} eq "bridge") { %>
+    <source bridge="<%= $netdev->{bridge} %>"/>
+    <% } %>
+   </interface>
+   <% } %>
+   <graphics type="vnc" autoport="yes"/>
+   <serial type="pty">
+    <target port="0"/>
+   </serial>
+   <console type="pty">
+    <target port="0"/>
+   </console>
   </devices>
 </domain>
 @end
@@ -525,16 +549,16 @@ __DATA__
   <bootloader><%= $::bootloader %></bootloader>
   <% } %>
   <os>
-    <type><%= $::os->{type} %></type>
-    <% if(exists $::os->{kernel}) { %>
-    <kernel><%= $::os->{kernel} %></kernel>
-    <% } %>
-    <% if(exists $::os->{initrd}) { %>
-    <initrd><%= $::os->{initrd} %></initrd>
-    <% } %>
-    <% if(exists $::os->{cmdline}) { %>
-    <cmdline><%= $::os->{cmdline} %></cmdline>
-    <% } %>
+   <type><%= $::os->{type} %></type>
+   <% if(exists $::os->{kernel}) { %>
+   <kernel><%= $::os->{kernel} %></kernel>
+   <% } %>
+   <% if(exists $::os->{initrd}) { %>
+   <initrd><%= $::os->{initrd} %></initrd>
+   <% } %>
+   <% if(exists $::os->{cmdline}) { %>
+   <cmdline><%= $::os->{cmdline} %></cmdline>
+   <% } %>
   </os>
   <clock offset="<%= $::clock %>"/>
   <on_poweroff><%= $::on_poweroff %></on_poweroff>
@@ -542,37 +566,35 @@ __DATA__
   <on_crash><%= $::on_crash %></on_crash>
   <devices>
 
-    <% for my $disk (@{$::storage}) { %>
-    <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
-      <% if($disk->{aio}) { %>
-      <driver name="tap" type="aio"/>
-      <% } else { %>
-      <driver name="file"/>
-      <% } %>
-      <% if(exists $disk->{file}) { %>
-      <source file="<%= $disk->{file} %>"/>
-      <% } %>
-      <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
-    </disk>
+   <% for my $disk (@{$::storage}) { %>
+   <disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
+    <% if($disk->{aio}) { %>
+    <driver name="tap" type="aio"/>
+    <% } else { %>
+    <driver name="file"/>
     <% } %>
-
-    <% for my $netdev (@{$::network}) { %>
-    <interface type="<%= $netdev->{type} %>">
-      <% if(exists $netdev->{mac}) { %>
-      <mac address="<%= $netdev->{mac} %>"/>
-      <% } %>
-      <% if($netdev->{type} eq "bridge") { %>
-      <source bridge="<%= $netdev->{bridge} %>"/>
-      <% } %>
-    </interface>
+    <% if(exists $disk->{file}) { %>
+    <source file="<%= $disk->{file} %>"/>
+    <% } %>
+    <target dev="<%= $disk->{dev} %>" bus="<%= $disk->{bus} %>"/>
+   </disk>
+   <% } %>
+
+   <% for my $netdev (@{$::network}) { %>
+   <interface type="<%= $netdev->{type} %>">
+    <% if(exists $netdev->{mac}) { %>
+    <mac address="<%= $netdev->{mac} %>"/>
     <% } %>
-    <graphics type="vnc" autoport="yes"/>
-    <console type="pty">
-      <target port="0"/>
-    </console>
+    <% if($netdev->{type} eq "bridge") { %>
+    <source bridge="<%= $netdev->{bridge} %>"/>
+    <% } %>
+   </interface>
+   <% } %>
+   <graphics type="vnc" autoport="yes"/>
+   <console type="pty">
+    <target port="0"/>
+   </console>
   </devices>
 </domain>
 
 @end
-
-
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::delete;
@@ -13,26 +13,27 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1) = @_;
+  my ( $class, $arg1 ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("deleting domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("deleting domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless ($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "virsh undefine $dom";
-   if($? != 0) {
-      die("Error destroying vm $dom");
-   }
+  i_run "virsh -c $uri undefine $dom";
+  if ( $? != 0 ) {
+    die("Error destroying vm $dom");
+  }
 
 }
 
 1;
-
-
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::destroy;
@@ -13,26 +13,27 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("destroying domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("destroying domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless ($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "virsh destroy $dom";
-   if($? != 0) {
-      die("Error destroying vm $dom");
-   }
+  i_run "virsh -c $uri destroy $dom";
+  if ( $? != 0 ) {
+    die("Error destroying vm $dom");
+  }
 
 }
 
 1;
-
-
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::dumpxml;
@@ -17,22 +17,25 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $vmname) = @_;
+  my ( $class, $vmname ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  Rex::Logger::debug("Getting dumpxml of domain: $vmname");
 
-   Rex::Logger::debug("Getting dumpxml of domain: $vmname");
+  my $xml;
 
-   my $xml;
+  my $dumpxml = i_run "virsh -c $uri dumpxml $vmname";
 
-   my $dumpxml = i_run "virsh dumpxml $vmname";
-  
-   if($? != 0) {
-      die("Error running virsh dumpxml $vmname");
-   }
-   return XMLin($dumpxml);
+  if ( $? != 0 ) {
+    die("Error running virsh dumpxml $vmname");
+  }
+  return XMLin($dumpxml);
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::guestinfo;
@@ -16,42 +16,43 @@ use Rex::Virtualization::LibVirt::iflist;
 use Rex::Commands::Gather;
 
 sub execute {
-   my ($class, $vmname) = @_;
+  my ( $class, $vmname ) = @_;
+
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  Rex::Logger::debug("Getting info of guest: $vmname");
 
-   Rex::Logger::debug("Getting info of guest: $vmname");
+  my $ifs = Rex::Virtualization::LibVirt::iflist->execute($vmname);
 
-   my $ifs = Rex::Virtualization::LibVirt::iflist->execute($vmname);
+  my $got_ip = 0;
 
-   my $got_ip = 0;
+  my @ifaces;
 
-   my @ifaces;
+  my $command = operating_system_is("Gentoo") ? '/sbin/arp' : '/usr/sbin/arp';
 
-   my $command = operating_system_is("Gentoo") ? '/sbin/arp' : '/usr/sbin/arp';
-   
-   while($got_ip < scalar(keys %{ $ifs })) {
-      my %arp = map { my @x = ( $_ =~ m/\(([^\)]+)\) at ([^\s]+)\s/ ); ($x[1], $x[0]) } i_run "$command -an";
+  while ( $got_ip < scalar( keys %{$ifs} ) ) {
+    my %arp =
+      map { my @x = ( $_ =~ m/\(([^\)]+)\) at ([^\s]+)\s/ ); ( $x[1], $x[0] ) }
+      i_run "$command -an";
 
-      for my $if (keys %{ $ifs }) {
-         if(exists $arp{$ifs->{$if}->{mac}} && $arp{$ifs->{$if}->{mac}}) {
-            $got_ip++;
-            push @ifaces, {
-               device => $if,
-               ip   => $arp{$ifs->{$if}->{mac}},
-               %{ $ifs->{$if} }
-            };
-         }
+    for my $if ( keys %{$ifs} ) {
+      if ( exists $arp{ $ifs->{$if}->{mac} } && $arp{ $ifs->{$if}->{mac} } ) {
+        $got_ip++;
+        push @ifaces,
+          {
+          device => $if,
+          ip     => $arp{ $ifs->{$if}->{mac} },
+          %{ $ifs->{$if} }
+          };
       }
+    }
 
-      sleep 1;
-   }
+    sleep 1;
+  }
 
-   return {
-      network => \@ifaces,
-   };
+  return { network => \@ifaces, };
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::hypervisor;
@@ -17,58 +17,70 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
-
-   my ($xml, @dominfo, $dom);
-   if ($arg1 eq 'capabilities') {
-      @dominfo = i_run "virsh capabilities";
-      if($? != 0) {
-         die("Error running virsh dominfo $dom");
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
+
+  my ( $xml, @dominfo, $dom );
+  if ( $arg1 eq 'capabilities' ) {
+    @dominfo = i_run "virsh -c $uri capabilities";
+    if ( $? != 0 ) {
+      die("Error running virsh dominfo $dom");
+    }
+
+    my $xs = XML::Simple->new();
+    $xml = $xs->XMLin(
+      join( "", @dominfo ),
+      KeepRoot     => 1,
+      KeyAttr      => 1,
+      ForceContent => 1
+    );
+  }
+  else {
+    Rex::Logger::debug("Unknown action $arg1");
+    die("Unknown action $arg1");
+  }
+
+  my %ret = ();
+  my ( $k, $v );
+
+  if ( ref( $xml->{'capabilities'}->{'guest'} ) ne "ARRAY" ) {
+    $xml->{'capabilities'}->{'guest'} = [ $xml->{'capabilities'}->{'guest'} ];
+  }
+
+  for my $line ( @{ $xml->{'capabilities'}->{'guest'} } ) {
+
+    $ret{ $line->{'arch'}->{'name'} } = 'true'
+      if defined( $line->{'arch'}->{'name'} );
+
+    $ret{'emulator'} = $line->{'arch'}->{'emulator'}->{'content'}
+      if defined( $line->{'arch'}->{'emulator'}->{'content'} );
+
+    $ret{'loader'} = $line->{'arch'}->{'loader'}->{'content'}
+      if defined( $line->{'arch'}->{'loader'}->{'content'} );
+
+    $ret{ $line->{'os_type'}->{'content'} } = 'true'
+      if defined( $line->{'os_type'}->{'content'} );
+
+    if ( defined( $line->{'arch'}->{'domain'} )
+      && ref( $line->{'arch'}->{'domain'} ) eq 'ARRAY' )
+    {
+      for ( @{ $line->{'arch'}->{'domain'} } ) {
+        $ret{ $_->{'type'} } = 'true';
       }
-
-      my $xs = XML::Simple->new();
-      $xml = $xs->XMLin(join("",@dominfo), KeepRoot => 1, KeyAttr => 1, ForceContent => 1);
-   } else {
-      Rex::Logger::debug("Unknown action $arg1");
-      die("Unknown action $arg1");
-   }
-  
-   my %ret = ();
-   my ($k, $v);
-
-   if(ref($xml->{'capabilities'}->{'guest'}) ne "ARRAY") {
-      $xml->{'capabilities'}->{'guest'} = [ $xml->{'capabilities'}->{'guest'} ];
-   }
-
-   for my $line (@{$xml->{'capabilities'}->{'guest'}}) {
-
-      $ret{$line->{'arch'}->{'name'}} = 'true'        
-         if defined($line->{'arch'}->{'name'});
-
-      $ret{'emulator'} = $line->{'arch'}->{'emulator'}->{'content'}
-         if defined($line->{'arch'}->{'emulator'}->{'content'});
-
-      $ret{'loader'} = $line->{'arch'}->{'loader'}->{'content'}
-         if defined($line->{'arch'}->{'loader'}->{'content'});
-
-      $ret{$line->{'os_type'}->{'content'}} = 'true'
-         if defined($line->{'os_type'}->{'content'});
-
-      if(defined($line->{'arch'}->{'domain'}) && ref($line->{'arch'}->{'domain'}) eq 'ARRAY') {
-         for (@{$line->{'arch'}->{'domain'}}) {
-            $ret{$_->{'type'}} = 'true';
-         }
-      } else {
-         $ret{$line->{'arch'}->{'domain'}->{'type'}} = 'true'    
-            if defined($line->{'arch'}->{'domain'}->{'type'});
-      }
-   }
-
-   return \%ret;
+    }
+    else {
+      $ret{ $line->{'arch'}->{'domain'}->{'type'} } = 'true'
+        if defined( $line->{'arch'}->{'domain'}->{'type'} );
+    }
+  }
+
+  return \%ret;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 #
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::iflist;
@@ -17,35 +17,35 @@ use Data::Dumper;
 use Rex::Virtualization::LibVirt::dumpxml;
 
 sub execute {
-   shift;
-   my $vmname = shift;
-   my %options = @_;
+  shift;
+  my $vmname  = shift;
+  my %options = @_;
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   my $ref = Rex::Virtualization::LibVirt::dumpxml->execute($vmname);
+  my $ref = Rex::Virtualization::LibVirt::dumpxml->execute($vmname);
 
-   my $interfaces = $ref->{devices}->{interface};
-   if(ref $interfaces ne "ARRAY") {
-      $interfaces = [ $interfaces ];
-   }
+  my $interfaces = $ref->{devices}->{interface};
+  if ( ref $interfaces ne "ARRAY" ) {
+    $interfaces = [$interfaces];
+  }
 
-   my %ret = ();
-   my $iface_num = 0;
-   for my $iface (@{ $interfaces }) {
-      $ret{"vnet$iface_num"} = {
-         type => $iface->{model}->{type},
-         source => $iface->{source}->{network},
-         model => $iface->{model}->{type},
-         mac => $iface->{mac}->{address},
-      };
+  my %ret       = ();
+  my $iface_num = 0;
+  for my $iface ( @{$interfaces} ) {
+    $ret{"vnet$iface_num"} = {
+      type   => $iface->{model}->{type},
+      source => $iface->{source}->{network},
+      model  => $iface->{model}->{type},
+      mac    => $iface->{mac}->{address},
+    };
 
-      $iface_num++;
-   }
+    $iface_num++;
+  }
 
-   return \%ret;
+  return \%ret;
 
 }
 
@@ -53,39 +53,39 @@ sub execute {
 
 __END__
 
-   print Dumper($ref);
+  print Dumper($ref);
 return;
-   Rex::Logger::debug("Getting interface list of domain: $vmname");
+  Rex::Logger::debug("Getting interface list of domain: $vmname");
 
-   my @iflist = i_run "virsh domiflist $vmname";
+  my @iflist = i_run "virsh domiflist $vmname";
 
-   if($? != 0) {
-      die("Error running virsh domiflist $vmname");
-   }
+  if($? != 0) {
+    die("Error running virsh domiflist $vmname");
+  }
 
-   my ($k, $v);
+  my ($k, $v);
 
-   shift @iflist;
-   shift @iflist;
-   my $iface_num = 0;
-   for my $line (@iflist) {
-      my ($interface, $type, $source, $model, $mac) = split(/\s+/, $line);
+  shift @iflist;
+  shift @iflist;
+  my $iface_num = 0;
+  for my $line (@iflist) {
+    my ($interface, $type, $source, $model, $mac) = split(/\s+/, $line);
 
-      if($interface eq "-") {
-         $interface = "vnet$iface_num";
-      }
+    if($interface eq "-") {
+      $interface = "vnet$iface_num";
+    }
 
-      $ret{$interface} = {
-         type => $type,
-         source => $source,
-         model => $model,
-         mac => $mac
-      };
+    $ret{$interface} = {
+      type => $type,
+      source => $source,
+      model => $model,
+      mac => $mac
+    };
 
-      $iface_num++;
-   }
+    $iface_num++;
+  }
 
-   return \%ret;
+  return \%ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::info;
@@ -17,31 +17,34 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $vmname) = @_;
+  my ( $class, $vmname ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  Rex::Logger::debug("Getting info of domain: $vmname");
 
-   Rex::Logger::debug("Getting info of domain: $vmname");
+  my $xml;
 
-   my $xml;
+  my @dominfo = i_run "virsh -c $uri dominfo $vmname";
 
-   my @dominfo = i_run "virsh dominfo $vmname";
-  
-   if($? != 0) {
-      die("Error running virsh dominfo $vmname");
-   }
+  if ( $? != 0 ) {
+    die("Error running virsh dominfo $vmname");
+  }
 
-   my %ret = ();
-   my ($k, $v);
+  my %ret = ();
+  my ( $k, $v );
 
-   for my $line (@dominfo) {
-      ($k, $v) = split(/:\s+/, $line);
-      $ret{$k} = $v;
-   } 
+  for my $line (@dominfo) {
+    ( $k, $v ) = split( /:\s+/, $line );
+    $ret{$k} = $v;
+  }
 
-   return \%ret;
+  return \%ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::list;
@@ -15,38 +15,49 @@ use Rex::Helper::Run;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-   my @domains;
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
 
-   if($arg1 eq "all") {
-      @domains = i_run "virsh list --all";
-      if($? != 0) {
-         die("Error running virsh list --all");
-      }
-   } elsif($arg1 eq "running") {
-      @domains = i_run "virsh list";
-      if($? != 0) {
-         die("Error running virsh list");
-      }
-   } else {
-      return;
-   }
+  my @domains;
 
-   ## remove header of the output
-   shift @domains; shift @domains;
+  if ( $arg1 eq "all" ) {
+    @domains = i_run "virsh -c $uri list --all";
+    if ( $? != 0 ) {
+      die("Error running virsh list --all");
+    }
+  }
+  elsif ( $arg1 eq "running" ) {
+    @domains = i_run "virsh -c $uri list";
+    if ( $? != 0 ) {
+      die("Error running virsh list");
+    }
+  }
+  else {
+    return;
+  }
 
-   my @ret = ();
-   for my $line (@domains) {
-      my ($id, $name, $status) = $line =~ m:^\s{0,2}(\d+|\-)\s+([A-Za-z0-9-._]+)\s+(.*)$:;
+  ## remove header of the output
+  shift @domains;
+  shift @domains;
 
-      push( @ret, {
-         id     => $id,
-         name   => $name,
-         status => $status
-      });
-   }
+  my @ret = ();
+  for my $line (@domains) {
+    my ( $id, $name, $status ) =
+      $line =~ m:^\s{0,2}(\d+|\-)\s+([A-Za-z0-9-._]+)\s+(.*)$:;
+
+    push(
+      @ret,
+      {
+        id     => $id,
+        name   => $name,
+        status => $status
+      }
+    );
+  }
 
-   return \@ret;
+  return \@ret;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::option;
@@ -13,37 +13,39 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 my $FUNC_MAP = {
-   max_memory  => "setmaxmem",
-   memory      => "setmem",
+  max_memory => "setmaxmem",
+  memory     => "setmem",
 };
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("setting some options for: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("setting some options for: $dom");
 
-   for my $opt (keys %opt) {
-      my $val = $opt{$opt};
+  for my $opt ( keys %opt ) {
+    my $val = $opt{$opt};
 
-      unless(exists $FUNC_MAP->{$opt}) {
-         Rex::Logger::info("$opt can't be set right now.");
-         next;
-      }
+    unless ( exists $FUNC_MAP->{$opt} ) {
+      Rex::Logger::info("$opt can't be set right now.");
+      next;
+    }
 
-      my $func = $FUNC_MAP->{$opt};
-      i_run "virsh $func $dom $val";
-      if($? != 0) {
-         Rex::Logger::info("Error setting $opt to $val on $dom ($@)", "warn");
-      }
+    my $func = $FUNC_MAP->{$opt};
+    i_run "virsh -c $uri $func $dom $val";
+    if ( $? != 0 ) {
+      Rex::Logger::info( "Error setting $opt to $val on $dom ($@)", "warn" );
+    }
 
-   }
+  }
 
 }
 
 1;
-
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::reboot;
@@ -13,23 +13,26 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
-
-   my $dom = $arg1;
-   Rex::Logger::debug("rebooting domain: $dom");
-
-   unless($dom) {
-      die("VM $dom not found.");
-   }
-
-   i_run "virsh reboot $dom";
-   if($? != 0) {
-      die("Error rebooting vm $dom");
-   }
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
+
+  my $dom = $arg1;
+  Rex::Logger::debug("rebooting domain: $dom");
+
+  unless ($dom) {
+    die("VM $dom not found.");
+  }
+
+  i_run "virsh -c $uri reboot $dom";
+  if ( $? != 0 ) {
+    die("Error rebooting vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::shutdown;
@@ -13,23 +13,26 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
-
-   my $dom = $arg1;
-   Rex::Logger::debug("shutdown domain: $dom");
-
-   unless($dom) {
-      die("VM $dom not found.");
-   }
-
-   i_run "virsh shutdown $dom";
-   if($? != 0) {
-      die("Error shutdown vm $dom");
-   }
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
+
+  my $dom = $arg1;
+  Rex::Logger::debug("shutdown domain: $dom");
+
+  unless ($dom) {
+    die("VM $dom not found.");
+  }
+
+  i_run "virsh -c $uri shutdown $dom";
+  if ( $? != 0 ) {
+    die("Error shutdown vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::start;
@@ -13,23 +13,26 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
-
-   my $dom = $arg1;
-   Rex::Logger::debug("starting domain: $dom");
-
-   unless($dom) {
-      die("VM $dom not found.");
-   }
-
-   i_run "virsh start $dom";
-   if($? != 0) {
-      die("Error starting vm $dom");
-   }
+  my ( $class, $arg1, %opt ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($arg1) {
+    die("You have to define the vm name!");
+  }
+
+  my $dom = $arg1;
+  Rex::Logger::debug("starting domain: $dom");
+
+  unless ($dom) {
+    die("VM $dom not found.");
+  }
+
+  i_run "virsh -c $uri start $dom";
+  if ( $? != 0 ) {
+    die("Error starting vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::LibVirt::vncdisplay;
@@ -17,23 +17,26 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $vmname) = @_;
+  my ( $class, $vmname ) = @_;
+  my $virt_settings = Rex::Config->get("virtualization");
+  chomp( my $uri =
+      ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
+
+  unless ($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  Rex::Logger::debug("Getting info of domain: $vmname");
 
-   Rex::Logger::debug("Getting info of domain: $vmname");
+  my $xml;
 
-   my $xml;
+  my @vncdisplay = i_run "virsh -c $uri vncdisplay $vmname";
 
-   my @vncdisplay = i_run "virsh vncdisplay $vmname";
-  
-   if($? != 0) {
-      die("Error running virsh vncdisplay $vmname");
-   }
+  if ( $? != 0 ) {
+    die("Error running virsh vncdisplay $vmname");
+  }
 
-   return shift @vncdisplay;
+  return shift @vncdisplay;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,37 +15,37 @@ With this module you can manage LibVirt.
 =head1 SYNOPSIS
 
  use Rex::Commands::Virtualization;
-    
+   
  set virtualization => "LibVirt";
-    
+   
  print Dumper vm list => "all";
  print Dumper vm list => "running";
-    
+   
  vm destroy => "vm01";
-    
+   
  vm delete => "vm01"; 
-     
- vm start => "vm01";
     
+ vm start => "vm01";
+   
  vm shutdown => "vm01";
-    
+   
  vm reboot => "vm01";
-    
+   
  vm option => "vm01",
-          max_memory => 1024*1024,
-          memory     => 512*1024;
-              
+       max_memory => 1024*1024,
+       memory    => 512*1024;
+          
  print Dumper vm info => "vm01";
-    
+   
  # creating a vm on a kvm host
  vm create => "vm01",
-      storage     => [
-         {   
-            file   => "/mnt/data/libvirt/images/vm01.img",
-            dev    => "vda",
-         }   
-      ];  
-       
+    storage    => [
+      {  
+        file  => "/mnt/data/libvirt/images/vm01.img",
+        dev   => "vda",
+      }  
+    ];  
+     
  print Dumper vm hypervisor => "capabilities";
 
 =cut
@@ -59,13 +59,13 @@ use Rex::Virtualization::Base;
 use base qw(Rex::Virtualization::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::bridge;
@@ -15,38 +15,38 @@ use Rex::Helper::Run;
 use Data::Dumper;
 
 sub execute {
-   my $class = shift;
-
-   my $result = i_run "VBoxManage list bridgedifs";
-   if($? != 0) {
-      die("Error running VBoxManage list bridgedifs");
-   }
-
-   my @ifs;
-   my @blocks = split /\n\n/m, $result;
-   for my $block (@blocks) {
-
-      my $if = {};
-      my @lines = split /\n/, $block;
-      for my $line (@lines) {
-         if ($line =~ /^Name:\s+(.+?)$/) {
-            $if->{name} = $1;
-         }
-         elsif ($line =~ /^IPAddress:\s+(.+?)$/) {
-            $if->{ip} = $1;
-         }
-         elsif ($line =~ /^NetworkMask:\s+(.+?)$/) {
-            $if->{netmask} = $1;
-         }
-         elsif ($line =~ /^Status:\s+(.+?)$/) {
-            $if->{status} = $1;
-         }
+  my $class = shift;
+
+  my $result = i_run "VBoxManage list bridgedifs";
+  if($? != 0) {
+    die("Error running VBoxManage list bridgedifs");
+  }
+
+  my @ifs;
+  my @blocks = split /\n\n/m, $result;
+  for my $block (@blocks) {
+
+    my $if = {};
+    my @lines = split /\n/, $block;
+    for my $line (@lines) {
+      if ($line =~ /^Name:\s+(.+?)$/) {
+        $if->{name} = $1;
       }
+      elsif ($line =~ /^IPAddress:\s+(.+?)$/) {
+        $if->{ip} = $1;
+      }
+      elsif ($line =~ /^NetworkMask:\s+(.+?)$/) {
+        $if->{netmask} = $1;
+      }
+      elsif ($line =~ /^Status:\s+(.+?)$/) {
+        $if->{status} = $1;
+      }
+    }
 
-      push @ifs, $if;
-   }
+    push @ifs, $if;
+  }
 
-   return \@ifs;
+  return \@ifs;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::create;
@@ -23,179 +23,179 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $name, %opt) = @_;
+  my ($class, $name, %opt) = @_;
 
-   my $opts = \%opt;
-   $opts->{name} = $name;
-   $opts->{type} ||= "Linux26"; # default to Linux 2.6
+  my $opts = \%opt;
+  $opts->{name} = $name;
+  $opts->{type} ||= "Linux26"; # default to Linux 2.6
 
-   unless($opts) {
-      die("You have to define the create options!");
-   }
+  unless($opts) {
+    die("You have to define the create options!");
+  }
 
-   _set_defaults($opts);
+  _set_defaults($opts);
 
-   i_run "VBoxManage createvm --name \"" . $name . "\" --ostype \"" . $opts->{type} . "\" --register";
+  i_run "VBoxManage createvm --name \"" . $name . "\" --ostype \"" . $opts->{type} . "\" --register";
 
-   ### add controller
-   i_run "VBoxManage storagectl \"$name\" --name \"SATA Controller\" --add sata --controller IntelAhci";
-   i_run "VBoxManage storagectl \"$name\" --name \"IDE Controller\" --add ide --controller PIIX4";
+  ### add controller
+  i_run "VBoxManage storagectl \"$name\" --name \"SATA Controller\" --add sata --controller IntelAhci";
+  i_run "VBoxManage storagectl \"$name\" --name \"IDE Controller\" --add ide --controller PIIX4";
 
-   ### create hds
-   my $hdd_ports = {
-      "sata" => 0,
-      "ide"  => 0,
-   };
+  ### create hds
+  my $hdd_ports = {
+    "sata" => 0,
+    "ide"  => 0,
+  };
 
-   for my $hd (@{ $opts->{storage} }) {
-      if($hd->{type} eq "file") {
-         my $filename = $hd->{file};
-         my $size     = $hd->{size};
-         my $format   = $hd->{format};
-         if(! $filename) { die("You have to specify 'file'."); }
+  for my $hd (@{ $opts->{storage} }) {
+    if($hd->{type} eq "file") {
+      my $filename = $hd->{file};
+      my $size    = $hd->{size};
+      my $format  = $hd->{format};
+      if(! $filename) { die("You have to specify 'file'."); }
 
-         if($hd->{device} eq "disk") {
+      if($hd->{device} eq "disk") {
 
-            if(! -f $filename) {
-               i_run "VBoxManage createhd --filename \"$filename\" --size $size --format $format 2>&1";
-            }
+        if(! -f $filename) {
+          i_run "VBoxManage createhd --filename \"$filename\" --size $size --format $format 2>&1";
+        }
 
-            i_run "VBoxManage storageattach \"$name\" --storagectl \"SATA Controller\" --port " . $hdd_ports->{sata} . " --device 0 --type hdd --medium \"$filename\"";
-            $hdd_ports->{sata}++;
-         }
-
-         if($hd->{device} eq "cdrom") {
-            i_run "VBoxManage storageattach \"$name\" --storagectl \"IDE Controller\" --port " . $hdd_ports->{ide} . " --device 0 --type dvddrive --medium \"$filename\"";
-            $hdd_ports->{sata}++;
-         }
+        i_run "VBoxManage storageattach \"$name\" --storagectl \"SATA Controller\" --port " . $hdd_ports->{sata} . " --device 0 --type hdd --medium \"$filename\"";
+        $hdd_ports->{sata}++;
+      }
 
+      if($hd->{device} eq "cdrom") {
+        i_run "VBoxManage storageattach \"$name\" --storagectl \"IDE Controller\" --port " . $hdd_ports->{ide} . " --device 0 --type dvddrive --medium \"$filename\"";
+        $hdd_ports->{sata}++;
       }
-   }
 
-   # memory
-   i_run "VBoxManage modifyvm \"$name\" --memory " . $opts->{memory};
+    }
+  }
+
+  # memory
+  i_run "VBoxManage modifyvm \"$name\" --memory " . $opts->{memory};
 
-   # cpus
-   i_run "VBoxManage modifyvm \"$name\" --cpus " . $opts->{cpus};
+  # cpus
+  i_run "VBoxManage modifyvm \"$name\" --cpus " . $opts->{cpus};
 
-   # boot
-   i_run "VBoxManage modifyvm \"$name\" --boot1 " . $opts->{boot};
+  # boot
+  i_run "VBoxManage modifyvm \"$name\" --boot1 " . $opts->{boot};
 
-   return;
+  return;
 }
 
 sub _set_defaults {
-   my ($opts) = @_;
+  my ($opts) = @_;
 
-   if( ! exists $opts->{"name"} ) {
-      die("You have to give a name.");
-   }
+  if( ! exists $opts->{"name"} ) {
+    die("You have to give a name.");
+  }
 
-   if( ! exists $opts->{"storage"} ) {
-      die("You have to add at least one storage disk.");
-   }
+  if( ! exists $opts->{"storage"} ) {
+    die("You have to add at least one storage disk.");
+  }
 
-   if( ! exists $opts->{"memory"} ) {
-      $opts->{"memory"} = 512;
-   }
-   else {
-      # default is mega byte
-      $opts->{memory} = $opts->{memory};
-   }
+  if( ! exists $opts->{"memory"} ) {
+    $opts->{"memory"} = 512;
+  }
+  else {
+    # default is mega byte
+    $opts->{memory} = $opts->{memory};
+  }
 
-   if( ! exists $opts->{"cpus"} ) {
-      $opts->{"cpus"} = 1;
-   }
+  if( ! exists $opts->{"cpus"} ) {
+    $opts->{"cpus"} = 1;
+  }
 
-   if( ! exists $opts->{"boot"} ) {
-      $opts->{"boot"} = "disk";
-   }
+  if( ! exists $opts->{"boot"} ) {
+    $opts->{"boot"} = "disk";
+  }
 
-   # normalize
-   if($opts->{boot} eq "hd") {
-      $opts->{boot} = "disk";
-   }
+  # normalize
+  if($opts->{boot} eq "hd") {
+    $opts->{boot} = "disk";
+  }
 
-   _set_storage_defaults($opts);
+  _set_storage_defaults($opts);
 
-   _set_network_defaults($opts);
+  _set_network_defaults($opts);
 
 }
 
 sub _set_storage_defaults {
-   my ($opts) = @_;
+  my ($opts) = @_;
 
-   my $store_letter = "a";
-   for my $store ( @{ $opts->{"storage"} } ) {
+  my $store_letter = "a";
+  for my $store ( @{ $opts->{"storage"} } ) {
 
-      if( ! exists $store->{"type"} ) {
-         $store->{"type"} = "file";
-      }
+    if( ! exists $store->{"type"} ) {
+      $store->{"type"} = "file";
+    }
 
-      if( $store->{type} eq "file" && ! exists $store->{format} ) {
-         $store->{format} = "VDI";
-      }
+    if( $store->{type} eq "file" && ! exists $store->{format} ) {
+      $store->{format} = "VDI";
+    }
 
-      if( ! exists $store->{"size"} && $store->{"type"} eq "file" ) {
-         $store->{"size"} = "10G";
-      }
+    if( ! exists $store->{"size"} && $store->{"type"} eq "file" ) {
+      $store->{"size"} = "10G";
+    }
 
-      if( $store->{type} eq "file" ) {
-         $store->{size} = _calc_size($store->{size});
-      }
+    if( $store->{type} eq "file" ) {
+      $store->{size} = _calc_size($store->{size});
+    }
 
-      if( exists $store->{"file"} && $store->{"file"} =~ m/\.iso$/ && ! exists $store->{"device"} ) {
-         $store->{"device"} = "cdrom";
-      }
+    if( exists $store->{"file"} && $store->{"file"} =~ m/\.iso$/ && ! exists $store->{"device"} ) {
+      $store->{"device"} = "cdrom";
+    }
 
-      if( ! exists $store->{"device"} ) {
-         $store->{"device"} = "disk";
-      }
+    if( ! exists $store->{"device"} ) {
+      $store->{"device"} = "disk";
+    }
 
-      if( $store->{"device"} eq "cdrom" ) {
-         $store->{"readonly"} = 1;
-      }
+    if( $store->{"device"} eq "cdrom" ) {
+      $store->{"readonly"} = 1;
+    }
 
-   }
+  }
 
 }
 
 sub _set_network_defaults {
-   my ($opts, $hyper) = @_;
+  my ($opts, $hyper) = @_;
 
-   if( ! exists $opts->{"network"} ) {
-      $opts->{"network"} = [
-         {
-            type   => "bridge",
-            bridge => "eth0",
-         },
-      ];
-   }
+  if( ! exists $opts->{"network"} ) {
+    $opts->{"network"} = [
+      {
+        type  => "bridge",
+        bridge => "eth0",
+      },
+    ];
+  }
 
-   for my $netdev ( @{ $opts->{"network"} } ) {
+  for my $netdev ( @{ $opts->{"network"} } ) {
 
-      if( ! exists $netdev->{"type"} ) {
-         $netdev->{"type"} = "bridge";
-      }
+    if( ! exists $netdev->{"type"} ) {
+      $netdev->{"type"} = "bridge";
+    }
 
-      if( ! exists $netdev->{"bridge"} ) {
-         $netdev->{"bridge"} = "eth0";
-      }
+    if( ! exists $netdev->{"bridge"} ) {
+      $netdev->{"bridge"} = "eth0";
+    }
 
-   }
+  }
 }
 
 sub _calc_size {
-   my ($size) = @_;
+  my ($size) = @_;
 
-   my $ret_size = 0;
-   if($size =~ m/^(\d+)G$/) {
-      $ret_size = $1 * 1024;
-   }
+  my $ret_size = 0;
+  if($size =~ m/^(\d+)G$/) {
+    $ret_size = $1 * 1024;
+  }
 
-   elsif($size =~ m/^(\d+)M$/) {
-      $ret_size = $1;
-   }
+  elsif($size =~ m/^(\d+)M$/) {
+    $ret_size = $1;
+  }
 }
 
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::delete;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1) = @_;
+  my ($class, $arg1) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("deleting domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("deleting domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "VBoxManage unregistervm \"$dom\" --delete";
-   if($? != 0) {
-      die("Error destroying vm $dom");
-   }
+  i_run "VBoxManage unregistervm \"$dom\" --delete";
+  if($? != 0) {
+    die("Error destroying vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::destroy;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("destroying domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("destroying domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "VBoxManage controlvm \"$dom\" poweroff";
-   if($? != 0) {
-      die("Error destroying vm $dom");
-   }
+  i_run "VBoxManage controlvm \"$dom\" poweroff";
+  if($? != 0) {
+    die("Error destroying vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::forward_port;
@@ -19,49 +19,49 @@ use Rex::Virtualization::VBox::info;
 #
 
 sub execute {
-   my ($class, $arg1, $action, $option) = @_;
+  my ($class, $arg1, $action, $option) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
+  my $dom = $arg1;
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   if($action eq "add") {
-      for my $rule (keys %{ $option }) {
+  if($action eq "add") {
+    for my $rule (keys %{ $option }) {
 
 
-         my $from_port = $option->{$rule}->[0];
-         my $to_port = $option->{$rule}->[1];
+      my $from_port = $option->{$rule}->[0];
+      my $to_port = $option->{$rule}->[1];
 
-         i_run "VBoxManage modifyvm \"$dom\" --natpf1 \"$rule,tcp,,$from_port,,$to_port\"";
-      }
-   }
-   else {
-      if($option ne "-all") {
-         i_run "VBoxManage modifyvm \"$dom\" --natpf1 delete \"$option\"";
-      }
-      else {
-         # if no name is given, remove all redirects
-         # output: Forwarding(0)="ssh,tcp,,2222,,22"
-         my $info = Rex::Virtualization::VBox::info->execute($dom);
-         my @keys = grep { m/^Forwarding/ } keys %{ $info };
-
-         for my $k (@keys) {
-            my @_t = split(/,/, $info->{$k});
-            i_run "VBoxManage modifyvm \"$dom\" --natpf1 delete \"$_t[0]\"";
-         }
+      i_run "VBoxManage modifyvm \"$dom\" --natpf1 \"$rule,tcp,,$from_port,,$to_port\"";
+    }
+  }
+  else {
+    if($option ne "-all") {
+      i_run "VBoxManage modifyvm \"$dom\" --natpf1 delete \"$option\"";
+    }
+    else {
+      # if no name is given, remove all redirects
+      # output: Forwarding(0)="ssh,tcp,,2222,,22"
+      my $info = Rex::Virtualization::VBox::info->execute($dom);
+      my @keys = grep { m/^Forwarding/ } keys %{ $info };
+
+      for my $k (@keys) {
+        my @_t = split(/,/, $info->{$k});
+        i_run "VBoxManage modifyvm \"$dom\" --natpf1 delete \"$_t[0]\"";
       }
-      
-   }
+    }
+    
+  }
 
-   if($? != 0) {
-      die("Error setting port forwarding options for vm $dom");
-   }
+  if($? != 0) {
+    die("Error setting port forwarding options for vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::guestinfo;
@@ -14,68 +14,68 @@ use Rex::Helper::Run;
 use Rex::Virtualization::VBox::status;
 
 sub execute {
-   my ($class, $vmname) = @_;
-
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
-
-   Rex::Logger::debug("Getting info of guest: $vmname");
-
-   my $status = Rex::Virtualization::VBox::status->execute($vmname);
-   if($status eq "stopped") {
-      Rex::Logger::debug("VM is not running, no guestinfo available.");
-      return {};
-   }
-
-   # getting info of network interfaces
-   my $netcount = _get_property($vmname, "/VirtualBox/GuestInfo/Net/Count");
-
-   my @netinfo;
-   for(my $i=0; $i < $netcount; $i++) {
-      
-      my $ip         = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/IP");
-      my $mac        = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/MAC");
-      my $netmask    = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/Netmask");
-      my $status     = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/Status");
-      my $broadcast  = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/Broadcast");
-
-      push(@netinfo, {
-         ip => $ip,
-         mac => $mac,
-         netmask => $netmask,
-         status => $status,
-         broadcast => $broadcast,
-      });
-   }
+  my ($class, $vmname) = @_;
+
+  unless($vmname) {
+    die("You have to define the vm name!");
+  }
+
+  Rex::Logger::debug("Getting info of guest: $vmname");
+
+  my $status = Rex::Virtualization::VBox::status->execute($vmname);
+  if($status eq "stopped") {
+    Rex::Logger::debug("VM is not running, no guestinfo available.");
+    return {};
+  }
+
+  # getting info of network interfaces
+  my $netcount = _get_property($vmname, "/VirtualBox/GuestInfo/Net/Count");
+
+  my @netinfo;
+  for(my $i=0; $i < $netcount; $i++) {
+    
+    my $ip      = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/IP");
+    my $mac      = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/MAC");
+    my $netmask   = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/Netmask");
+    my $status    = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/Status");
+    my $broadcast  = _get_property($vmname, "/VirtualBox/GuestInfo/Net/$i/V4/Broadcast");
+
+    push(@netinfo, {
+      ip => $ip,
+      mac => $mac,
+      netmask => $netmask,
+      status => $status,
+      broadcast => $broadcast,
+    });
+  }
   
-   if($? != 0) {
-      die("Error running VBoxManage guestproperty $vmname");
-   }
+  if($? != 0) {
+    die("Error running VBoxManage guestproperty $vmname");
+  }
 
-   return {
-      net => \@netinfo,
-   };
+  return {
+    net => \@netinfo,
+  };
 }
 
 sub _get_property {
-   my ($vmname, $prop) = @_;
+  my ($vmname, $prop) = @_;
 
-   my ($got_value) = (0);
+  my ($got_value) = (0);
 
-   while($got_value != 1) {
-      my @a_tmp = i_run "VBoxManage guestproperty get \"$vmname\" \"$prop\"";
+  while($got_value != 1) {
+    my @a_tmp = i_run "VBoxManage guestproperty get \"$vmname\" \"$prop\"";
 
-      if($a_tmp[0] =~ m/No value set/) {
-         sleep 1;
-         next;
-      }
+    if($a_tmp[0] =~ m/No value set/) {
+      sleep 1;
+      next;
+    }
 
-      $got_value = 1;
+    $got_value = 1;
 
-      my ($return) = ($a_tmp[0] =~ m/Value: (.*)/);
-      return $return;
-   }
+    my ($return) = ($a_tmp[0] =~ m/Value: (.*)/);
+    return $return;
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::import;
@@ -13,30 +13,30 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("importing: $dom -> ". $opt{file});
+  my $dom = $arg1;
+  Rex::Logger::debug("importing: $dom -> ". $opt{file});
 
-   my $add_cmd = "";
+  my $add_cmd = "";
 
-   if(exists $opt{cpus}) {
-      $add_cmd .= " --cpus $opt{cpus} ";
-   }
+  if(exists $opt{cpus}) {
+    $add_cmd .= " --cpus $opt{cpus} ";
+  }
 
-   if(exists $opt{memory}) {
-      $add_cmd .= " --memory $opt{memory} ";
-   }
+  if(exists $opt{memory}) {
+    $add_cmd .= " --memory $opt{memory} ";
+  }
 
-   i_run "VBoxManage import \"" . $opt{file} . "\" --vsys 0 --vmname \"" . $dom . "\" $add_cmd 2>&1";
+  i_run "VBoxManage import \"" . $opt{file} . "\" --vsys 0 --vmname \"" . $dom . "\" $add_cmd 2>&1";
 
-   if($? != 0) {
-      die("Error importing VM $opt{file}");
-   }
+  if($? != 0) {
+    die("Error importing VM $opt{file}");
+  }
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::info;
@@ -17,33 +17,33 @@ use XML::Simple;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $vmname) = @_;
+  my ($class, $vmname) = @_;
 
-   unless($vmname) {
-      die("You have to define the vm name!");
-   }
+  unless($vmname) {
+    die("You have to define the vm name!");
+  }
 
-   Rex::Logger::debug("Getting info of domain: $vmname");
+  Rex::Logger::debug("Getting info of domain: $vmname");
 
-   my $xml;
+  my $xml;
 
-   my @dominfo = i_run "VBoxManage showvminfo \"$vmname\" --machinereadable";
+  my @dominfo = i_run "VBoxManage showvminfo \"$vmname\" --machinereadable";
   
-   if($? != 0) {
-      die("Error running VBoxManage showvminfo $vmname");
-   }
+  if($? != 0) {
+    die("Error running VBoxManage showvminfo $vmname");
+  }
 
-   my %ret = ();
-   my ($k, $v);
+  my %ret = ();
+  my ($k, $v);
 
-   for my $line (@dominfo) {
-      ($k, $v) = split(/=/, $line);
-      $k =~ s/^"|"$//g;
-      $v =~ s/^"|"$//g;
-      $ret{$k} = $v;
-   } 
+  for my $line (@dominfo) {
+    ($k, $v) = split(/=/, $line);
+    $k =~ s/^"|"$//g;
+    $v =~ s/^"|"$//g;
+    $ret{$k} = $v;
+  } 
 
-   return \%ret;
+  return \%ret;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::list;
@@ -15,38 +15,38 @@ use Rex::Helper::Run;
 use Data::Dumper;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
-   my @domains;
-
-   if($arg1 eq "all") {
-      @domains = i_run "VBoxManage list vms";
-      if($? != 0) {
-         die("Error running VBoxManage list vms");
-      }
-   } elsif($arg1 eq "running") {
-      @domains = i_run "VBoxManage list runningvms";
-      if($? != 0) {
-         die("Error running VBoxManage runningvms");
-      }
-   } else {
-      return;
-   }
-
-   my @ret = ();
-   for my $line (@domains) {
-      my ($name, $id) = $line =~ m:^"([^"]+)"\s*\{([^\}]+)\}$:;
-
-      my @status = grep { $_=$1 if /^VMState="([^"]+)"$/ } i_run "VBoxManage showvminfo \"{$id}\" --machinereadable";
-      my $status;
-
-      push( @ret, {
-         id     => $id,
-         name   => $name,
-         status => $status[0],
-      });
-   }
-
-   return \@ret;
+  my ($class, $arg1, %opt) = @_;
+  my @domains;
+
+  if($arg1 eq "all") {
+    @domains = i_run "VBoxManage list vms";
+    if($? != 0) {
+      die("Error running VBoxManage list vms");
+    }
+  } elsif($arg1 eq "running") {
+    @domains = i_run "VBoxManage list runningvms";
+    if($? != 0) {
+      die("Error running VBoxManage runningvms");
+    }
+  } else {
+    return;
+  }
+
+  my @ret = ();
+  for my $line (@domains) {
+    my ($name, $id) = $line =~ m:^"([^"]+)"\s*\{([^\}]+)\}$:;
+
+    my @status = grep { $_=$1 if /^VMState="([^"]+)"$/ } i_run "VBoxManage showvminfo \"{$id}\" --machinereadable";
+    my $status;
+
+    push( @ret, {
+      id    => $id,
+      name  => $name,
+      status => $status[0],
+    });
+  }
+
+  return \@ret;
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::option;
@@ -13,38 +13,38 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 my $FUNC_MAP = {
-   max_memory  => "memory",
-   memory      => "memory",
+  max_memory  => "memory",
+  memory    => "memory",
 };
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("setting some options for: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("setting some options for: $dom");
 
-   for my $opt (keys %opt) {
-      my $val = $opt{$opt};
+  for my $opt (keys %opt) {
+    my $val = $opt{$opt};
 
-      my $func;
-      unless(exists $FUNC_MAP->{$opt}) {
-         Rex::Logger::debug("$opt unknown. using as option for VBoxManage.");
-         $func = $opt;
-      }
-      else {
-         $func = $FUNC_MAP->{$opt};
-      }
+    my $func;
+    unless(exists $FUNC_MAP->{$opt}) {
+      Rex::Logger::debug("$opt unknown. using as option for VBoxManage.");
+      $func = $opt;
+    }
+    else {
+      $func = $FUNC_MAP->{$opt};
+    }
 
-      i_run "VBoxManage modifyvm \"$dom\" --$func \"$val\"";
-      if($? != 0) {
-         Rex::Logger::info("Error setting $opt to $val on $dom ($@)", "warn");
-      }
+    i_run "VBoxManage modifyvm \"$dom\" --$func \"$val\"";
+    if($? != 0) {
+      Rex::Logger::info("Error setting $opt to $val on $dom ($@)", "warn");
+    }
 
-   }
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::reboot;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("rebooting domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("rebooting domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "VBoxManage controlvm \"$dom\" reset";
-   if($? != 0) {
-      die("Error rebooting vm $dom");
-   }
+  i_run "VBoxManage controlvm \"$dom\" reset";
+  if($? != 0) {
+    die("Error rebooting vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::share_folder;
@@ -19,53 +19,53 @@ use Rex::Virtualization::VBox::info;
 #
 
 sub execute {
-   my ($class, $arg1, $action, $option) = @_;
-
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
-
-   my $dom = $arg1;
-
-   unless($dom) {
-      die("VM $dom not found.");
-   }
-
-   if($action eq "add") {
-      FOLDER: for my $folder (keys %{ $option }) {
-         my $info = Rex::Virtualization::VBox::info->execute($dom);
-         my @keys = grep { m/^SharedFolderNameMachineMapping/ } keys %{ $info };
-         for my $k (@keys) {
-            if($info->{$k} eq $folder) {
-               # folder already mapped
-               next FOLDER;
-            }
-         }
-
-         my $from_path = $option->{$folder};
-         i_run "VBoxManage sharedfolder add \"$dom\" --name \"$folder\" --automount --hostpath \"$from_path\"";
+  my ($class, $arg1, $action, $option) = @_;
+
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
+
+  my $dom = $arg1;
+
+  unless($dom) {
+    die("VM $dom not found.");
+  }
+
+  if($action eq "add") {
+    FOLDER: for my $folder (keys %{ $option }) {
+      my $info = Rex::Virtualization::VBox::info->execute($dom);
+      my @keys = grep { m/^SharedFolderNameMachineMapping/ } keys %{ $info };
+      for my $k (@keys) {
+        if($info->{$k} eq $folder) {
+          # folder already mapped
+          next FOLDER;
+        }
       }
-   }
-   else {
-      if($option ne "-all") {
-         i_run "VBoxManage sharedfolder remove \"$dom\" --name \"$option\"";
-      }
-      else {
-         # if no name is given, remove all redirects
-         # output: SharedFolderNameMachineMapping1
-         my $info = Rex::Virtualization::VBox::info->execute($dom);
-         my @keys = grep { m/^SharedFolderNameMachineMapping/ } keys %{ $info };
-
-         for my $k (@keys) {
-            i_run "VBoxManage sharedfolder delete \"$dom\" --name \"$info->{$k}\"";
-         }
+
+      my $from_path = $option->{$folder};
+      i_run "VBoxManage sharedfolder add \"$dom\" --name \"$folder\" --automount --hostpath \"$from_path\"";
+    }
+  }
+  else {
+    if($option ne "-all") {
+      i_run "VBoxManage sharedfolder remove \"$dom\" --name \"$option\"";
+    }
+    else {
+      # if no name is given, remove all redirects
+      # output: SharedFolderNameMachineMapping1
+      my $info = Rex::Virtualization::VBox::info->execute($dom);
+      my @keys = grep { m/^SharedFolderNameMachineMapping/ } keys %{ $info };
+
+      for my $k (@keys) {
+        i_run "VBoxManage sharedfolder delete \"$dom\" --name \"$info->{$k}\"";
       }
-      
-   }
+    }
+    
+  }
 
-   if($? != 0) {
-      die("Error setting folder shares for vm $dom");
-   }
+  if($? != 0) {
+    die("Error setting folder shares for vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::shutdown;
@@ -13,23 +13,23 @@ use Rex::Logger;
 use Rex::Helper::Run;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("shutdown domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("shutdown domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   i_run "VBoxManage controlvm \"$dom\" acpipowerbutton";
-   if($? != 0) {
-      die("Error shutdown vm $dom");
-   }
+  i_run "VBoxManage controlvm \"$dom\" acpipowerbutton";
+  if($? != 0) {
+    die("Error shutdown vm $dom");
+  }
 
 }
 
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 package Rex::Virtualization::VBox::start;
@@ -17,80 +17,80 @@ use Rex::Helper::Path;
 use Cwd 'getcwd';
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   unless($arg1) {
-      die("You have to define the vm name!");
-   }
+  unless($arg1) {
+    die("You have to define the vm name!");
+  }
 
-   my $dom = $arg1;
-   Rex::Logger::debug("starting domain: $dom");
+  my $dom = $arg1;
+  Rex::Logger::debug("starting domain: $dom");
 
-   unless($dom) {
-      die("VM $dom not found.");
-   }
+  unless($dom) {
+    die("VM $dom not found.");
+  }
 
-   my $virt_settings = Rex::Config->get("virtualization");
-   my $headless = 0;
-   if(ref($virt_settings)) {
-      if(exists $virt_settings->{headless} && $virt_settings->{headless}) {
-         $headless = 1;
-      }
-   }
+  my $virt_settings = Rex::Config->get("virtualization");
+  my $headless = 0;
+  if(ref($virt_settings)) {
+    if(exists $virt_settings->{headless} && $virt_settings->{headless}) {
+      $headless = 1;
+    }
+  }
 
-   if($headless && $^O =~ m/^MSWin/ && ! Rex::is_ssh()) {
-      Rex::Logger::info("Right now it is not possible to run VBoxHeadless under Windows.");
-      $headless = 0;
-   }
+  if($headless && $^O =~ m/^MSWin/ && ! Rex::is_ssh()) {
+    Rex::Logger::info("Right now it is not possible to run VBoxHeadless under Windows.");
+    $headless = 0;
+  }
 
-   if($headless) {
-      my $filename = get_tmp_file;
+  if($headless) {
+    my $filename = get_tmp_file;
 
-      file("$filename",
-         content => <<EOF);
+    file("$filename",
+      content => <<EOF);
 use POSIX();
 
 my \$pid = fork();
 if (defined \$pid && \$pid == 0 ) {
-   # child
-   chdir "/";
-   umask 0;
-   POSIX::setsid();
-   local \$SIG{'HUP'} = 'IGNORE';
-   my \$spid = fork();
-   if (defined \$spid && \$spid == 0 ) {
+  # child
+  chdir "/";
+  umask 0;
+  POSIX::setsid();
+  local \$SIG{'HUP'} = 'IGNORE';
+  my \$spid = fork();
+  if (defined \$spid && \$spid == 0 ) {
 
-      open( STDIN,  "</dev/null" );
-      open( STDOUT, "+>/dev/null" );
-      open( STDERR, "+>/dev/null" );
+    open( STDIN,  "</dev/null" );
+    open( STDOUT, "+>/dev/null" );
+    open( STDERR, "+>/dev/null" );
 
-      # 2nd child
-      unlink "$filename";
-      exec("VBoxHeadless --startvm \\\"$dom\\\"");
-      exit;
+    # 2nd child
+    unlink "$filename";
+    exec("VBoxHeadless --startvm \\\"$dom\\\"");
+    exit;
 
 
-   }
+  }
 
-   exit; # end first child (2nd parent)
+  exit; # end first child (2nd parent)
 }
 else {
-   waitpid( \$pid, 0 );
+  waitpid( \$pid, 0 );
 }
 
 exit;
 
 EOF
 
-      i_run "perl $filename";
-   }
-   else {
-      i_run "VBoxManage startvm \"$dom\"";
-   }
+    i_run "perl $filename";
+  }
+  else {
+    i_run "VBoxManage startvm \"$dom\"";
+  }
 
-   if($? != 0) {
-      die("Error starting vm $dom");
-   }
+  if($? != 0) {
+    die("Error starting vm $dom");
+  }
 
 }
 
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Virtualization::VBox::status;
 
 use strict;
@@ -12,18 +12,18 @@ use warnings;
 use Rex::Virtualization::VBox::list;
 
 sub execute {
-   my ($class, $arg1, %opt) = @_;
+  my ($class, $arg1, %opt) = @_;
 
-   my $vms = Rex::Virtualization::VBox::list->execute("all");
+  my $vms = Rex::Virtualization::VBox::list->execute("all");
 
-   my ($vm) = grep { $_->{name} eq $arg1 } @{ $vms };
+  my ($vm) = grep { $_->{name} eq $arg1 } @{ $vms };
 
-   if($vm->{status} eq "poweroff") {
-      return "stopped";
-   }
-   else {
-      return "running";
-   }
+  if($vm->{status} eq "poweroff") {
+    return "stopped";
+  }
+  else {
+    return "running";
+  }
 } 
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =head1 NAME
@@ -15,53 +15,53 @@ With this module you can manage VirtualBox.
 =head1 SYNOPSIS
 
  use Rex::Commands::Virtualization;
-    
+   
  set virtualization => "VBox";
-    
- use Data::Dumper;   
    
+ use Data::Dumper;  
+  
  print Dumper vm list => "all";
  print Dumper vm list => "running";
-    
+   
  vm destroy => "vm01";
-    
+   
  vm delete => "vm01"; 
-     
- vm start => "vm01";
     
+ vm start => "vm01";
+   
  vm shutdown => "vm01";
-    
+   
  vm reboot => "vm01";
-    
+   
  vm option => "vm01",
-          memory     => 512;
-              
+       memory    => 512;
+          
  print Dumper vm info => "vm01";
-    
+   
  # creating a vm 
  vm create => "vm01",
-      storage     => [
-         {   
-            file   => "/mnt/data/vbox/vm01.img",
-            size   => "10G",
-         },
-         {
-            file => "/mnt/iso/debian6.iso",
-         }
-      ],
-      memory => 512,
-      type => "Linux26", 
-      cpus => 1,
-      boot => "dvd";
-   
+    storage    => [
+      {  
+        file  => "/mnt/data/vbox/vm01.img",
+        size  => "10G",
+      },
+      {
+        file => "/mnt/iso/debian6.iso",
+      }
+    ],
+    memory => 512,
+    type => "Linux26", 
+    cpus => 1,
+    boot => "dvd";
+  
  vm forward_port => "vm01", add => { http => [8080, 80] };
-   
+  
  vm forward_port => "vm01", remove => "http";
   
  print Dumper vm guestinfo => "vm01";
-    
+   
  vm share_folder => "vm01", add => { sharename => "/path/to/share" };
-    
+   
  vm share_folder => "vm01", remove => "sharename";
 
 For VirtualBox memory declaration is always in megabyte.
@@ -78,13 +78,13 @@ use Rex::Virtualization::Base;
 use base qw(Rex::Virtualization::Base);
 
 sub new {
-   my $that = shift;
-   my $proto = ref($that) || $that;
-   my $self = { @_ };
+  my $that = shift;
+  my $proto = ref($that) || $that;
+  my $self = { @_ };
 
-   bless($self, $proto);
+  bless($self, $proto);
 
-   return $self;
+  return $self;
 }
 
 1;
@@ -1,9 +1,9 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
 # 
-# vim: set ts=3 sw=3 tw=0:
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
-   
+  
 package Rex::Virtualization;
 
 use strict;
@@ -15,50 +15,50 @@ use Rex::Config;
 my %VM_PROVIDER;
 
 Rex::Config->register_config_handler(virtualization => sub {
-   my ($param) = @_;
+  my ($param) = @_;
 
-   if (ref($param) eq '') {
-      #support 'set virtualization => 'LibVirt', but leave the way open for using a hash in future
-      #other virtualisation drivers may need more settings...
-      $param = {type=>$param};
-   }
+  if (ref($param) eq '') {
+    #support 'set virtualization => 'LibVirt', but leave the way open for using a hash in future
+    #other virtualisation drivers may need more settings...
+    $param = {type=>$param};
+  }
 
-   if(exists $param->{type}) {
-      Rex::Config->set(virtualization => $param->{type});
-   }
+  if(exists $param->{type}) {
+    Rex::Config->set(virtualization => $param->{type});
+  }
 });
 
 sub register_vm_provider {
-   my ($class, $service_name, $service_class) = @_;
-   $VM_PROVIDER{"\L$service_name"} = $service_class;
-   return 1;
+  my ($class, $service_name, $service_class) = @_;
+  $VM_PROVIDER{"\L$service_name"} = $service_class;
+  return 1;
 }
 
 sub create {
-   my ($class, $wanted_provider) = @_;
+  my ($class, $wanted_provider) = @_;
 
-   $wanted_provider ||= Rex::Config->get("virtualization");
-   if(ref($wanted_provider)) {
-      $wanted_provider = $wanted_provider->{type} || "LibVirt";
-   }
+  $wanted_provider ||= Rex::Config->get("virtualization");
+  if(ref($wanted_provider)) {
+    $wanted_provider = $wanted_provider->{type} || "LibVirt";
+  }
 
-   my $klass = "Rex::Virtualization::$wanted_provider";
+  my $klass = "Rex::Virtualization::$wanted_provider";
 
-   if(exists $VM_PROVIDER{$wanted_provider}) {
-      $klass = $VM_PROVIDER{$wanted_provider};
-   }
+  if(exists $VM_PROVIDER{$wanted_provider}) {
+    $klass = $VM_PROVIDER{$wanted_provider};
+  }
 
-   eval "use $klass";
+  eval "use $klass";
 
-   if($@) {
-      Rex::Logger::info("Virtualization Class $klass not found.");
-      die("Virtualization Class $klass not found.");
-   }
+  if($@) {
+    Rex::Logger::info("Virtualization Class $klass not found.");
+    die("Virtualization Class $klass not found.");
+  }
 
-   Rex::Logger::debug("Using $klass for virtualization");
+  Rex::Logger::debug("Using $klass for virtualization");
 
-   my $mod = $klass->new;
-   return $mod;
+  my $mod = $klass->new;
+  return $mod;
 }
 
 1;
@@ -1,7 +1,7 @@
 #
 # (c) Jan Gehring <jan.gehring@gmail.com>
-# 
-# vim: set ts=3 sw=3 tw=0:
+#
+# vim: set ts=2 sw=2 tw=0:
 # vim: set expandtab:
 
 =encoding UTF-8
@@ -34,12 +34,12 @@ You can find examples and howtos on L<http://rexify.org/>
 
  user "root";
  password "ch4ngem3";
-   
+ 
  desc "Show Unix version";
  task "uname", sub {
-     say run "uname -a";
+    say run "uname -a";
  };
-  
+ 
  bash# rex -H "server[01..10]" uname
 
 See L<Rex::Commands> for a list of all commands you can use.
@@ -66,138 +66,138 @@ use Rex::Config;
 use Rex::Helper::Array;
 
 our (@EXPORT,
-      $VERSION,
-      @CONNECTION_STACK,
-      $GLOBAL_SUDO,
-      $MODULE_PATHS,
-      $WITH_EXIT_STATUS);
+    $VERSION,
+    @CONNECTION_STACK,
+    $GLOBAL_SUDO,
+    $MODULE_PATHS,
+    $WITH_EXIT_STATUS);
 
-$VERSION = "0.44.6.1";
+$VERSION = "0.45.3";
 my $cur_dir;
 
 
 BEGIN {
 
-   sub _home_dir {
-      if($^O =~ m/^MSWin/) {
-         return $ENV{'USERPROFILE'};
-      }
+  sub _home_dir {
+    if($^O =~ m/^MSWin/) {
+      return $ENV{'USERPROFILE'};
+    }
 
-      return $ENV{'HOME'} || "";
-   }
+    return $ENV{'HOME'} || "";
+  }
 
-   $cur_dir = getcwd;
+  $cur_dir = getcwd;
 
-   unshift(@INC, sub {
-      my $mod_to_load = $_[1];
-      return search_module_path($mod_to_load, 1);
-   });
+  unshift(@INC, sub {
+    my $mod_to_load = $_[1];
+    return search_module_path($mod_to_load, 1);
+  });
 
 
-   if(-d "$cur_dir/lib") {
-      push(@INC, "$cur_dir/lib");
-   }
+  if(-d "$cur_dir/lib") {
+    push(@INC, "$cur_dir/lib");
+  }
 
-   my $home_dir = _home_dir();
-   if(-d "$home_dir/.rex/recipes") {
-      push(@INC, "$home_dir/.rex/recipes");
-   }
+  my $home_dir = _home_dir();
+  if(-d "$home_dir/.rex/recipes") {
+    push(@INC, "$home_dir/.rex/recipes");
+  }
 
-   push(@INC, sub {
-      my $mod_to_load = $_[1];
-      return search_module_path($mod_to_load, 0);
-   });
+  push(@INC, sub {
+    my $mod_to_load = $_[1];
+    return search_module_path($mod_to_load, 0);
+  });
 
 };
 
 
 my $home = $ENV{'HOME'};
 if($^O =~ m/^MSWin/) {
-   $home = $ENV{'USERPROFILE'};
+  $home = $ENV{'USERPROFILE'};
 }
 
 push(@INC, "$home/.rex/recipes");
 
 sub search_module_path {
-   my ($mod_to_load, $pre) = @_;
+  my ($mod_to_load, $pre) = @_;
 
-   $mod_to_load =~ s/\.pm//g;
+  $mod_to_load =~ s/\.pm//g;
 
-   my @search_in;
-   if($pre) {
-      @search_in = map { ("$_/$mod_to_load.pm") } 
-                     grep { -d } @INC;
+  my @search_in;
+  if($pre) {
+    @search_in = map { ("$_/$mod_to_load.pm") }
+              grep { -d } @INC;
 
-   }
-   else {
-      @search_in = map { ("$_/$mod_to_load/__module__.pm", "$_/$mod_to_load/Module.pm") } 
-                     grep { -d } @INC;
-   }
+  }
+  else {
+    @search_in = map { ("$_/$mod_to_load/__module__.pm", "$_/$mod_to_load/Module.pm") }
+              grep { -d } @INC;
+  }
 
 
-   for my $file (@search_in) {
-      if(-f $file) {
-         my ($path) = ($file =~ m/^(.*)\/.+?$/);
-         if($path !~ m/\//) {
-            $path = $cur_dir . "/$path";
-         }
-
-         # module found, register path
-         $MODULE_PATHS->{$mod_to_load} = {path => $path};
-         my $mod_package_name = $mod_to_load;
-         $mod_package_name =~ s/\//::/g;
-         $MODULE_PATHS->{$mod_package_name} = {path => $path};
+  for my $file (@search_in) {
+    if(-f $file) {
+      my ($path) = ($file =~ m/^(.*)\/.+?$/);
+      if($path !~ m/\//) {
+        $path = $cur_dir . "/$path";
+      }
 
-         if($pre) {
-            return;
-         }
+      # module found, register path
+      $MODULE_PATHS->{$mod_to_load} = {path => $path};
+      my $mod_package_name = $mod_to_load;
+      $mod_package_name =~ s/\//::/g;
+      $MODULE_PATHS->{$mod_package_name} = {path => $path};
 
-         open(my $fh, $file);
-         return $fh;
+      if($pre) {
+        return;
       }
-   }
+
+      open(my $fh, $file);
+      return $fh;
+    }
+  }
 }
 
 sub get_module_path {
-   my ($module) = @_;
-   if(exists $MODULE_PATHS->{$module}) {
-      return $MODULE_PATHS->{$module}->{path};
-   }
+  my ($module) = @_;
+  if(exists $MODULE_PATHS->{$module}) {
+    return $MODULE_PATHS->{$module}->{path};
+  }
 }
 
 sub push_connection {
-   push @CONNECTION_STACK, $_[0];
-   return $_[0];
+  push @CONNECTION_STACK, $_[0];
+  return $_[0];
 }
 
 sub pop_connection {
-   pop @CONNECTION_STACK;
-   Rex::Logger::debug("Connections in queue: " . scalar(@CONNECTION_STACK));
+  pop @CONNECTION_STACK;
+  Rex::Logger::debug("Connections in queue: " . scalar(@CONNECTION_STACK));
 }
 
 sub reconnect_lost_connections {
-   if(@CONNECTION_STACK > 0) {
-      Rex::Logger::debug("Need to reinitialize connections.");
-      for (@CONNECTION_STACK) {
-         $_->{conn}->reconnect;
-      }
-   }
+  if(@CONNECTION_STACK > 0) {
+    Rex::Logger::debug("Need to reinitialize connections.");
+    for (@CONNECTION_STACK) {
+      $_->{conn}->reconnect;
+    }
+  }
 }
 
 # ... no words
 my @__modif_caller;
 sub unset_modified_caller {
-   @__modif_caller = ();
+  @__modif_caller = ();
 }
 
 sub modified_caller {
-   my (@caller) = @_;
-   if(@caller) {
-      @__modif_caller = @caller;
-   }
-   else {
-      return @__modif_caller;
-   }
+  my (@caller) = @_;
+  if(@caller) {
+    @__modif_caller = @caller;
+  }
+  else {
+    return @__modif_caller;
+  }
 }
 
 =item get_current_connection
@@ -222,18 +222,18 @@ The server name
 
 sub get_current_connection {
 
-   # if no connection available, use local connect
-   unless(@CONNECTION_STACK) {
-      my $conn = Rex::Interface::Connection->create("Local");
+  # if no connection available, use local connect
+  unless(@CONNECTION_STACK) {
+    my $conn = Rex::Interface::Connection->create("Local");
 
-      Rex::push_connection({
-         conn   => $conn,
-         ssh    => $conn->get_connection_object,
-         cache => Rex::Interface::Cache->create(),
-      });
-   }
+    Rex::push_connection({
+      conn  => $conn,
+      ssh   => $conn->get_connection_object,
+      cache => Rex::Interface::Cache->create(),
+    });
+  }
 
-   $CONNECTION_STACK[-1];
+  $CONNECTION_STACK[-1];
 }
 
 =item is_ssh
@@ -243,14 +243,14 @@ Returns 1 if the current connection is a ssh connection. 0 if not.
 =cut
 
 sub is_ssh {
-   if($CONNECTION_STACK[-1]) {
-      my $ref = ref($CONNECTION_STACK[-1]->{"conn"});
-      if($ref =~ m/SSH/) {
-         return $CONNECTION_STACK[-1]->{"conn"}->get_connection_object();
-      }
-   }
-
-   return 0;
+  if($CONNECTION_STACK[-1]) {
+    my $ref = ref($CONNECTION_STACK[-1]->{"conn"});
+    if($ref =~ m/SSH/) {
+      return $CONNECTION_STACK[-1]->{"conn"}->get_connection_object();
+    }
+  }
+
+  return 0;
 }
 
 =item is_local
@@ -260,38 +260,38 @@ Returns 1 if the current connection is local. Otherwise 0.
 =cut
 
 sub is_local {
-   if($CONNECTION_STACK[-1]) {
-      my $ref = ref($CONNECTION_STACK[-1]->{"conn"});
-      if($ref =~ m/Local/) {
-         return $CONNECTION_STACK[-1]->{"conn"}->get_connection_object();
-      }
-   }
-
-   return 0;
+  if($CONNECTION_STACK[-1]) {
+    my $ref = ref($CONNECTION_STACK[-1]->{"conn"});
+    if($ref =~ m/Local/) {
+      return $CONNECTION_STACK[-1]->{"conn"}->get_connection_object();
+    }
+  }
+
+  return 0;
 }
 
 =item is_sudo
 
-Returns 1 if the current operation is executed within sudo. 
+Returns 1 if the current operation is executed within sudo.
 
 =cut
 
 sub is_sudo {
-   if($GLOBAL_SUDO) { return 1; }
+  if($GLOBAL_SUDO) { return 1; }
 
-   if($CONNECTION_STACK[-1]) {
-      return $CONNECTION_STACK[-1]->{"use_sudo"};
-   }
+  if($CONNECTION_STACK[-1]) {
+    return $CONNECTION_STACK[-1]->{"use_sudo"};
+  }
 
-   return 0;
+  return 0;
 }
 
 sub global_sudo {
-   my ($on) = @_;
-   $GLOBAL_SUDO = $on;
+  my ($on) = @_;
+  $GLOBAL_SUDO = $on;
 
-   # turn cache on
-   Rex::Config->set_use_cache(1);
+  # turn cache on
+  Rex::Config->set_use_cache(1);
 }
 
 =item get_sftp
@@ -301,19 +301,19 @@ Returns the sftp object for the current ssh connection.
 =cut
 
 sub get_sftp {
-   if($CONNECTION_STACK[-1]) {
-      return $CONNECTION_STACK[-1]->{"conn"}->get_fs_connection_object();
-   }
+  if($CONNECTION_STACK[-1]) {
+    return $CONNECTION_STACK[-1]->{"conn"}->get_fs_connection_object();
+  }
 
-   return 0;
+  return 0;
 }
 
 sub get_cache {
-   if($CONNECTION_STACK[-1]) {
-      return $CONNECTION_STACK[-1]->{"cache"};
-   }
+  if($CONNECTION_STACK[-1]) {
+    return $CONNECTION_STACK[-1]->{"cache"};
+  }
 
-   return Rex::Interface::Cache->create();
+  return Rex::Interface::Cache->create();
 }
 
 =item connect
@@ -323,293 +323,299 @@ Use this function to create a connection if you use Rex as a library.
  use Rex;
  use Rex::Commands::Run;
  use Rex::Commands::Fs;
-   
+ 
  Rex::connect(
-    server      => "remotehost",
-    user        => "root",
-    password    => "f00b4r",
-    private_key => "/path/to/private/key/file",
-    public_key  => "/path/to/public/key/file",
+   server    => "remotehost",
+   user      => "root",
+   password   => "f00b4r",
+   private_key => "/path/to/private/key/file",
+   public_key  => "/path/to/public/key/file",
  );
-    
+ 
  if(is_file("/foo/bar")) {
-    print "Do something...\n";
+   print "Do something...\n";
  }
-     
+ 
  my $output = run("uptime");
 
 =cut
 
 sub connect {
 
-   my ($param) = { @_ };
-
-   my $server  = $param->{server};
-   my $port    = $param->{port} || 22;
-   my $timeout = $param->{timeout} || 5;
-   my $user = $param->{"user"};
-   my $pass = $param->{"password"};
-   my $cached_conn = $param->{"cached_connection"};
-
-   if(! $cached_conn) {
-      my $conn = Rex::Interface::Connection->create("SSH");
-
-      $conn->connect(
-         user     => $user,
-         password => $pass,
-         server   => $server,
-         port     => $port,
-         timeout  => $timeout,
-         %{ $param },
-      );
-
-      unless($conn->is_connected) {
-         die("Connetion error or refused.");
-      }
+  my ($param) = { @_ };
+
+  my $server  = $param->{server};
+  my $port   = $param->{port} || 22;
+  my $timeout = $param->{timeout} || 5;
+  my $user = $param->{"user"};
+  my $pass = $param->{"password"};
+  my $cached_conn = $param->{"cached_connection"};
+
+  if(! $cached_conn) {
+    my $conn = Rex::Interface::Connection->create("SSH");
+
+    $conn->connect(
+      user    => $user,
+      password => $pass,
+      server  => $server,
+      port    => $port,
+      timeout  => $timeout,
+      %{ $param },
+    );
+
+    unless($conn->is_connected) {
+      die("Connetion error or refused.");
+    }
+
+    # push a remote connection
+    my $rex_conn = Rex::push_connection({
+      conn  => $conn,
+      ssh   => $conn->get_connection_object,
+      server => $server,
+      cache => Rex::Interface::Cache->create(),
+    });
+
+    # auth unsuccessfull
+    unless($conn->is_authenticated) {
+      Rex::Logger::info("Wrong username or password. Or wrong key.", "warn");
+      # after jobs
+
+      die("Wrong username or password. Or wrong key.");
+    }
+
+    return $rex_conn;
+  }
+  else {
+    Rex::push_connection($cached_conn);
+    return $cached_conn;
+  }
 
-      # push a remote connection
-      my $rex_conn = Rex::push_connection({
-         conn   => $conn,
-         ssh    => $conn->get_connection_object,
-         server => $server,
-         cache => Rex::Interface::Cache->create(),
-      });
+}
 
-      # auth unsuccessfull
-      unless($conn->is_authenticated) {
-         Rex::Logger::info("Wrong username or password. Or wrong key.", "warn");
-         # after jobs
+sub deprecated {
+  my ($func, $version, @msg) = @_;
 
-         die("Wrong username or password. Or wrong key.");
-      }
+  if($func) {
+    Rex::Logger::info("The call to $func is deprecated.");
+  }
+
+  if(@msg) {
+    for (@msg) {
+      Rex::Logger::info($_);
+    }
+  }
 
-      return $rex_conn;
-   }
-   else {
-      Rex::push_connection($cached_conn);
-      return $cached_conn;
-   }
+  Rex::Logger::info("");
+
+  Rex::Logger::info("Please rewrite your code. This function will disappear in (R)?ex version $version.");
+  Rex::Logger::info("If you need assistance please join #rex on irc.freenode.net or our google group.");
 
 }
 
-sub deprecated {
-   my ($func, $version, @msg) = @_;
 
-   if($func) {
-      Rex::Logger::info("The call to $func is deprecated.");
-   }
+sub import {
+  my ($class, $what, $addition1) = @_;
 
-   if(@msg) {
-      for (@msg) {
-         Rex::Logger::info($_);
-      }
-   }
+  $what ||= "";
 
-   Rex::Logger::info("");
+  my ($register_to, $file, $line) = caller;
 
-   Rex::Logger::info("Please rewrite your code. This function will disappear in (R)?ex version $version.");
-   Rex::Logger::info("If you need assistance please join #rex on irc.freenode.net or our google group.");
+  if($what eq "-base" || $what eq "base" || $what eq "-feature") {
+    require Rex::Commands;
+    Rex::Commands->import(register_in => $register_to);
 
-}
+    require Rex::Commands::Run;
+    Rex::Commands::Run->import(register_in => $register_to);
 
+    require Rex::Commands::Fs;
+    Rex::Commands::Fs->import(register_in => $register_to);
 
-sub import {
-   my ($class, $what, $addition1) = @_;
+    require Rex::Commands::File;
+    Rex::Commands::File->import(register_in => $register_to);
+
+    require Rex::Commands::Download;
+    Rex::Commands::Download->import(register_in => $register_to);
+
+    require Rex::Commands::Upload;
+    Rex::Commands::Upload->import(register_in => $register_to);
+
+    require Rex::Commands::Gather;
+    Rex::Commands::Gather->import(register_in => $register_to);
+
+    require Rex::Commands::Kernel;
+    Rex::Commands::Kernel->import(register_in => $register_to);
+
+    require Rex::Commands::Pkg;
+    Rex::Commands::Pkg->import(register_in => $register_to);
+
+    require Rex::Commands::Service;
+    Rex::Commands::Service->import(register_in => $register_to);
+
+    require Rex::Commands::Sysctl;
+    Rex::Commands::Sysctl->import(register_in => $register_to);
+
+    require Rex::Commands::Tail;
+    Rex::Commands::Tail->import(register_in => $register_to);
 
-   $what ||= "";
+    require Rex::Commands::Process;
+    Rex::Commands::Process->import(register_in => $register_to);
 
-   my ($register_to, $file, $line) = caller;
+    require Rex::Commands::Sync;
+    Rex::Commands::Sync->import(register_in => $register_to);
 
-   if($what eq "-base" || $what eq "base" || $what eq "-feature") {
-      require Rex::Commands;
-      Rex::Commands->import(register_in => $register_to);
+    require Rex::Commands::Notify;
+    Rex::Commands::Notify->import(register_in => $register_to);
 
-      require Rex::Commands::Run;
-      Rex::Commands::Run->import(register_in => $register_to);
+    require Rex::Commands::User;
+    Rex::Commands::User->import(register_in => $register_to);
+  }
 
-      require Rex::Commands::Fs;
-      Rex::Commands::Fs->import(register_in => $register_to);
+  if($what eq "-feature" || $what eq "feature") {
 
-      require Rex::Commands::File;
-      Rex::Commands::File->import(register_in => $register_to);
 
-      require Rex::Commands::Download;
-      Rex::Commands::Download->import(register_in => $register_to);
+    if(! ref($addition1)) {
+      $addition1 = [$addition1];
+    }
 
-      require Rex::Commands::Upload;
-      Rex::Commands::Upload->import(register_in => $register_to);
+    for my $add (@{ $addition1 }) {
 
-      require Rex::Commands::Gather;
-      Rex::Commands::Gather->import(register_in => $register_to);
+      my $found_feature = 0;
 
-      require Rex::Commands::Kernel;
-      Rex::Commands::Kernel->import(register_in => $register_to);
+      if($add =~ m/^(\d+\.\d+)$/) {
+        my $vers = $1;
+        my ($major, $minor, $patch) = split(/\./, $VERSION);
+        my ($c_major, $c_minor) = split(/\./, $vers);
 
-      require Rex::Commands::Pkg;
-      Rex::Commands::Pkg->import(register_in => $register_to);
+        if( ($c_major > $major)
+            ||
+           ($c_major >= $major && $c_minor > $minor)
+        ) {
+          Rex::Logger::info("This Rexfile tries to enable features that are not supported with your version. Please update.", "warn");
+          exit 1;
+        }
+      }
 
-      require Rex::Commands::Service;
-      Rex::Commands::Service->import(register_in => $register_to);
+      # remove default task auth
+      if($add =~ m/^\d+\.\d+$/ && $add  >= 0.31) {
+        Rex::Logger::debug("activating featureset >= 0.31");
+        Rex::TaskList->create()->set_default_auth(0);
+        $found_feature = 1;
+      }
 
-      require Rex::Commands::Sysctl;
-      Rex::Commands::Sysctl->import(register_in => $register_to);
+      if($add =~ m/^\d+\.\d+$/ && $add >= 0.35) {
+        Rex::Logger::debug("activating featureset >= 0.35");
+        $Rex::Commands::REGISTER_SUB_HASH_PARAMTER = 1;
+        $found_feature = 1;
+      }
 
-      require Rex::Commands::Tail;
-      Rex::Commands::Tail->import(register_in => $register_to);
+      if($add =~ m/^\d+\.\d+$/ && $add >= 0.40) {
+        Rex::Logger::debug("activating featureset >= 0.40");
+        $Rex::Template::BE_LOCAL = 1;
+        $Rex::WITH_EXIT_STATUS = 1;
+        $found_feature = 1;
+      }
 
-      require Rex::Commands::Process;
-      Rex::Commands::Process->import(register_in => $register_to);
 
-      require Rex::Commands::Sync;
-      Rex::Commands::Sync->import(register_in => $register_to);
-   }
+      if($add eq "no_local_template_vars") {
+        Rex::Logger::debug("activating featureset no_local_template_vars");
+        $Rex::Template::BE_LOCAL = 0;
+        $found_feature = 1;
+      }
 
-   if($what eq "-feature" || $what eq "feature") {
+      if($add eq "exit_status") {
+        Rex::Logger::debug("activating featureset exit_status");
+        $Rex::WITH_EXIT_STATUS = 1;
+        $found_feature = 1;
+      }
 
+      if($add eq "sudo_without_sh") {
+        Rex::Logger::debug("using sudo without sh. this might break some things.");
+        Rex::Config->set_sudo_without_sh(1);
+        $found_feature = 1;
+      }
 
-      if(! ref($addition1)) {
-         $addition1 = [$addition1];
+      if($add eq "sudo_without_locales") {
+        Rex::Logger::debug("Using sudo without locales. this _will_ break things!");
+        Rex::Config->set_sudo_without_locales(1);
+        $found_feature = 1;
       }
 
-      for my $add (@{ $addition1 }) {
-
-         my $found_feature = 0;
-
-         if($add =~ m/^(\d+\.\d+)$/) {
-            my $vers = $1;
-            my ($major, $minor, $patch) = split(/\./, $VERSION);
-            my ($c_major, $c_minor) = split(/\./, $vers);
-
-            if( ($c_major > $major)
-                  ||
-                ($c_major >= $major && $c_minor > $minor)
-            ) {
-               Rex::Logger::info("This Rexfile tries to enable features that are not supported with your version. Please update.", "warn");
-               exit 1;
-            }
-         }
-
-         # remove default task auth
-         if($add =~ m/^\d+\.\d+$/ && $add  >= 0.31) {
-            Rex::Logger::debug("activating featureset >= 0.31");
-            Rex::TaskList->create()->set_default_auth(0);
-            $found_feature = 1;
-         }
-
-         if($add =~ m/^\d+\.\d+$/ && $add >= 0.35) {
-            Rex::Logger::debug("activating featureset >= 0.35");
-            $Rex::Commands::REGISTER_SUB_HASH_PARAMTER = 1;
-            $found_feature = 1;
-         }
-
-         if($add =~ m/^\d+\.\d+$/ && $add >= 0.40) {
-            Rex::Logger::debug("activating featureset >= 0.40");
-            $Rex::Template::BE_LOCAL = 1;
-            $Rex::WITH_EXIT_STATUS = 1;
-            $found_feature = 1;
-         }
-
-
-         if($add eq "no_local_template_vars") {
-            Rex::Logger::debug("activating featureset no_local_template_vars");
-            $Rex::Template::BE_LOCAL = 0;
-            $found_feature = 1;
-         }
-
-         if($add eq "exit_status") {
-            Rex::Logger::debug("activating featureset exit_status");
-            $Rex::WITH_EXIT_STATUS = 1;
-            $found_feature = 1;
-         }
-
-         if($add eq "sudo_without_sh") {
-            Rex::Logger::debug("using sudo without sh. this might break some things.");
-            Rex::Config->set_sudo_without_sh(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "sudo_without_locales") {
-            Rex::Logger::debug("Using sudo without locales. this _will_ break things!");
-            Rex::Config->set_sudo_without_locales(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "no_tty") {
-            Rex::Logger::debug("Disabling pty usage for ssh");
-            Rex::Config->set_no_tty(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "empty_groups") {
-            Rex::Logger::debug("Enabling usage of empty groups");
-            Rex::Config->set_allow_empty_groups(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "use_server_auth") {
-            Rex::Logger::debug("Enabling use_server_auth");
-            Rex::Config->set_use_server_auth(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "exec_and_sleep") {
-            Rex::Logger::debug("Enabling exec_and_sleep");
-            Rex::Config->set_sleep_hack(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "disable_strict_host_key_checking") {
-            Rex::Logger::debug("Disabling strict host key checking for openssh");
-            Rex::Config->set_openssh_opt(StrictHostKeyChecking => "no");
-            $found_feature = 1;
-         }
-
-         if($add eq "reporting" || $add eq "report" || exists $ENV{REX_REPORT_TYPE}) {
-            Rex::Logger::debug("Enabling reporting");
-            Rex::Config->set_do_reporting(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "source_profile") {
-            Rex::Logger::debug("Enabling source_profile");
-            Rex::Config->set_source_profile(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "source_global_profile") {
-            Rex::Logger::debug("Enabling source_global_profile");
-            Rex::Config->set_source_global_profile(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "no_path_cleanup") {
-            Rex::Logger::debug("Enabling no_path_cleanup");
-            Rex::Config->set_no_path_cleanup(1);
-            $found_feature = 1;
-         }
-
-         if($add eq "exec_autodie") {
-            Rex::Logger::debug("Enabling exec_autodie");
-            Rex::Config->set_exec_autodie(1);
-            $found_feature = 1;
-         }
-
-         if($found_feature == 0) {
-            Rex::Logger::info("You tried to load a feature ($add) that doesn't exists in your Rex version. Please update.", "warn");
-            exit 1;
-         }
+      if($add eq "no_tty") {
+        Rex::Logger::debug("Disabling pty usage for ssh");
+        Rex::Config->set_no_tty(1);
+        $found_feature = 1;
+      }
 
+      if($add eq "empty_groups") {
+        Rex::Logger::debug("Enabling usage of empty groups");
+        Rex::Config->set_allow_empty_groups(1);
+        $found_feature = 1;
       }
 
-   }
+      if($add eq "use_server_auth") {
+        Rex::Logger::debug("Enabling use_server_auth");
+        Rex::Config->set_use_server_auth(1);
+        $found_feature = 1;
+      }
+
+      if($add eq "exec_and_sleep") {
+        Rex::Logger::debug("Enabling exec_and_sleep");
+        Rex::Config->set_sleep_hack(1);
+        $found_feature = 1;
+      }
 
-   if(exists $ENV{REX_REPORT_TYPE}) {
-      Rex::Logger::debug("Enabling reporting");
-      Rex::Config->set_do_reporting(1);
-   }
+      if($add eq "disable_strict_host_key_checking") {
+        Rex::Logger::debug("Disabling strict host key checking for openssh");
+        Rex::Config->set_openssh_opt(StrictHostKeyChecking => "no");
+        $found_feature = 1;
+      }
 
-   # we are always strict
-   strict->import;
+      if($add eq "reporting" || $add eq "report" || exists $ENV{REX_REPORT_TYPE}) {
+        Rex::Logger::debug("Enabling reporting");
+        Rex::Config->set_do_reporting(1);
+        $found_feature = 1;
+      }
+
+      if($add eq "source_profile") {
+        Rex::Logger::debug("Enabling source_profile");
+        Rex::Config->set_source_profile(1);
+        $found_feature = 1;
+      }
+
+      if($add eq "source_global_profile") {
+        Rex::Logger::debug("Enabling source_global_profile");
+        Rex::Config->set_source_global_profile(1);
+        $found_feature = 1;
+      }
+
+      if($add eq "no_path_cleanup") {
+        Rex::Logger::debug("Enabling no_path_cleanup");
+        Rex::Config->set_no_path_cleanup(1);
+        $found_feature = 1;
+      }
+
+      if($add eq "exec_autodie") {
+        Rex::Logger::debug("Enabling exec_autodie");
+        Rex::Config->set_exec_autodie(1);
+        $found_feature = 1;
+      }
+
+      if($found_feature == 0) {
+        Rex::Logger::info("You tried to load a feature ($add) that doesn't exists in your Rex version. Please update.", "warn");
+        exit 1;
+      }
+
+    }
+
+  }
+
+  if(exists $ENV{REX_REPORT_TYPE}) {
+    Rex::Logger::debug("Enabling reporting");
+    Rex::Config->set_do_reporting(1);
+  }
+
+  # we are always strict
+  strict->import;
 }
 
 
@@ -676,6 +682,8 @@ Many thanks to the contributors for their work (alphabetical order).
 
 =item Naveed Massjouni
 
+=item Niklas Larsson
+
 =item Nikolay Fetisov
 
 =item Nils Domrose
@@ -688,6 +696,8 @@ Many thanks to the contributors for their work (alphabetical order).
 
 =item RenatoCRON
 
+=item Renee Bäcker
+
 =item Samuele Tognini
 
 =item Sascha Guenther
@@ -1,4 +1,4 @@
-use Test::More tests => 153;
+use Test::More tests => 154;
 
 use_ok 'Rex::Batch';
 use_ok 'Rex::Interface::Cache';
@@ -148,6 +148,7 @@ use_ok 'Rex::Interface::Shell::Csh';
 use_ok 'Rex::Interface::Shell::Tcsh';
 use_ok 'Rex::Interface::Shell::Default';
 use_ok 'Rex::Interface::Shell::Bash';
+use_ok 'Rex::Interface::Shell::Base';
 use_ok 'Rex::Interface::Shell::Sh';
 use_ok 'Rex::Interface::Shell::Zsh';
 use_ok 'Rex';
@@ -159,4 +160,3 @@ ok(join(",", @hosts) eq "web01,web02,web03,web04,web05,web06,web07,web08,web09,w
 
 @hosts = Rex::Commands::evaluate_hostname("web[01..10]:5000");
 ok(join(",", @hosts) eq "web01:5000,web02:5000,web03:5000,web04:5000,web05:5000,web06:5000,web07:5000,web08:5000,web09:5000,web10:5000", "host evaluation 2");
-
@@ -1,7 +1,7 @@
-use Test::More tests => 4; 
+use Test::More tests => 5;
 
 use_ok 'Rex::Cloud::Amazon';
 use_ok 'Rex::Cloud::Base';
 use_ok 'Rex::Cloud::Jiffybox';
+use_ok 'Rex::Cloud::OpenStack';
 use_ok 'Rex::Cloud';
-
@@ -1,4 +1,4 @@
-use Test::More tests => 17;
+use Test::More tests => 19;
 
 use_ok 'Rex::Commands::Inventory';
 
@@ -18,4 +18,5 @@ use_ok 'Rex::Inventory::Hal::Object';
 use_ok 'Rex::Inventory::Hal';
 use_ok 'Rex::Inventory::HP::ACU';
 use_ok 'Rex::Inventory';
-
+use_ok 'Rex::Inventory::Proc';
+use_ok 'Rex::Inventory::Proc::Cpuinfo';
@@ -0,0 +1,13 @@
+use Test::More tests => 2;
+
+use_ok 'Rex::Commands::Run';
+
+Rex::Commands::Run->import;
+
+if($^O =~ m/^MSWin/) {
+   ok(1==1, "skipped for winfows");
+}
+else {
+   my $s = run("printenv REX", env => { 'REX' => 'XER' } );
+   ok($s =~ m/XER/, "run with env");
+}
@@ -5,7 +5,7 @@ use Cwd 'getcwd';
 my $cwd = getcwd;
 
 BEGIN {
-   use Test::More tests => 44;
+   use Test::More tests => 45;
    use Data::Dumper;
 
    use_ok 'Rex';
@@ -27,166 +27,167 @@ if($^O =~ m/^MSWin/) {
    $tmp_dir = $ENV{TMP};
 }
 
-file("$cwd/test.txt",
+my $filename = "$cwd/test-$$.txt";
+
+file($filename,
    content => "blah blah\nfoo bar");
 
-my $c = cat("$cwd/test.txt");
+my $c = cat($filename);
 
 ok($c, "cat");
 ok($c =~ m/blah/, "file with content (1)");
 ok($c =~ m/bar/, "file with content (2)");
 
-Rex::Commands::Fs::unlink("$cwd/test.txt");
+Rex::Commands::Fs::unlink($filename);
 
-ok(! is_file("$cwd/test.txt"), "file removed");
+ok(! is_file($filename), "file removed");
 
-file("$cwd/test.txt",
+file($filename,
    content => "blah blah\nbaaazzzz",
    mode => 777);
 
-my %stats = Rex::Commands::Fs::stat("$cwd/test.txt");
+my %stats = Rex::Commands::Fs::stat($filename);
 ok($stats{mode} eq "0777" || is_windows(), "fs chmod ok");
 
 my $changed = 0;
-my $content = cat("$cwd/test.txt");
+my $content = cat($filename);
 ok($content !~ m/change/gms, "found change");
 
-append_if_no_such_line("$cwd/test.txt", "change", qr{change}, 
+append_if_no_such_line($filename, "change", qr{change},
    on_change => sub {
       $changed = 1;
    });
 
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/change/gms, "found change");
 
 ok($changed == 1, "something was changed in the file");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
    line => "dream-breaker",
    regexp => qr{^dream-breaker$});
 
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/dream\-breaker/gms, "found dream-breaker");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
    line => "#include /etc/sudoers.d/*.conf",
    regexp => qr{^#include /etc/sudoers.d/*.conf$});
 
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/#include \/etc\/sudoers\.d\/\*\.conf/gms, "found sudoers entry");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
    line => 'silly with "quotes"');
 
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/silly with "quotes"/gms, "found entry with quotes");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
    line => "#include /etc/sudoers.d/*.conf");
 
-my @content = split(/\n/, cat("$cwd/test.txt"));
+my @content = split(/\n/, cat($filename));
 ok($content[-1] ne "#include /etc/sudoers.d/*.conf", "last entry is not #include ...");
 
-append_if_no_such_line("$cwd/test.txt", 'KEY="VAL"');
-$content = cat("$cwd/test.txt");
+append_if_no_such_line($filename, 'KEY="VAL"');
+$content = cat($filename);
 ok($content =~ m/KEY="VAL"/gms, "found KEY=VAL");
 
-append_if_no_such_line("$cwd/test.txt", "change", qr{change}, 
+append_if_no_such_line($filename, "change", qr{change},
    on_change => sub {
       $changed = 0;
    });
 
 ok($changed == 1, "nothing was changed in the file");
 
-append_if_no_such_line("$cwd/test.txt", "change",
+append_if_no_such_line($filename, "change",
    on_change => sub {
       $changed = 0;
    });
 
 ok($changed == 1, "nothing was changed in the file without regexp");
 
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content !~ m/foobar/gms, "not found foobar");
 
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "foobar",
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/foobar/gms, "found foobar");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "bazzada",
       regexp => qr{^foobar},
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 
 ok($content !~ m/bazzada/gms, "found bazzada");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "tacktack",
       regexp => qr{blah blah}ms,
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 
 ok($content !~ m/tacktack/gms, "not found tacktack");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "nothing there",
       regexp => [qr{blah blah}ms, qr{tzuhgjbn}ms],
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 
 ok($content !~ m/nothing there/gms, "not found nothing there");
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "this is there",
       regexp => [qr{qaywsx}ms, qr{tzuhgjbn}ms],
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 
 ok($content =~ m/this is there/gms, "found this is there");
 
 
 
-append_if_no_such_line("$cwd/test.txt",
+append_if_no_such_line($filename,
       line => "bazzada",
       regexp => qr{^bazzada},
 );
-$content = cat("$cwd/test.txt");
+$content = cat($filename);
 ok($content =~ m/bazzada/gms, "found bazzada (2)");
 
-
-
-file "file with space.txt",
+file "file with space-$$.txt",
    content => "file with space\n";
 
-ok(is_file("file with space.txt"), "file with space exists");
+ok(is_file("file with space-$$.txt"), "file with space exists");
 
 $c = "";
-$c = cat "file with space.txt";
+$c = cat "file with space-$$.txt";
 ok($c =~ m/file with space/m, "found content of file with space");
 
-Rex::Commands::Fs::unlink("$cwd/test.txt");
-Rex::Commands::Fs::unlink("file with space.txt");
+Rex::Commands::Fs::unlink($filename);
+Rex::Commands::Fs::unlink("file with space-$$.txt");
 
-ok(! is_file("$cwd/test.txt"), "test.txt removed");
-ok(! is_file("file with space.txt"), "file with space removed");
+ok(! is_file($filename), "test.txt removed");
+ok(! is_file("file with space-$$.txt"), "file with space removed");
 
+$filename = "$tmp_dir/test-sed-$$.txt";
 
-file "$tmp_dir/test-sed.txt",
+file $filename,
    content => "this is a sed test file\nthese are just some lines\n0505\n0606\n0707\n'foo'\n/etc/passwd\n\"baz\"\n{klonk}\nfoo bar\n\\.-~'[a-z]\$ foo {1} /with/some/slashes \%\&()?\n|.-\\~'[a-z]\$ bar {2} /with/more/slashes \%\&()?\n";
 
-sed qr/fo{2} bar/, "baz bar", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr/fo{2} bar/, "baz bar", $filename;
+$content = cat $filename;
 ok($content =~ m/baz bar/, "sed replaced foo bar");
 
-sed qr/^\\\.\-\~'\[a\-z\]\$ foo \{1\} \/with\/some\/slashes/, "got replaced", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr/^\\\.\-\~'\[a\-z\]\$ foo \{1\} \/with\/some\/slashes/, "got replaced", $filename;
+$content = cat $filename;
 ok($content =~ m/got replaced/, "sed replaced strange chars");
 
-sed qr/^\|\.\-\\\~'\[a\-z\]\$ BAR \{2\} \/with\/more\/slashes/i, "got another replace", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr/^\|\.\-\\\~'\[a\-z\]\$ BAR \{2\} \/with\/more\/slashes/i, "got another replace", $filename;
+$content = cat $filename;
 ok($content =~ m/got another replace/, "sed replaced strange chars");
 
 my @lines = split(/\n/, $content);
@@ -194,33 +195,41 @@ ok($lines[-1] =~ m/^got another replace/, "last line was successfully replaced")
 ok($lines[-2] =~ m/^got replaced/, "second last line was successfully replaced");
 ok($lines[-4] =~ m/^\{klonk\}/, "fourth last line untouched");
 
-sed qr{0606}, "6666", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr{0606}, "6666", $filename;
+$content = cat $filename;
 ok($content =~ m/6666/, "sed replaced 0606");
 
-sed qr{'foo'}, "'bar'", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr{'foo'}, "'bar'", $filename;
+$content = cat $filename;
 ok($content =~ m/'bar'/, "sed replaced 'foo'");
 
-sed qr{/etc/passwd}, "/etc/shadow", "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr{/etc/passwd}, "/etc/shadow", $filename;
+$content = cat $filename;
 ok($content =~ m/\/etc\/shadow/, "sed replaced /etc/passwd");
 
-sed qr{"baz"}, '"boooooz"', "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr{"baz"}, '"boooooz"', $filename;
+$content = cat $filename;
 ok($content =~ m/"boooooz"/, "sed replaced baz");
 
-sed qr/{klonk}/, '{plonk}', "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr/{klonk}/, '{plonk}', $filename;
+$content = cat $filename;
 ok($content =~ m/{plonk}/, "sed replaced {klonk}");
 
-sed qr/{klonk}/, '{plonk}', "$tmp_dir/test-sed.txt";
-$content = cat "$tmp_dir/test-sed.txt";
+sed qr/{klonk}/, '{plonk}', $filename;
+$content = cat $filename;
 ok($content =~ m/{plonk}/, "sed replaced {klonk}");
 
-file "$tmp_dir/multiline.txt", content => "this is\na test.\n";
-sed qr/is\sa test/msi, "no one\nknows!", "$tmp_dir/multiline.txt", multiline => 1;
-$content = cat "$tmp_dir/multiline.txt";
+unlink $filename;
+
+file "$tmp_dir/multiline-$$.txt", content => "this is\na test.\n";
+sed qr/is\sa test/msi, "no one\nknows!", "$tmp_dir/multiline-$$.txt", multiline => 1;
+$content = cat "$tmp_dir/multiline-$$.txt";
 is($content,  "this no one\nknows!.\n", "multiline replacement");
 
-unlink "$tmp_dir/multiline.txt";
+unlink "$tmp_dir/multiline-$$.txt";
+
+file "$tmp_dir/test.d-$$",
+   ensure => "directory";
+
+ok(-d "$tmp_dir/test.d-$$", "created directory with file()");
+rmdir "$tmp_dir/test.d-$$";
@@ -0,0 +1,7 @@
+ppp0      Link encap:Point-to-Point Protocol
+          inet addr:123.117.251.17  P-t-P:234.165.249.179  Mask:255.255.255.255
+          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1454  Metric:1
+          RX packets:4143329786 errors:0 dropped:0 overruns:0 frame:0
+          TX packets:754829057 errors:0 dropped:0 overruns:0 carrier:0
+          collisions:0 txqueuelen:3
+          RX bytes:1171440390 (1.0 GiB)  TX bytes:121847007 (116.2 MiB)
@@ -0,0 +1,3 @@
+4: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP> mtu 1454 qdisc pfifo_fast qlen 3
+    link/ppp
+    inet 123.117.251.17 peer 234.165.249.179/32 scope global ppp0
@@ -1,5 +1,5 @@
 use Data::Dumper;
-use Test::More tests => 38;
+use Test::More tests => 46;
 use_ok 'Rex::Hardware::Network::Linux';
 use_ok 'Rex::Helper::Hash';
 
@@ -70,4 +70,16 @@ ok($info->{"eth0:1"}->{ip} eq "1.2.3.4", "(fc19) eth0:1 / ip");
 ok($info->{"eth0:1"}->{netmask} eq "255.255.0.0", "(fc19) eth0:1 / netmask");
 ok($info->{"eth0:1"}->{mac} eq "52:54:00:37:a8:e1", "(fc19) eth0:1 / mac");
 
+@in = eval { local(@ARGV) = ("t/ifconfig.out7"); <>; };
+$info = Rex::Hardware::Network::Linux::_parse_ifconfig(@in);
+ok($info->{ppp0}->{ip} eq "123.117.251.17", "ppp0 / ip");
+ok($info->{ppp0}->{netmask} eq "255.255.255.255", "ppp0 / netmask");
+ok($info->{ppp0}->{broadcast} eq "", "ppp0 / broadcast");
+ok($info->{ppp0}->{mac} eq "", "ppp0 / mac");
 
+@in = eval { local(@ARGV) = ("t/ip.out3"); <>; };
+$info = Rex::Hardware::Network::Linux::_parse_ip(@in);
+ok($info->{ppp0}->{ip} eq "123.117.251.17", "ppp0 / ip");
+ok($info->{ppp0}->{netmask} eq "255.255.255.255", "ppp0 / netmask");
+ok($info->{ppp0}->{broadcast} eq "", "ppp0 / broadcast");
+ok($info->{ppp0}->{mac} eq "", "ppp0 / mac");
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 7;
 
 use_ok 'Rex';
 use_ok 'Rex::Commands';
@@ -11,3 +11,9 @@ use_ok 'Rex::Commands::Virtualization';
 Rex::Commands::set(virtualization => "LibVirt");
 ok(Rex::Config->get("virtualization") eq "LibVirt", "set virtualization handler");
 
+Rex::Commands::set(
+    virtualization => { "type" => "LibVirt", "connect" => "qemu:///system", } );
+is( Rex::Config->get("virtualization")->{type},
+    "LibVirt", "Virtualization type with connection URI" );
+is( Rex::Config->get("virtualization")->{connect},
+    "qemu:///system", "Virtualization URI with connection URI" );