GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Rex::Config(3) User Contributed Perl Documentation Rex::Config(3)

Rex::Config - Handles Rex configuration

 use Rex::Config;

 # set a config option
 Rex::Config->set_exec_autodie(TRUE);

 # get value of a config option
 my $user = Rex::Config->get_user();

This module holds all configuration options for Rex, and also allows you to specify your own ones for your modules.

Please take a look at Rex::Commands first, which provides convenience wrappers for many of these options.

While it's possible to use the methods below to set a configuration option directly, their main intended purpose is to be used as internal plumbing, and to provide an escape hatch in case there are no better alternatives.

Sets and gets the value of the $autodie configuration variable.

This controls whether Rex should "die()" if there's an error while executing file system commands that are supposed to change the contents.

Default is "undef".

Sets and gets the value of the $use_net_openssh_if_present configuration variable.

This controls whether Rex should use Net::OpenSSH for connections if that is available.

Default is "undef".

Sets and gets the value of the $use_rex_kvm_agent configuration variable.

This controls whether Rex should setup and use a serial device for the experimental Rex KVM agent <https://github.com/RexOps/rex-kvm-agent> for managed VMs.

Default is "undef".

Sets and gets the value of the $use_template_ng configuration variable.

This controls whether Rex should use Rex::Template::NG to render templates.

Default is "undef".

Sets and gets the value of the $set_no_append configuration variable.

This controls whether Rex should overwrite or append values of configuration options when using the set command.

Default is "undef".

Sets and gets the value of the $check_service_exists configuration variable.

This controls whether Rex should "die()" early if it is asked to manage a service that doesn't exist.

Default is "undef".

Sets and gets the value of the $register_cmdb_template configuration variable.

This controls whether Rex should make CMDB data available to be used in templates as variables.

Default is "undef".

Sets and gets the value of the $fallback_auth configuration variable.

This can be used to define an array of hash references, each of them containing authentication details to be tried during connection attempts when the directly specified ones fail.

Default is "undef".

Sets and gets the value of the $task_call_by_method configuration variable.

This controls whether calling tasks as a method is allowed or not.

Default is "undef".

Sets and gets the value of the $disable_taskname_warning configuration variable.

This controls whether Rex should show or suppress the warning message about task names that can not be used as Perl identifiers.

Default is "undef".

Sets and gets the value of the $task_chaining_cmdline_args configuration variable.

This controls whether Rex should parse task arguments on the command line per task, or should pass all arguments to all tasks.

Default is "undef".

Sets and gets the value of the $verbose_run configuration variable.

This controls whether Rex should show verbose output about executed run commands. This means an error message if the command is not found, a warning message if the exit code indicates an error, and an informational message upon success.

Default is "undef".

Sets and gets the value of the $exec_autodie configuration variable.

This controls whether Rex should "die()" or not when the exit code of executed run command indicate an error.

Default is "undef".

Sets and gets the value of the $no_path_cleanup configuration variable.

This controls whether Rex should clean up the $PATH before executing a run command.

Default is "undef".

Sets and gets the value of the $source_profile configuration variable.

This controls whether Rex should source shell-specific profile files before executing commands.

Default is "undef".

Sets and gets the value of the $say_format configuration variable.

This controls the output format of the built-in "say" command (see also sayformat).

Default is "undef".

Sets and gets the value of the $do_reporting configuration variable.

This controls whether Rex should do reporting on executed resources where it is supported. This only affects the data structures returned internally.

Default is "undef".

Sets and gets the value of the $report_type configuration variable, which can also be controlled via the "REX_REPORT_TYPE" environment variable.

This selects the reporting type (format) Rex should use, e.g. 'YAML'.

Default is "undef".

Sets and gets the value of the $sleep_hack configuration variable.

This controls whether Rex should use or not an extra 10 ns long sleep after executed commands.

This might help working around an issue when Rex runs inside a KVM virtualized host and Net::SSH2/libssh2 <https://www.libssh2.org> is used to connect to another VM on the same hardware.

