def validate(template, options = {})
      args = ['validate']
      args << '-syntax-only' if options.key?(:syntax_only)
      args << "-except=#{options[:except].join(',')}" if options.key?(:except)
      args << "-only=#{options[:only].join(',')}" if options.key?(:only)
      args << "-var-file=#{options[:var_file]}" if options.key?(:var_file)

      vars = options[:vars] || {}
      vars.each { |key, val| args << "-var '#{key}=#{val}'" }

      args << template

      Packer::Output::Validate.new(command(args, options[:live_stream]))
    end
def validate(template, options = {})
      args = ['validate']
      args << '-syntax-only' if options.key?(:syntax_only)
      args << "-except=#{options[:except].join(',')}" if options.key?(:except)
      args << "-only=#{options[:only].join(',')}" if options.key?(:only)
      args << "-var-file=#{options[:var_file]}" if options.key?(:var_file)

      vars = options[:vars] || {}
      vars.each { |key, val| args << "-var '#{key}=#{val}'" }

      args << template

      Packer::Output::Validate.new(command(args, options[:live_stream]))
    end
Executes +packer validate+

 Checks the template is valid by parsing the template and also checking
 the configuration with the various builders, provisioners, etc.

 If it is not valid, the errors will be shown and the command will exit
 with a non-zero exit status. If it is valid, it will exist with a zero
 exist status.

 @param [String,Packer::Template] template the Packer template
 @param [Hash] options
 @option options [Boolean] :syntax_only only check syntax. Do not verify
   config of the template.
 @option options [Array<String>] :except validate all builds other than
   these
 @option options [Array<String>] :only validate only these builds
 @option options [Hash] :vars variables for templates
 @option options [String] :var_file path to JSON file containing user
 @option options [IO] :live_stream an IO object to stream packer output to
   in addition to saving output in the output object.
   variables
 @return [Packer::Output::Validate]