cfengine classes and shellcommands
06 Oct 2005cfengine is great, it really is. But there are some things that tripped me up. Often you want to set up a daemon to run The Right Way, which involves changing its config file. After that, of course, you want to restart it. What to do? The naive way (ie, the first way I tried) of doing things is:
control::
sequence ( editfiles shellcommands )
editfiles::
debian:
{ /etc/foo.conf
BeginGroupIfNoLineMatching "bar"
AddLine "bar"
Define restart_foo
EndGroup
}
freebsd:
{ /usr/local/etc/foo.conf
BeginGroupIfNoLineMatching "bar"
AddLine "bar"
Define restart_foo
EndGroup
}
shellcommands::
debian.restart_foo:
"/etc/init.d/foo restart"
freebsd.restart_foo:
"/usr/local/etc/rc.d/foo restart"
However, the correct way of doing this is:
control::
sequence = ( editfiles shellcommands )
AddInstallable = ( restart_foo )
editfiles::
debian:
{ /etc/foo.conf
BeginGroupIfNoLineMatching "bar"
AddLine "bar"
DefineInGroup "restart_foo"
EndGroup
}
freebsd:
{ /usr/local/etc/foo.conf
BeginGroupIfNoLineMatching "bar"
AddLine "bar"
DefineInGroup "restart_foo"
EndGroup
}
shellcommands::
debian.restart_foo:
"/etc/init.d/foo restart"
freebsd.restart_foo:
"/usr/local/etc/rc.d/foo restart"
Without both the enumeration of all your made-up classes in AddInstallable and the enclosing of that class in quotes, cfengine will fail to do what you want -- and will do so quietly and with no clue about why. God, that took me a long time to find.
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018