lib/beaker/dsl/helpers.rb in beaker-2.2.0 vs lib/beaker/dsl/helpers.rb in beaker-2.3.0

- old
+ new

@@ -1254,11 +1254,12 @@ avoid_puppet_at_all_costs = false avoid_puppet_at_all_costs ||= agent['platform'] =~ /el-4/ avoid_puppet_at_all_costs ||= agent['pe_ver'] && version_is_less(agent['pe_ver'], '3.2') && agent['platform'] =~ /sles/ if avoid_puppet_at_all_costs - on agent, "/etc/init.d/#{agent_service} stop" + # When upgrading, puppet is already stopped. On EL4, this causes an exit code of '1' + on agent, "/etc/init.d/#{agent_service} stop", :acceptable_exit_codes => [0, 1] else on agent, puppet_resource('service', agent_service, 'ensure=stopped') end end end @@ -1352,8 +1353,48 @@ on host, "curl --tlsv1 %s" % cmd, opts, &block else on host, "curl %s" % cmd, opts, &block end end + + # Write hiera config file on one or more provided hosts + # + # @param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon, + # or a role (String or Symbol) that identifies one or more hosts. + # @param[Array] One or more hierarchy paths + def write_hiera_config_on(host, hierarchy) + + block_on host do |host| + hiera_config=Hash.new + hiera_config[:backends] = 'yaml' + hiera_config[:yaml] = {} + hiera_config[:yaml][:datadir] = host[:hieradatadir] + hiera_config[:hierarchy] = hierarchy + hiera_config[:logger] = 'console' + create_remote_file host, host[:hieraconf], hiera_config.to_yaml + end + end + + # Write hiera config file for the default host + # @see #write_hiera_config_on + def write_hiera_config(hierarchy) + write_hiera_config_on(default, hierarchy) + end + + # Copy hiera data files to one or more provided hosts + # + # @param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon, + # or a role (String or Symbol) that identifies one or more hosts. + # @param[String] Directory containing the hiera data files. + def copy_hiera_data_to(host, source) + scp_to host, File.expand_path(source), host[:hieradatadir] + end + + # Copy hiera data files to the default host + # @see #copy_hiera_data_to + def copy_hiera_data(source) + copy_hiera_data_to(default, source) + end + end end end