Module: Beaker::DSL::InstallUtils::PuppetUtils

Included in:
Beaker::DSL::InstallUtils, FOSSUtils, PEUtils
Defined in:
lib/beaker/dsl/install_utils/puppet_utils.rb

Overview

This module contains methods useful for both foss and pe installs

Instance Method Summary collapse

Instance Method Details

#add_puppet_paths_on(hosts) ⇒ Object

Append puppetbindir, facterbindir and hierabindir to the PATH for each host

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.



29
30
31
32
33
34
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 29

def add_puppet_paths_on(hosts)
  block_on hosts do | host |
    host.add_env_var('PATH', construct_puppet_path(host))
    host.add_env_var('PATH', 'PATH') # don't destroy the path!
  end
end

#configure_defaults_on(hosts, type) ⇒ Object

Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host is already associated with a type then remove the previous settings for that type

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.

  • type (String)

    One of ‘aio’, ‘pe’ or ‘foss’



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 51

def configure_defaults_on( hosts, type )
  block_on hosts do |host|

    # check to see if the host already has a type associated with it
    remove_defaults_on(host)

    add_method = "add_#{type}_defaults_on"
    if self.respond_to?(add_method, host)
      self.send(add_method, host)
    else
      raise "cannot add defaults of type #{type} for host #{host.name} (#{add_method} not present)"
    end
    # add pathing env
    add_puppet_paths_on(host)
  end
end

#construct_puppet_path(host) ⇒ Object

Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir

Parameters:

  • host (Host)

    A single host to construct pathing for



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 11

def construct_puppet_path(host)
  path = (%w(puppetbindir facterbindir hierabindir)).compact.reject(&:empty?)
  #get the PATH defaults
  path.map! { |val| host[val] }
  path = path.compact.reject(&:empty?)
  #run the paths through echo to see if they have any subcommands that need processing
  path.map! { |val| echo_on(host, val) }

  separator = host['pathseparator']
  if not host.is_powershell?
    separator = ':'
  end
  path.join(separator)
end

#remove_defaults_on(hosts) ⇒ Object

If the host is associated with a type remove all defaults and environment associated with that type.

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 71

def remove_defaults_on( hosts )
  block_on hosts do |host|
    if host['type']
      remove_puppet_paths_on(hosts)
      remove_method = "remove_#{host['type']}_defaults_on"
      if self.respond_to?(remove_method, host)
        self.send(remove_method, host)
      else
        raise "cannot remove defaults of type #{host['type']} associated with host #{host.name} (#{remove_method} not present)"
      end
    end
  end
end

#remove_puppet_paths_on(hosts) ⇒ Object

Remove puppetbindir, facterbindir and hierabindir to the PATH for each host

Parameters:

  • hosts (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.



40
41
42
43
44
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 40

def remove_puppet_paths_on(hosts)
  block_on hosts do | host |
    host.delete_env_var('PATH', construct_puppet_path(host))
  end
end