class QB::Ansible::Env
@todo document QB::Ansible::Env
class.
Constants
- VAR_NAME_PREFIX
Constants
¶ ↑
Attributes
config[R]
`ANSIBLE_CONFIG_<name>=<value>` ENV var values.
@see docs.ansible.com/ansible/latest/intro_configuration.html
@return [Hash<(String | Symbol), String]
filter_plugins[R]
@!attribute [r] filter_plugins
@return [Array<Pathname>]
library[R]
@!attribute [r] library
@return [Array<Pathname>]
lookup_plugins[R]
Paths to search for Ansible/Jinja2 “Lookup Plugins”
@return [Array<Pathname>]
python_path[R]
roles_path[R]
@!attribute [r] roles_path
@return [Array<Pathname>]
test_plugins[R]
Paths to search for Ansible/Jinja2 “Test Plugins”
@return [Array<Pathname>]
Public Class Methods
new()
click to toggle source
Instantiate a new `QB::Ansible::Env`.
# File lib/qb/ansible/env.rb, line 82 def initialize # NOTE this includes role paths pulled from a call-site local # ansible.cfg @roles_path = QB::Role.search_path. # since QB::Role.search_path is an Array select(&:directory?). map(&:realpath). # so uniq works uniq # drop dups (seems to keep first instance so preserves priority) @library = [ QB::ROOT.join('library'), ] @filter_plugins = [ QB::ROOT.join('plugins', 'filter'), ] @lookup_plugins = [ QB::ROOT.join('plugins', 'lookup'), ] @test_plugins = [ QB::ROOT.join( 'plugins', 'test' ), ] @python_path = [ QB::ROOT.join( 'lib', 'python' ), *(ENV['PYTHONPATH'] || '').split( ':' ), ] @config = {} end
to_var_name(name)
click to toggle source
@todo Document to_var_name
method.
@param [type] name
@todo Add name param description.
@return [return_type]
@todo Document return value.
# File lib/qb/ansible/env.rb, line 26 def self.to_var_name name "#{ VAR_NAME_PREFIX }_#{ name.to_s.upcase }" end
Public Instance Methods
to_h()
click to toggle source
@todo Document to_h
method.
@param [type] arg_name
@todo Add name param description.''
@return [return_type]
@todo Document return value.
# File lib/qb/ansible/env.rb, line 126 def to_h hash = [ :roles_path, :library, :filter_plugins, :lookup_plugins, :test_plugins, ].map { |name| value = self.send name value = value.join(':') if value.is_a?(Array) [self.class.to_var_name(name), value] }.to_h config.each { |name, value| hash[ self.class.to_var_name( "CONFIG_#{ name }" ) ] = value.to_s } hash[ 'QB_AM_AUTORUN_PATH' ] = \ (QB::ROOT / 'load' / 'ansible' / 'module' / 'autorun.rb').to_s hash[ 'QB_AM_SCRIPT_PATH' ] = \ (QB::ROOT / 'load' / 'ansible' / 'module' / 'script.rb').to_s hash[ 'PYTHONPATH' ] = python_path.join ':' hash end