8

I am using an exec command to run a shell script which modifies certain configuration files of other packages. The exec command is triggered whenever input parameters such as ip addresses, ports or url change, or when the shell script itself has been changed.

I have to use a shell script because the configuration files of the software package differ slightly between releases. I think it is easier to update the configuration file per sed script instead of providing different puppet templates for each particular release.

But this configuration does not detect when any of the configuration files have been modified outside of puppet. Puppet does not know about the files which are been modified by the shell script.

What I am looking for is a way to make the exec command dependend on the checksums of arbitrary other files:

exec { "my_command.sh":
  only_if_file_has_changed => [ 
    "/etc/mysoftware/config.xml", 
    "/etc/othersoftware/defaults", 
  ]
}

Is this possible? Please advise.

  • Exactly what are you trying to do? There is probably a better way. – Michael Hampton Dec 25 '14 at 13:49
  • I have updated the question with an explanation. – nn4l Dec 26 '14 at 8:42
  • This is the problem that augeas solves. – Michael Hampton Dec 26 '14 at 15:15
11

It would work like this:

exec { 'my_command.sh':
  command   => '/bin/my_command.sh',
  subscribe => [ 
    File['/etc/mysoftware/config.xml'], 
    File['/etc/othersoftware/defaults'], 
  ],
  refreshonly => true,
}

The obvious constraint here is, that the files /etc/mysoftware/config.xml and /etc/othersoftware/defaults must be changed via Puppet too.
If they are changed by something else (external to Puppet), see Felix' answer.
You can also subscribe to Package['xxx'] or any other more fitting dependency of course.

7

Puppet can solve this through its audit metaparameter.

file { [ "/etc/mysoftware/config.xml", 
         "/etc/othersoftware/defaults" ]:
    audit => 'content',
    notify => Exec['my_command'],
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.