# File lib/simp/cli/config/item_list_factory.rb, line 28
  def process( answers_hash={}, items_yaml = nil )
    @answers_hash = answers_hash

    # Require the config items
    rb_files = File.expand_path( '../config/item/*.rb', File.dirname(__FILE__))
    Dir.glob( rb_files ).sort_by(&:to_s).each { |file| require file }

    if items_yaml.nil?
      scenario = @answers_hash.fetch('cli::simp::scenario')
      items_yaml = Simp::Cli::Config::ItemsYamlGenerator.new(scenario).generate_yaml
    end

    begin
      items = YAML.load items_yaml
    rescue Psych::SyntaxError => e
      $stderr.puts "Invalid Items list YAML: #{e.message}"
      $stderr.puts '>'*80
      $stderr.puts items_yaml
      $stderr.puts '<'*80
      raise 'Internal error:  invalid Items list YAML'
    end

    # add file writers needed by all scenarios
    items <<  "HieradataYAMLFileWriter FILE=#{ @options.fetch( :puppet_system_file, '/dev/null') }"

    # Note: This is this file writer is the ONLY action that can be run as non-root user,
    #  as all it does is create a file that is not within the Puppet environment.
    items << "AnswersYAMLFileWriter   FILE=#{ @options.fetch( :answers_output_file, '/dev/null') } USERAPPLY DRYRUNAPPLY"

    item_queue = build_item_queue( [], items )
    item_queue
  end