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 ⇒ Object
readonly
Returns the value of attribute lookup_plugins.
-
#roles_path ⇒ Object
readonly
Returns the value of attribute roles_path.
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.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/qb/ansible/env.rb', line 70 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_plugins'), ] @lookup_plugins = [ QB::ROOT.join('plugins', 'lookup_plugins'), ] @config = {} end |
Instance Attribute Details
#config ⇒ Hash<(String | Symbol), String] (readonly)
ANSIBLE_CONFIG_<name>=<value> ENV var values.
62 63 64 |
# File 'lib/qb/ansible/env.rb', line 62 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 ⇒ Object (readonly)
Returns the value of attribute lookup_plugins.
53 54 55 |
# File 'lib/qb/ansible/env.rb', line 53 def lookup_plugins @lookup_plugins 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 |
Class Method Details
.to_var_name(name) ⇒ return_type
TODO:
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
TODO:
Document to_h method.
Returns @todo Document return value.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/qb/ansible/env.rb', line 105 def to_h hash = [ :roles_path, :library, :filter_plugins, :lookup_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 end |