puppetlabs/puppet · warning

Only .yaml or .pp can be used as a --values_file

Error message

Only .yaml or .pp can be used as a --values_file

What it means

Emitted by Puppet::Face[:epp]#get_values when --values_file does not end in .yaml or .pp. Only those two loaders exist, so the case statement falls through to else, Puppet.err logs this message, and the file is ignored: template_values stays nil and rendering continues without the supplied values.

Source

Thrown at lib/puppet/face/epp.rb:413

      end
      Puppet.err(detail.message)
      ""
    end
  end

  def get_values(compiler, options)
    template_values = nil
    values_file = options[:values_file]
    if values_file
      begin
        case values_file
        when /\.yaml$/
          template_values = Puppet::Util::Yaml.safe_load_file(values_file, [Symbol])
        when /\.pp$/
          evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new
          template_values = evaluating_parser.evaluate_file(compiler.topscope, values_file)
        else
          Puppet.err(_("Only .yaml or .pp can be used as a --values_file"))
        end
      rescue => e
        Puppet.err(_("Could not load --values_file %{error}") % { error: e.message })
      end
      unless template_values.nil? || template_values.is_a?(Hash)
        Puppet.err(_("--values_file option must evaluate to a Hash or undef/nil, got: '%{template_class}'") % { template_class: template_values.class })
      end
    end

    values = options[:values]
    if values
      evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new
      result = evaluating_parser.evaluate_string(compiler.topscope, values, 'values-hash')
      case result
      when nil
        template_values
      when Hash
        template_values.nil? ? result : template_values.merge(result)

View on GitHub (pinned to e227c27540)

Solutions

  1. Rename the file to .yaml (or .pp if it holds Puppet code): `mv values.yml values.yaml`
  2. If the data is JSON, convert it to YAML first
  3. Rerun and confirm the values hash is applied to the rendered output

Example fix

# before
$ puppet epp render tpl.epp --values_file vars.yml
Error: Only .yaml or .pp can be used as a --values_file

# after
$ mv vars.yml vars.yaml
$ puppet epp render tpl.epp --values_file vars.yaml
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, '--values_file must end in .yaml or .pp' unless values_file =~ /\.(yaml|pp)\z/

Type guard

def values_file?(path)
  !path.to_s.match(/\.(yaml|pp)\z/).nil?
end

Prevention

When it happens

Trigger: `puppet epp render template.epp --values_file values.json`, `--values_file vars.yml`, or any other extension; the case patterns /\.yaml$/ and /\.pp$/ both fail and the else branch fires.

Common situations: Values files named .yml (very common single-file convention) or .json; scripts ported from ERB tooling that accepted arbitrary formats.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/d6f909365ad45427. Report an issue: GitHub.