Default is "undef".

Sets and gets the value of the $cache_type configuration variable, which can also be controlled via the "REX_CACHE_TYPE" environment variable.

This selects the cache type Rex should use, e.g. 'YAML'.

Default is 'Base'.

Sets and gets the value of the $use_cache configuration variable.

This controls whether Rex should use caching or not for runtime information like CMDB contents, hardware and operating system information, or the shell type that is being used to execute commands on the managed endpoint.

Default is "undef".

Sets and gets the value of the $openssh_opt configuration variable, which holds a hash of the SSH configuration options used for the connection. See the ssh_config(5) man page <http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5> for the available options.

  Rex::Config->set_openssh_opt( $option => $value, );

There is a custom option named "initialize_options" specific to Rex, which can be used to pass a hash reference describing the constructor parameters <https://metacpan.org/pod/Net::OpenSSH#Net::OpenSSH->new($host,-%opts)> for the underlying Net::OpenSSH object:

 Rex::Config->set_openssh_opt( initialize_options => { $parameter => $value, } );

Default is "undef".

Sets and gets the value of the $sudo_without_locales configuration variable.

This controls whether Rex should execute sudo commands without setting any locales via the "LC_ALL" environment variable.

Warning: if the locale is something else than "C" or "en_US", then things will break!

Default is "undef".

Sets and gets the value of the $sudo_without_sh configuration variable.

This controls whether Rex should run sudo commands without "sh". This might break things.

Default is "undef".

Sets and gets the keys and values of the %executor_for configuration variable.

This sets the executor for a given file type when using the "upload_and_run()" function of Rex::Helper::Run module.

Default is:

 (
   perl   => 'perl',
   python => 'python',
   ruby   => 'ruby',
   bash   => 'bash',
 )

Sets and gets the value of the $tmp_dir configuration variable.

This controls which directory Rex should use for temporary files.

Default is determined by the following logic:

  • try to use what "File::Spec->tmpdir" would return on the managed endpoint
  • fall back to '/tmp'

Sets and gets the value of the $path configuration variable.

This controls which "PATH" Rex should use when executing run commands. The value should be set as an array reference, and will be dereferenced as such before returned by "get_path".

Default is

 qw(
   /bin
   /sbin
   /usr/bin
   /usr/sbin
   /usr/local/bin
   /usr/local/sbin
   /usr/pkg/bin
   /usr/pkg/sbin
 )

Sets and gets the value of the $user configuration variable, which also can be set via the "REX_USER" environment variable.

This controls which user Rex should use for authentication.

Default is determined by the following logic:

  • value of "REX_USER" environment variable
  • user set by user command
  • user running Rex

Sets and gets the value of the $password configuration variable, which also can be set via the "REX_PASSWORD" environment variable.

This controls what password Rex should use for authentication or as passphrase when using private keys.

Default is "undef".

Sets and gets the value of the $port configuration variable.

This controls which port Rex should connect to.

"get_port" accepts an optional "server => $server" argument to return the "port" setting for the given $server as optionally set in group files.

Default is "undef".

Sets and gets the value of the $sudo_password configuration variable, which can also be controlled via the "REX_SUDO_PASSWORD" environment variable.

This controls what sudo password Rex should use.

Default is determined by the following logic:

  • value of "REX_SUDO_PASSWORD" environment variable
  • sudo password set by the sudo_password command
  • password set by the password command
  • empty string ('')

Sets and gets the value of the $source_global_profile configuration variable.

This controls whether Rex should source "/etc/profile" before executing commands.

Default is "undef".

Sets and gets the value of the $max_connect_fails configuration variable.

This controls how many times Rex should retry to connect before giving up.

"get_max_connect_fails" accepts an optional "server => $server" argument to "connectionattempts" setting for the given $server as optionally set in group files.

Default is "undef".

Sets and gets the value of the $proxy_command configuration variable.

