Wednesday, May 20, 2020

Puppet restart service on file change

Following is sample puppet manifest to reload service after file change. This may come handy if you want to reload service once config file is updated.

class cmk_cache {
case $::kernel {
'Linux': {

	service { 'xinetd':
	ensure  => 'running',
	enable  => true,
		}

	# add a notify to the file resource
	file { '/etc/xinetd.d/check_mk':
	notify  => Service['xinetd'],  # this sets up the relationship
	source => "puppet:///modules/cmk_cache/check_mk",
		}
}
}
}

Here we are refreshing / restarting xinetd service once check_mk xinetd file is updated.

No comments:

Post a Comment