puppetlabs / puppetlabs-concat

File concatenation system for Puppet
Apache License 2.0
171 stars 303 forks source link

concat_file.rb is missing the code to run the validate_cmd #807

Open jkbzh opened 7 months ago

jkbzh commented 7 months ago

Describe the Bug

Unless I examined the code wrongly, the only thing that concact_file does with the validate_cmd argument is ... validate that the arguments of that command are correct.

However, you seem to have forgotten the code to execute the validate_cmd. Even if you pass the correct arguments, nothing happens.

Expected Behavior

I'd expect that the validate command be executed and abort the replacement of the file if the command returns 1.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use your fragment.pp example to create /tmp/concatby running puppet
  2. Modify your example to change line 12 so the content is '3' (or anything else, doesn't matter)
  3. Add a validate_command in line 7 that always returns 1 (the expected failure value) (doesn't matter if you add the ending %). validate_cmd => '/usr/bin/false',
  4. Run puppet on the modified example
  5. You'll see that /tmp/concact was replaced with the new content, even if validate_cmd returned an error.

It doesn't matter if validate_cmd returns 0 or 1. There's no code executing validate_cmd or taking action on its result.

Environment

Additional Context

You are missing a call to execute validate_cmd. Something along the lines of whatpuppet::filedoes here