Module: PuppetlabsSpecHelper::Tasks::BeakerHelpers

Defined in:
lib/puppetlabs_spec_helper/tasks/beaker.rb

Instance Method Summary collapse

Instance Method Details

#beaker_node_setsArray<String>

get the array of Beaker set names

Returns:

  • (Array<String>)


21
22
23
24
25
26
27
28
# File 'lib/puppetlabs_spec_helper/tasks/beaker.rb', line 21

def beaker_node_sets
  return @beaker_nodes if @beaker_nodes

  @beaker_nodes = Dir['spec/acceptance/nodesets/*.yml'].sort.map do |node_set|
    node_set.slice!('.yml')
    File.basename(node_set)
  end
end

#repositoriesObject

cache the repositories and return a hash object



14
15
16
17
# File 'lib/puppetlabs_spec_helper/tasks/beaker.rb', line 14

def repositories
  @repositories ||= fixtures('repositories')
  @repositories
end

#source_dirObject

This is a helper for the self-symlink entry of fixtures.yml



9
10
11
# File 'lib/puppetlabs_spec_helper/tasks/beaker.rb', line 9

def source_dir
  Dir.pwd
end

#vagrant_ssh(set, node = nil) ⇒ Object

Use “vagrant ssh” to login to the given node in the node set

Parameters:

  • set (String)

    The name of the node set (yml file)

  • node (String) (defaults to: nil)

    The name of the node in the set. For multi-node sets.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/puppetlabs_spec_helper/tasks/beaker.rb', line 33

def vagrant_ssh(set, node = nil)
  vagrant_yml_dir = File.join '.vagrant', 'beaker_vagrant_files', "#{set}.yml"
  vagrant_file = File.join vagrant_yml_dir, 'Vagrantfile'
  unless File.file? vagrant_file
    puts "There is no Vagrantfile at: '#{vagrant_file}'. Perhaps, the node is not created or is destroyed."
    exit 1
  end
  Dir.chdir(vagrant_yml_dir) do
    command = 'vagrant ssh'
    command += " #{node}" if node
    # Vagrant is not distributed as a normal gem
    # and we should protect it from the current Ruby environment
    env = {
      'RUBYLIB' => nil,
      'GEM_PATH' => nil,
      'BUNDLE_BIN_PATH' => nil,
    }
    system env, command
  end
end