Hi, Found a solution:
Create ruby script in: root@foreman]# cat /etc/puppet/environments/production/modules/customfacts/lib/facter/check_file_exsist.rb Facter.add('check_nails_exsist') do setcode do File.exists?('/etc/NONAILS') end end We are checking if /etc/NONAILS exist, if yes return true else false. Create puppet manifest to ensure the service running, if file exist stop the server: [root@foreman]# cat /etc/puppet/environments/production/modules/check_service/manifests/init.pp # Class: check_service class check_service { if $check_nails_exsist == 'true' { service { 'nails': ensure => "stopped", enable => false, hasstatus => false, hasrestart => false, } } else { service { 'nails': ensure => "running", enable => true, hasstatus => false, hasrestart => true, } } } Hope it helped. On Thursday, June 11, 2015 at 4:06:53 PM UTC+3, jcbollinger wrote: > > > > On Thursday, June 11, 2015 at 7:24:57 AM UTC-5, Eddie Mashayev wrote: >> >> >> Thanks, do you have any other suggestion how can I do it properly? >> >> I want “nails” process to be running only if there is no /etc/NONAILS >> flag in my OS. >> >> > > The canonical way to inform the catalog compiler about node state is via > node facts. It should be pretty straightforward to create a custom fact > that simply reports on the presence or absence of one file; then you put > the Service resource in a conditional block that depends on the value of > that fact. > > > John > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/728e087f-16c5-4f95-8663-cd181b7dd7dc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.