Ansible::Util::Vars
version 0.001
$vars = Ansible::Util::Vars->new; $href = $vars->getVar('foo'); $href = $vars->getVars(['foo', 'bar']); $val = $vars->getValue('foo');
Read Ansible runtime vars into native Perl.
To indicate which vars to read, you use the variable dot notation similar to what is described in the Ansible documentation. Further information about the Perl implementation can be found in Hash::DotPath.
An optional cache layer is used to speed up multiple invocations.
A list of vault-password-files to pass to the command line.
Toggle to disable/enable caching.
Controls how long to hold onto cached data.
Choose which managed nodes or groups you want to execute against. This format of this is exactly the same as defined in "Patterns: targeting hosts and groups" by the Ansible documentation.
Keeps the generated tempfiles for debugging/troubleshooting. The tempfiles used are a playbook, template, and json output.
This is a toggle to keep the generated tempfiles when Ansible exits with an error.
All methods confess on error unless otherwise specified.
Clears any cached vars.
$vars->clearCache;
none
Disables caching.
$vars->disableCache;
The previous value of the attribute 'cacheEnabled'.
Enables caching.
$vars->enableCache;
Fetches the value of the specified var.
$val = $vars->getValue($path);
The value found at the specified path.
The path to the variable in dot notation. See Hash::DotPath for more info.
Fetches the variable found at the specified path.
$href = $vars->getVar($path);
A hash reference containing the requested var. Note that this also includes each of the elements in the path. Examples:
$href = $vars->getVar('foo.bar'); Data::Printer::p($href); \ { foo { bar "somevalue" } } $href = $vars->getVar('biz.0.baz'); Data::Printer::p($href); \ { biz [ [0] { baz "anothervalue" } ] }
Fetches the variables found at the specified path.
$href = $vars->getVars(['foo.0.bar', 'biz']);
A hash reference containing the requested vars. The characteristics are the same as described in "getVar" except that the vars are merged into a single hash ref.
To install Ansible::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ansible::Util
CPAN shell
perl -MCPAN -e shell install Ansible::Util
For more information on module installation, please visit the detailed CPAN module installation guide.