Class: QB::Ansible::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/qb/ansible/env.rb

Overview

TODO:

document QB::Ansible::Env class.

Constant Summary collapse

VAR_NAME_PREFIX =

Constants

'ANSIBLE'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnv

Instantiate a new QB::Ansible::Env.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/qb/ansible/env.rb', line 60

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'),
  ]
end

Instance Attribute Details

#filter_pluginsObject (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

#libraryObject (readonly)

Returns the value of attribute library.



43
44
45
# File 'lib/qb/ansible/env.rb', line 43

def library
  @library
end

#lookup_pluginsObject (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_pathObject (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.

Parameters:

  • name (type)

    @todo Add name param description.

Returns:

  • (return_type)

    @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_hreturn_type

TODO:

Document to_h method.

Returns @todo Document return value.

Parameters:

  • arg_name (type)

    @todo Add name param description.

Returns:

  • (return_type)

    @todo Document return value.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/qb/ansible/env.rb', line 93

def to_h
  [
    :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
end