Search code examples
validationpuppetconsul

Puppet: how to enforce a certain file extension for the tempfile when using validate_cmd


I'm using puppet to generate consul config files. I'd also like to validate the files using validate_cmd. Unfortunately puppet generates file names like my-service.json20171026-6787-5on04g but consul validate requires a .json extension.

How can I force puppet to generate temporary files with a .json extension?

file { "${consul_clientconfig_dir}/${name}.json":
  ...
  content      => template("${module_name}/template.json.erb"),
  validate_cmd => "${consul_binary_dir}/consul validate %",
  notify       => Exec['consul_reload']
}

I'm using consul 1.0.0 and a pretty olde puppet version 3.8.


Solution

  • It seems currently not be possible (see @MattSchuchard comment above).

    Luckly, with consul 1.0.1 comes the -config-format option which does not answer my initial question but solves my problem.