Class: Kitchen::Provisioner::Ansible::Config

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/kitchen/provisioner/ansible/config.rb

Overview

Ansible Playbook provisioner.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Config

Returns a new instance of Config.



166
167
168
# File 'lib/kitchen/provisioner/ansible/config.rb', line 166

def initialize(config = {})
  init_config(config)
end

Instance Attribute Details

#instanceObject

Returns the value of attribute instance.



31
32
33
# File 'lib/kitchen/provisioner/ansible/config.rb', line 31

def instance
  @instance
end

Instance Method Details

#[](attr) ⇒ Object



174
175
176
# File 'lib/kitchen/provisioner/ansible/config.rb', line 174

def [](attr)
  config[attr]
end

#[]=(attr, val) ⇒ Object



170
171
172
# File 'lib/kitchen/provisioner/ansible/config.rb', line 170

def []=(attr, val)
  config[attr] = val
end

#calculate_path(path, type = :directory) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/kitchen/provisioner/ansible/config.rb', line 186

def calculate_path(path, type = :directory)
  unless instance
    fail 'Please ensure that an instance is provided before calling calculate_path'
  end

  base = config[:test_base_path]
  candidates = []
  candidates << File.join(base, instance.suite.name, 'ansible', path)
  candidates << File.join(base, instance.suite.name, path)
  candidates << File.join(base, path)
  candidates << File.join(Dir.pwd, path)
  candidates << File.join(Dir.pwd) if path == 'roles'

  candidates.find do |c|
    type == :directory ? File.directory?(c) : File.file?(c)
  end
end

#key?(k) ⇒ Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/kitchen/provisioner/ansible/config.rb', line 178

def key?(k)
  config.key?(k)
end

#keysObject



182
183
184
# File 'lib/kitchen/provisioner/ansible/config.rb', line 182

def keys
  config.keys
end