Hi LQ community,
I got a mission to migrate some Puppet configurations to Chef, but my main experience is with bcfg2, therefore I am struggling to achieve what the IT manager wants.
Basically they need to run the "patch" command in order to include a list of servers to a fresh installation of a Fedora server. Versions of Fedora may vary in our shop and therefore also the ntp package, that's the main reason for using patch instead of placing a brand new ntp configuration file; we don't want to take the risk of proving an incompatible configuration file to the ntp daemon.
Then "patch" would solve this problem, as we only add a list of servers and keep the rest of the original ntp configuration file.
At the moment we have it running in a puppet environment with the following configuration that I would like to convert to chef but I am not sure yet how to do it:
Code:
class ntp{
file{'ntp.patch':
ensure => file,
path => '/tmp/ntp.patch',
source => 'puppet:///modules/ntp/ntp.patch',
owner => 'root',
group => 'root',
mode => '440',
}
exec{'ntp-patch':
path => '/bin:/usr/bin',
command => '/usr/bin/patch -d /etc/ -p0 < /tmp/ntp.patch',
logoutput => true,
onlyif => 'test "`cat /etc/ntp.conf | grep "^server\ 0.pool.ntp.org" -c`" -ne 1',
}
exec{'ntp-patch-delete':
path => '/bin',
command => 'rm /tmp/ntp.patch',
logoutput => true,
}
File['ntp.patch'] -> Exec['ntp-patch'] -> Exec['ntp-patch-delete']
Well, I think I have found a way to run system commands using chef, but still, I'm not sure how to pull a text file containing the list of ntp servers to be included in the running system. In Puppet we have it in "/etc/puppet/modules/ntp/files/ntp.patch" and then the manifest file will read the "ntp.patch" file and use it's content to write in the actual ntp.conf file in the running system. So that would be great if I could do the same with Chef or, perhaps, there are more elegant ways to solve this problem using Chef, but I don't know.
Thank you very much in advance for your help.