Class: QB::Ansible::Env
- Inherits:
-
Object
- Object
- QB::Ansible::Env
- Defined in:
- lib/qb/ansible/env.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Devel
Constant Summary collapse
- VAR_NAME_PREFIX =
Constants
'ANSIBLE'
Instance Attribute Summary collapse
-
#config ⇒ Hash<(String | Symbol), String]
readonly
ANSIBLE_CONFIG_<name>=<value>
ENV var values. -
#filter_plugins ⇒ Object
readonly
Returns the value of attribute filter_plugins.
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#lookup_plugins ⇒ Array<Pathname>
readonly
Paths to search for Ansible/Jinja2 "Lookup Plugins".
-
#python_path ⇒ Object
readonly
Returns the value of attribute python_path.
-
#roles_path ⇒ Object
readonly
Returns the value of attribute roles_path.
-
#test_plugins ⇒ Array<Pathname>
readonly
Paths to search for Ansible/Jinja2 "Test Plugins".
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Env
constructor
Instantiate a new
QB::Ansible::Env
. - #to_h ⇒ return_type
Constructor Details
#initialize ⇒ Env
Instantiate a new QB::Ansible::Env
.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# 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 |
Instance Attribute Details
#config ⇒ Hash<(String | Symbol), String] (readonly)
ANSIBLE_CONFIG_<name>=<value>
ENV var values.
74 75 76 |
# File 'lib/qb/ansible/env.rb', line 74 def config @config end |
#filter_plugins ⇒ Object (readonly)
Returns the value of attribute filter_plugins.
48 49 50 |
# File 'lib/qb/ansible/env.rb', line 48 def filter_plugins @filter_plugins end |
#library ⇒ Object (readonly)
Returns the value of attribute library.
43 44 45 |
# File 'lib/qb/ansible/env.rb', line 43 def library @library end |
#lookup_plugins ⇒ Array<Pathname> (readonly)
Paths to search for Ansible/Jinja2 "Lookup Plugins"
55 56 57 |
# File 'lib/qb/ansible/env.rb', line 55 def lookup_plugins @lookup_plugins end |
#python_path ⇒ Object (readonly)
Returns the value of attribute python_path.
65 66 67 |
# File 'lib/qb/ansible/env.rb', line 65 def python_path @python_path end |
#roles_path ⇒ Object (readonly)
Returns the value of attribute roles_path.
38 39 40 |
# File 'lib/qb/ansible/env.rb', line 38 def roles_path @roles_path end |
#test_plugins ⇒ Array<Pathname> (readonly)
Paths to search for Ansible/Jinja2 "Test Plugins"
62 63 64 |
# File 'lib/qb/ansible/env.rb', line 62 def test_plugins @test_plugins end |
Class Method Details
.to_var_name(name) ⇒ return_type
Document to_var_name method.
Returns @todo Document return value.
26 27 28 |
# File 'lib/qb/ansible/env.rb', line 26 def self.to_var_name name "#{ VAR_NAME_PREFIX }_#{ name.to_s.upcase }" end |
Instance Method Details
#to_h ⇒ return_type
Document to_h method.
Returns @todo Document return value.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# 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 |