|
NAMERex::Config - Handles Rex configurationSYNOPSISuse Rex::Config; # set a config option Rex::Config->set_exec_autodie(TRUE); # get value of a config option my $user = Rex::Config->get_user(); DESCRIPTIONThis 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. EXPORTED METHODSset_autodieget_autodieSets 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". set_use_net_openssh_if_presentget_use_net_openssh_if_presentSets 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". set_use_rex_kvm_agentget_use_rex_kvm_agentSets 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". set_use_template_ngget_use_template_ngSets 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". set_set_no_appendget_set_no_appendSets 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". set_check_service_existsget_check_service_existsSets 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". set_register_cmdb_templateget_register_cmdb_templateSets 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". set_fallback_authget_fallback_authSets 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". set_task_call_by_methodget_task_call_by_methodSets 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". set_disable_taskname_warningget_disable_taskname_warningSets 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". set_task_chaining_cmdline_argsget_task_chaining_cmdline_argsSets 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". set_verbose_runget_verbose_runSets 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". set_exec_autodieget_exec_autodieSets 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". set_no_path_cleanupget_no_path_cleanupSets 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". set_source_profileget_source_profileSets 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". set_say_formatget_say_formatSets 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". set_do_reportingget_do_reportingSets 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". set_report_typeget_report_typeSets 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". set_sleep_hackget_sleep_hackSets 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". set_cache_typeget_cache_typeSets 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'. set_use_cacheget_use_cacheSets 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". set_openssh_optget_openssh_optSets 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". set_sudo_without_localesget_sudo_without_localesSets 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". set_sudo_without_shget_sudo_without_shSets 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". set_executor_forget_executor_forSets 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', ) set_tmp_dirget_tmp_dirSets 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:
set_pathget_pathSets 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 ) set_userget_userSets 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:
set_passwordget_passwordSets 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". set_portget_portSets 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". set_sudo_passwordget_sudo_passwordSets 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:
set_source_global_profileget_source_global_profileSets 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". set_max_connect_failsget_max_connect_failsSets 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". set_proxy_commandget_proxy_commandSets 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". set_timeoutget_timeoutSets 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". set_password_authget_password_authSets 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". set_key_authget_key_authSets 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". set_krb5_authget_krb5_authSets 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". set_public_keyget_public_keySets 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". set_private_keyget_private_keySets 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". set_parallelismget_parallelismSets and gets the value of the $parallelism configuration variable.This controls how many hosts Rex should connect to in parallel. Default is 1. set_log_filenameget_log_filenameSets and gets the value of the $log_filename configuration variable.This controls which file Rex should use for logging. Default is "undef". set_log_facilityget_log_facilitySets 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'. set_environmentget_environmentSets and gets the value of the $environment configuration variable.This controls which environment Rex should use. Default is ''. set_distributorget_distributorSets 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'. set_template_functionget_template_functionSets 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:
set_no_ttyget_no_ttySets 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". set_allow_empty_groupsget_allow_empty_groupsSets 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. set_use_server_authget_use_server_authSets 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. set_waitpid_blocking_sleep_timeget_waitpid_blocking_sleep_timeSets 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. set_write_utf8_filesget_write_utf8_filesSets 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". set_default_authget_default_authSets 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_set_handler($handler_name, $code)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"; register_config_handler($topic, $code)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
Visit the GSP FreeBSD Man Page Interface. |