Method: Beaker::Options::HostsFileParser.parse_hosts_string

Defined in:
lib/beaker/options/hosts_file_parser.rb

.parse_hosts_string(hosts_def_yaml = nil) ⇒ OptionsHash

Read the contents of a host definition as a string into an OptionsHash

Parameters:

  • hosts_def_yaml (String) (defaults to: nil)

    YAML hosts definition

Returns:

  • (OptionsHash)

    Contents of the hosts file as an OptionsHash

Raises:

  • (ArgumentError)

    If hosts_def_yaml is not a valid YAML string



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/beaker/options/hosts_file_parser.rb', line 58

def self.parse_hosts_string(hosts_def_yaml = nil)
  require 'erb'

  host_options = new_host_options
  return host_options unless hosts_def_yaml

  error_message = "#{hosts_def_yaml}\nis not a valid YAML string\n\t"
  host_options = self.merge_hosts_yaml(host_options, error_message) do
    process_yaml(hosts_def_yaml, binding)
  end
  fix_roles_array(host_options)
end