I want to automate the newrelic-sysmond installation using Puppet and it requires to set the license key in the nrsysmond.cfg and start the agent. And all this steps should happen once only and this can be achieved by creating a text file and only execute if the file does not exist.
Here is the class definition i used in the manifest.
class system::newrelic-sysmond ($licensekey) { package { "newrelic-sysmond": ensure => installed, } exec { 'Insert newrelic license key': command => "nrsysmond-config --set license_key=$licensekey", require => Package['newrelic-sysmond'], creates => '/etc/newrelic/key_added', } exec { 'Restart newrelic system monitor': command => "/etc/init.d/newrelic-sysmond start", require => Exec['Insert newrelic license key'], creates => '/etc/newrelic/key_added', } exec { 'Create the key_added file': command => "echo key_added > /etc/newrelic/key_added", require => Exec['Restart newrelic system monitor'], creates => '/etc/newrelic/key_added', } }
Done =)
One thought on “Puppet – Run exec once only”