Class: QB::Ansible::ConfigFile

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

Overview

A parse of an ansible.cfg file, extending ParseConfig.

We need these to read role path and other Ansible variables so we can setup paths correctly.

Defined Under Namespace

Classes: Defaults

Constant Summary collapse

FILE_NAME =

The "well-known" name we look for.

'ansible.cfg'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ConfigFile

Instantiate a new QB::Ansible::ConfigFile.



130
131
132
133
# File 'lib/qb/ansible/config_file.rb', line 130

def initialize path
  super path
  @rel_root = QB::Util.resolve(path).dirname
end

Instance Attribute Details

#rel_rootObject (readonly)

Returns the value of attribute rel_root.



123
124
125
# File 'lib/qb/ansible/config_file.rb', line 123

def rel_root
  @rel_root
end

Class Method Details

.end_with_config_file?(file_path) ⇒ Boolean

Test if a file path looks like it points to an Ansible config file - a file with FILE_NAME as the basename.

Explicitly does not check if the file actually exists and is a file. This is because we need this test to differentiate role search path elements that are meant to point to Ansible config files from those that aren't in Role.search_path.

Parameters:

  • file_path (String, Pathname)

Returns:

  • (Boolean)

    true if path's basename is FILE_NAME.



111
112
113
# File 'lib/qb/ansible/config_file.rb', line 111

def self.end_with_config_file? file_path
  File.basename(file_path).to_s == FILE_NAME
end

Instance Method Details

#defaultsQB::Ansible::ConfigFile::Defaults

TODO:

Document defaults method.

Returns @todo Document return value.

Returns:



144
145
146
# File 'lib/qb/ansible/config_file.rb', line 144

def defaults
  Defaults.new (self['defaults'] || {}), rel_root: @rel_root
end