This controls the SSH ProxyCommand Rex should set for connections when Net::OpenSSH is used.

"get_proxy_command" accepts an optional "server => $server" argument to return the "proxycommand" setting for the given $server as optionally set in group files.

Default is "undef".

Sets and gets the value of the $timeout configuration variable.

This controls how many seconds Rex should wait for connections to succeed when using SSH or Rex::Commands::Rsync.

"get_timeout" accepts an optional "server => $server" argument to return the "connecttimeout" setting for the given $server as optionally set in group files.

Default is "undef".

Sets and gets the value of the $password_auth configuration variable, which can also be set by setting the "REX_AUTH_TYPE" environment variable to "pass".

This controls whether Rex should use the password authentication method.

Default is "undef".

Sets and gets the value of the $key_auth configuration variable, which can also be set by setting the "REX_AUTH_TYPE" environment variable to "key".

This controls whether Rex should use the key authentication method.

Default is "undef".

Sets and gets the value of the $krb5_auth configuration variable, which can also be set by setting the "REX_AUTH_TYPE" environment variable to "krb5".

This controls whether Rex should use the Kerberos 5 authentication method.

Default is "undef".

Sets and gets the value of the $public_key configuration variable.

This controls which public key Rex should use when using Net::SSH2 for connections.

Default is "undef".

Sets and gets the value of the $private_key configuration variable.

This controls which private key Rex should use with Rex::Commands::Rsync or when using Net::SSH2 for connections.

Default is "undef".

Sets and gets the value of the $parallelism configuration variable.

This controls how many hosts Rex should connect to in parallel.

Default is 1.

Sets and gets the value of the $log_filename configuration variable.

This controls which file Rex should use for logging.

Default is "undef".

Sets and gets the value of the $log_facility configuration variable.

This controls which log facility Rex should use when logging to syslog.

Default is 'local0'.

Sets and gets the value of the $environment configuration variable.

This controls which environment Rex should use.

Default is ''.

Sets and gets the value of the $distributor configuration variable.

This controls which method Rex should use for distributing tasks for parallel execution.

Default is 'Base'.

Sets and gets the value of the $template_function configuration variable.

This controls the function to be used for rendering templates. The value should be a subroutine reference that will be called with passing two scalar references as positional arguments: first is template content, second is template variables.

Default is determined by the following logic:

  • if Rex::Template::NG is loadable and use_template_ng is true, use that
  • fall back to Rex::Template otherwise

Sets and gets the value of the $no_tty configuration variable.

This controls whether Rex should request a terminal when using Net::SSH2 or allocate a pseudo-tty for the remote process when using Net::OpenSSH.

Default is "undef".

Sets and gets the value of the $allow_empty_groups configuration variable.

This controls whether Rex should allow empty groups of hosts or not.

Default is 0.

Sets and gets the value of the $use_server_auth configuration variable.

This controls whether Rex should use server-specific authentication information from group files.

Default is 0.

Sets and gets the value of the $waitpid_blocking_sleep_time configuration variable.

This controls how many seconds Rex should sleep between checking forks.

Default is 0.1.

Sets and gets the value of the $write_utf8_files configuration variable.

This controls whether Rex should force "UTF-8" encoding when writing files.

Default is "undef".

Sets and gets the value of the $default_auth configuration variable.

This controls whether Rex should attach default authentication info to tasks.

Default is 1.

Register a handler that gets called by set.

 Rex::Config->register_set_handler("foo", sub {
   my ($value) = @_;
   print "The user set foo -> $value\n";
 });

And now you can use this handler in your Rexfile like this:

 set foo => "bar";

With this function it is possible to register own sections in the users config file ("$HOME/.rex/config.yml").

Example:

 Rex::Config->register_config_handler("foo", sub {
  my ($param) = @_;
  print "bar is: " . $param->{bar} . "\n";
 });

And now the user can set this in his configuration file:

 base:
   user: theuser
   password: thepassw0rd
 foo:
   bar: baz
2021-07-05 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.