Class: QB::Ansible::ConfigFile::Defaults

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

Overview

Wrapper around the Hash from the [defaults] group in an Asnible config file.

Instances are returned from #defaults.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, rel_root:) ⇒ Defaults

Instantiate a new QB::Ansible::ConfigFile.

Parameters:

  • source (#each_pair)

    Source for the keys and values.



60
61
62
63
64
# File 'lib/qb/ansible/config_file.rb', line 60

def initialize source, rel_root:
  super()
  source.each_pair { |k, v| self[k] = v }
  @rel_root = rel_root
end

Instance Attribute Details

#rel_rootObject (readonly)

Returns the value of attribute rel_root.



49
50
51
# File 'lib/qb/ansible/config_file.rb', line 49

def rel_root
  @rel_root
end

Instance Method Details

#roles_pathArray<Pathname>

Returns Array of resolved (absolute) Pathname instances parsed from the roles_path value. Empty array roles_path key is missing.

Returns:

  • (Array<Pathname>)

    Array of resolved (absolute) Pathname instances parsed from the roles_path value. Empty array roles_path key is missing.



74
75
76
77
78
79
80
81
82
# File 'lib/qb/ansible/config_file.rb', line 74

def roles_path
  if key? 'roles_path'
    self['roles_path'].
      split(':').
      map { |path| QB::Util.resolve @rel_root, path }
  else
    []
  end
end