Module: Beaker::DSL::InstallUtils::PuppetUtils
- Included in:
- Beaker::DSL::InstallUtils, FOSSUtils
- 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
-
#add_puppet_paths_on(hosts) ⇒ Object
Append puppetbindir, facterbindir and hierabindir to the PATH for each host.
-
#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.
- #configure_type_defaults_on(hosts) ⇒ Object (also: #configure_foss_defaults_on, #configure_pe_defaults_on)
-
#construct_puppet_path(host) ⇒ Object
Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir.
-
#normalize_type(type) ⇒ String
Given a type return an understood host type.
-
#remove_defaults_on(hosts) ⇒ Object
If the host is associated with a type remove all defaults and environment associated with that type.
-
#remove_puppet_paths_on(hosts) ⇒ Object
Remove puppetbindir, facterbindir and hierabindir to the PATH for each host.
Instance Method Details
#add_puppet_paths_on(hosts) ⇒ Object
Append puppetbindir, facterbindir and hierabindir to the PATH for each host
55 56 57 58 59 60 61 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 55 def add_puppet_paths_on(hosts) block_on hosts do | host | puppet_path = construct_puppet_path(host) host.add_env_var('PATH', puppet_path) 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
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 80 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 |
#configure_type_defaults_on(hosts) ⇒ Object Also known as: configure_foss_defaults_on, configure_pe_defaults_on
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 98 def configure_type_defaults_on( hosts ) block_on hosts do |host| has_defaults = false if host[:type] host_type = host[:type] # clean up the naming conventions here (some teams use foss-package, git-whatever, we need # to correctly handle that # don't worry about aio, that happens in the aio_version? check host_type = normalize_type(host_type) if host_type and host_type !~ /aio/ add_method = "add_#{host_type}_defaults_on" if self.respond_to?(add_method, host) self.send(add_method, host) else raise "cannot add defaults of type #{host_type} for host #{host.name} (#{add_method} not present)" end has_defaults = true end end if aio_version?(host) add_aio_defaults_on(host) has_defaults = true end # add pathing env if has_defaults add_puppet_paths_on(host) end end end |
#construct_puppet_path(host) ⇒ Object
Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 37 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 |
#normalize_type(type) ⇒ String
Given a type return an understood host type
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 22 def normalize_type type case type when /(\A|-)(git)|(foss)(\Z|-)/ 'foss' when /(\A|-)pe(\Z|-)/ 'pe' when /(\A|-)aio(\Z|-)/ 'aio' else nil end end |
#remove_defaults_on(hosts) ⇒ Object
If the host is associated with a type remove all defaults and environment associated with that type.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 133 def remove_defaults_on( hosts ) block_on hosts do |host| if host['type'] # clean up the naming conventions here (some teams use foss-package, git-whatever, we need # to correctly handle that # don't worry about aio, that happens in the aio_version? check host_type = normalize_type(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 if aio_version?(host) remove_aio_defaults_on(host) end end end end |
#remove_puppet_paths_on(hosts) ⇒ Object
Remove puppetbindir, facterbindir and hierabindir to the PATH for each host
67 68 69 70 71 72 73 |
# File 'lib/beaker/dsl/install_utils/puppet_utils.rb', line 67 def remove_puppet_paths_on(hosts) block_on hosts do | host | puppet_path = construct_puppet_path(host) host.delete_env_var('PATH', puppet_path) host.add_env_var('PATH', 'PATH') # don't destroy the path! end end |