1Rex::Config(3) User Contributed Perl Documentation Rex::Config(3)
2
3
4
6 Rex::Config - Handles Rex configuration
7
9 This module holds all configuration parameters for Rex, and also allows
10 you to specify your own configuration parameters for your modules.
11
13 set_autodie
14 get_autodie
15 Sets and gets the value of the $autodie configuration variable.
16
17 This controls whether Rex should "die()" if there's an error while
18 executing file system commands that are supposed to change the
19 contents.
20
21 Default is "undef".
22
23 set_use_net_openssh_if_present
24 get_use_net_openssh_if_present
25 Sets and gets the value of the $use_net_openssh_if_present
26 configuration variable.
27
28 This controls whether Rex should use Net::OpenSSH for connections if
29 that is available.
30
31 Default is "undef".
32
33 set_use_rex_kvm_agent
34 get_use_rex_kvm_agent
35 Sets and gets the value of the $use_rex_kvm_agent configuration
36 variable.
37
38 This controls whether Rex should setup and use a serial device for the
39 experimental Rex KVM agent <https://github.com/RexOps/rex-kvm-agent>
40 for managed VMs.
41
42 Default is "undef".
43
44 set_use_template_ng
45 get_use_template_ng
46 Sets and gets the value of the $use_template_ng configuration variable.
47
48 This controls whether Rex should use Rex::Template::NG to render
49 templates.
50
51 Default is "undef".
52
53 set_set_no_append
54 get_set_no_append
55 Sets and gets the value of the $set_no_append configuration variable.
56
57 This controls whether Rex should overwrite or append values of
58 configuration options when using the set command.
59
60 Default is "undef".
61
62 set_check_service_exists
63 get_check_service_exists
64 Sets and gets the value of the $check_service_exists configuration
65 variable.
66
67 This controls whether Rex should "die()" early if it is asked to manage
68 a service that doesn't exist.
69
70 Default is "undef".
71
72 set_register_cmdb_template
73 get_register_cmdb_template
74 Sets and gets the value of the $register_cmdb_template configuration
75 variable.
76
77 This controls whether Rex should make CMDB data available to be used in
78 templates as variables.
79
80 Default is "undef".
81
82 set_fallback_auth
83 get_fallback_auth
84 Sets and gets the value of the $fallback_auth configuration variable.
85
86 This can be used to define an array of hash references, each of them
87 containing authentication details to be tried during connection
88 attempts when the directly specified ones fail.
89
90 Default is "undef".
91
92 set_task_call_by_method
93 get_task_call_by_method
94 Sets and gets the value of the $task_call_by_method configuration
95 variable.
96
97 This controls whether calling tasks as a method is allowed or not.
98
99 Default is "undef".
100
101 set_disable_taskname_warning
102 get_disable_taskname_warning
103 Sets and gets the value of the $disable_taskname_warning configuration
104 variable.
105
106 This controls whether Rex should show or suppress the warning message
107 about task names that can not be used as Perl identifiers.
108
109 Default is "undef".
110
111 set_task_chaining_cmdline_args
112 get_task_chaining_cmdline_args
113 Sets and gets the value of the $task_chaining_cmdline_args
114 configuration variable.
115
116 This controls whether Rex should parse task arguments on the command
117 line per task, or should pass all arguments to all tasks.
118
119 Default is "undef".
120
121 set_verbose_run
122 get_verbose_run
123 Sets and gets the value of the $verbose_run configuration variable.
124
125 This controls whether Rex should show verbose output about executed run
126 commands. This means an error message if the command is not found, a
127 warning message if the exit code indicates an error, and an
128 informational message upon success.
129
130 Default is "undef".
131
132 set_exec_autodie
133 get_exec_autodie
134 Sets and gets the value of the $exec_autodie configuration variable.
135
136 This controls whether Rex should "die()" or not when the exit code of
137 executed run command indicate an error.
138
139 Default is "undef".
140
141 set_no_path_cleanup
142 get_no_path_cleanup
143 Sets and gets the value of the $no_path_cleanup configuration variable.
144
145 This controls whether Rex should clean up the $PATH before executing a
146 run command.
147
148 Default is "undef".
149
150 set_source_profile
151 get_source_profile
152 Sets and gets the value of the $source_profile configuration variable.
153
154 This controls whether Rex should source shell-specific profile files
155 before executing commands.
156
157 Default is "undef".
158
159 set_say_format
160 get_say_format
161 Sets and gets the value of the $say_format configuration variable.
162
163 This controls the output format of the built-in "say" command (see also
164 sayformat).
165
166 Default is "undef".
167
168 set_do_reporting
169 get_do_reporting
170 Sets and gets the value of the $do_reporting configuration variable.
171
172 This controls whether Rex should do reporting on executed resources
173 where it is supported. This only affects the data structures returned
174 internally.
175
176 Default is "undef".
177
178 set_report_type
179 get_report_type
180 Sets and gets the value of the $report_type configuration variable,
181 which can also be controlled via the "REX_REPORT_TYPE" environment
182 variable.
183
184 This selects the reporting type (format) Rex should use, e.g. 'YAML'.
185
186 Default is "undef".
187
188 set_sleep_hack
189 get_sleep_hack
190 Sets and gets the value of the $sleep_hack configuration variable.
191
192 This controls whether Rex should use or not an extra 10 ns long sleep
193 after executed commands.
194
195 This might help working around an issue when Rex runs inside a KVM
196 virtualized host and Net::SSH2/libssh2 <https://www.libssh2.org> is
197 used to connect to another VM on the same hardware.
198
199 Default is "undef".
200
201 set_cache_type
202 get_cache_type
203 Sets and gets the value of the $cache_type configuration variable,
204 which can also be controlled via the "REX_CACHE_TYPE" environment
205 variable.
206
207 This selects the cache type Rex should use, e.g. 'YAML'.
208
209 Default is 'Base'.
210
211 set_use_cache
212 get_use_cache
213 Sets and gets the value of the $use_cache configuration variable.
214
215 This controls whether Rex should use caching or not for runtime
216 information like CMDB contents, hardware and operating system
217 information, or the shell type that is being used to execute commands
218 on the managed endpoint.
219
220 Default is "undef".
221
222 set_openssh_opt
223 get_openssh_opt
224 Sets and gets the value of the $openssh_opt configuration variable.
225
226 This sets the hash containing OpenSSH options Rex should use when using
227 Net::OpenSSH for SSH connections.
228
229 Default is "undef".
230
231 set_sudo_without_locales
232 get_sudo_without_locales
233 Sets and gets the value of the $sudo_without_locales configuration
234 variable.
235
236 This controls whether Rex should execute sudo commands without setting
237 any locales via the "LC_ALL" environment variable.
238
239 Warning: if the locale is something else than "C" or "en_US", then
240 things will break!
241
242 Default is "undef".
243
244 set_sudo_without_sh
245 get_sudo_without_sh
246 Sets and gets the value of the $sudo_without_sh configuration variable.
247
248 This controls whether Rex should run sudo commands without "sh". This
249 might break things.
250
251 Default is "undef".
252
253 set_executor_for
254 get_executor_for
255 Sets and gets the keys and values of the %executor_for configuration
256 variable.
257
258 This sets the executor for a given file type when using the
259 "upload_and_run()" function of Rex::Helper::Run module.
260
261 Default is:
262
263 (
264 perl => 'perl',
265 python => 'python',
266 ruby => 'ruby',
267 bash => 'bash',
268 )
269
270 set_tmp_dir
271 get_tmp_dir
272 Sets and gets the value of the $tmp_dir configuration variable.
273
274 This controls which directory Rex should use for temporary files.
275
276 Default is determined by the following logic:
277
278 · try to use what "File::Spec->tmpdir" would return on the managed
279 endpoint
280
281 · fall back to '/tmp'
282
283 set_path
284 get_path
285 Sets and gets the value of the $path configuration variable.
286
287 This controls which "PATH" Rex should use when executing run commands.
288 The value should be set as an array reference, and will be dereferenced
289 as such before returned by "get_path".
290
291 Default is
292
293 qw(
294 /bin
295 /sbin
296 /usr/bin
297 /usr/sbin
298 /usr/local/bin
299 /usr/local/sbin
300 /usr/pkg/bin
301 /usr/pkg/sbin
302 )
303
304 set_user
305 get_user
306 Sets and gets the value of the $user configuration variable, which also
307 can be set via the "REX_USER" environment variable.
308
309 This controls which user Rex should use for authentication.
310
311 Default is determined by the following logic:
312
313 · value of "REX_USER" environment variable
314
315 · user set by user command
316
317 · user running Rex
318
319 set_password
320 get_password
321 Sets and gets the value of the $password configuration variable, which
322 also can be set via the "REX_PASSWORD" environment variable.
323
324 This controls what password Rex should use for authentication or as
325 passphrase when using private keys.
326
327 Default is "undef".
328
329 set_port
330 get_port
331 Sets and gets the value of the $port configuration variable.
332
333 This controls which port Rex should connect to.
334
335 "get_port" accepts an optional "server => $server" argument to return
336 the "port" setting for the given $server as optionally set in group
337 files.
338
339 Default is "undef".
340
341 set_sudo_password
342 get_sudo_password
343 Sets and gets the value of the $sudo_password configuration variable,
344 which can also be controlled via the "REX_SUDO_PASSWORD" environment
345 variable.
346
347 This controls what sudo password Rex should use.
348
349 Default is determined by the following logic:
350
351 · value of "REX_SUDO_PASSWORD" environment variable
352
353 · sudo password set by the sudo_password command
354
355 · password set by the password command
356
357 · empty string ('')
358
359 set_source_global_profile
360 get_source_global_profile
361 Sets and gets the value of the $source_global_profile configuration
362 variable.
363
364 This controls whether Rex should source "/etc/profile" before executing
365 commands.
366
367 Default is "undef".
368
369 set_max_connect_fails
370 get_max_connect_fails
371 Sets and gets the value of the $max_connect_fails configuration
372 variable.
373
374 This controls how many times Rex should retry to connect before giving
375 up.
376
377 "get_max_connect_fails" accepts an optional "server => $server"
378 argument to "connectionattempts" setting for the given $server as
379 optionally set in group files.
380
381 Default is "undef".
382
383 set_proxy_command
384 get_proxy_command
385 Sets and gets the value of the $proxy_command configuration variable.
386
387 This controls the SSH ProxyCommand Rex should set for connections when
388 Net::OpenSSH is used.
389
390 "get_proxy_command" accepts an optional "server => $server" argument to
391 return the "proxycommand" setting for the given $server as optionally
392 set in group files.
393
394 Default is "undef".
395
396 set_timeout
397 get_timeout
398 Sets and gets the value of the $timeout configuration variable.
399
400 This controls how many seconds Rex should wait for connections to
401 succeed when using SSH or Rex::Commands::Rsync.
402
403 "get_timeout" accepts an optional "server => $server" argument to
404 return the "connecttimeout" setting for the given $server as optionally
405 set in group files.
406
407 Default is "undef".
408
409 set_password_auth
410 get_password_auth
411 Sets and gets the value of the $password_auth configuration variable,
412 which can also be set by setting the "REX_AUTH_TYPE" environment
413 variable to "pass".
414
415 This controls whether Rex should use the password authentication
416 method.
417
418 Default is "undef".
419
420 set_key_auth
421 get_key_auth
422 Sets and gets the value of the $key_auth configuration variable, which
423 can also be set by setting the "REX_AUTH_TYPE" environment variable to
424 "key".
425
426 This controls whether Rex should use the key authentication method.
427
428 Default is "undef".
429
430 set_krb5_auth
431 get_krb5_auth
432 Sets and gets the value of the $krb5_auth configuration variable, which
433 can also be set by setting the "REX_AUTH_TYPE" environment variable to
434 "krb5".
435
436 This controls whether Rex should use the Kerberos 5 authentication
437 method.
438
439 Default is "undef".
440
441 set_public_key
442 get_public_key
443 Sets and gets the value of the $public_key configuration variable.
444
445 This controls which public key Rex should use when using Net::SSH2 for
446 connections.
447
448 Default is "undef".
449
450 set_private_key
451 get_private_key
452 Sets and gets the value of the $private_key configuration variable.
453
454 This controls which private key Rex should use with
455 Rex::Commands::Rsync or when using Net::SSH2 for connections.
456
457 Default is "undef".
458
459 set_parallelism
460 get_parallelism
461 Sets and gets the value of the $parallelism configuration variable.
462
463 This controls how many hosts Rex should connect to in parallel.
464
465 Default is 1.
466
467 set_log_filename
468 get_log_filename
469 Sets and gets the value of the $log_filename configuration variable.
470
471 This controls which file Rex should use for logging.
472
473 Default is "undef".
474
475 set_log_facility
476 get_log_facility
477 Sets and gets the value of the $log_facility configuration variable.
478
479 This controls which log facility Rex should use when logging to syslog.
480
481 Default is 'local0'.
482
483 set_environment
484 get_environment
485 Sets and gets the value of the $environment configuration variable.
486
487 This controls which environment Rex should use.
488
489 Default is ''.
490
491 set_distributor
492 get_distributor
493 Sets and gets the value of the $distributor configuration variable.
494
495 This controls which method Rex should use for distributing tasks for
496 parallel execution.
497
498 Default is 'Base'.
499
500 set_template_function
501 get_template_function
502 Sets and gets the value of the $template_function configuration
503 variable.
504
505 This controls the function to be used for rendering templates. The
506 value should be a subroutine reference that will be called with passing
507 two scalar references as positional arguments: first is template
508 content, second is template variables.
509
510 Default is determined by the following logic:
511
512 · if Rex::Template::NG is loadable and use_template_ng is true, use
513 that
514
515 · fall back to Rex::Template otherwise
516
517 set_no_tty
518 get_no_tty
519 Sets and gets the value of the $no_tty configuration variable.
520
521 This controls whether Rex should request a terminal when using
522 Net::SSH2 or allocate a pseudo-tty for the remote process when using
523 Net::OpenSSH.
524
525 Default is "undef".
526
527 set_allow_empty_groups
528 get_allow_empty_groups
529 Sets and gets the value of the $allow_empty_groups configuration
530 variable.
531
532 This controls whether Rex should allow empty groups of hosts or not.
533
534 Default is 0.
535
536 set_use_server_auth
537 get_use_server_auth
538 Sets and gets the value of the $use_server_auth configuration variable.
539
540 This controls whether Rex should use server-specific authentication
541 information from group files.
542
543 Default is 0.
544
545 set_waitpid_blocking_sleep_time
546 get_waitpid_blocking_sleep_time
547 Sets and gets the value of the $waitpid_blocking_sleep_time
548 configuration variable.
549
550 This controls how many seconds Rex should sleep between checking forks.
551
552 Default is 0.1.
553
554 set_write_utf8_files
555 get_write_utf8_files
556 Sets and gets the value of the $write_utf8_files configuration
557 variable.
558
559 This controls whether Rex should force "UTF-8" encoding when writing
560 files.
561
562 Default is "undef".
563
564 register_set_handler($handler_name, $code)
565 Register a handler that gets called by set.
566
567 Rex::Config->register_set_handler("foo", sub {
568 my ($value) = @_;
569 print "The user set foo -> $value\n";
570 });
571
572 And now you can use this handler in your Rexfile like this:
573
574 set foo => "bar";
575
576 register_config_handler($topic, $code)
577 With this function it is possible to register own sections in the users
578 config file ("$HOME/.rex/config.yml").
579
580 Example:
581
582 Rex::Config->register_config_handler("foo", sub {
583 my ($param) = @_;
584 print "bar is: " . $param->{bar} . "\n";
585 });
586
587 And now the user can set this in his configuration file:
588
589 base:
590 user: theuser
591 password: thepassw0rd
592 foo:
593 bar: baz
594
595
596
597perl v5.30.2 2020-04-06 Rex::Config(3)