On Jun 20, 2011, at 3:37 PM, Jacob Helwig wrote:
> On Mon, 20 Jun 2011 15:11:09 -0700, Craig White wrote:
>> Date: Mon, 20 Jun 2011 15:11:09 -0700
>> From: Craig White <[email protected]>
>> To: [email protected]
>> Subject: Re: [Puppet Users] confused about file ensure/require
>> X-Mailer: Apple Mail (2.1084)
>> Message-Id: <[email protected]>
>>
>>
>> On Jun 20, 2011, at 2:35 PM, Jacob Helwig wrote:
>>
>>> On Mon, 20 Jun 2011 14:17:46 -0700, Craig White wrote:
>>>>
>>>> my base/default includes this ntp manifest
>>>>
>>>> # cat modules/ntp/manifests/ntp.pp
>>>> # ntp.pp
>>>>
>>>> class ntp {
>>>> case $operatingsystem {
>>>> centos, redhat: {
>>>> $service_name = 'ntpd'
>>>> $conf_file = 'ntp.conf.el'
>>>> }
>>>> debian, ubuntu: {
>>>> $service_name = 'ntp'
>>>> $conf_file = 'ntp.conf.debian'
>>>> }
>>>> }
>>>>
>>>> package { 'ntp':
>>>> ensure => installed,
>>>> }
>>>>
>>>> service { 'ntp':
>>>> name => $service_name,
>>>> ensure => running,
>>>> enable => true,
>>>> subscribe => File['ntp.conf'],
>>>> }
>>>>
>>>> file { 'ntp.conf':
>>>> path => '/etc/ntp.conf',
>>>> ensure => file,
>>>> require => Package['ntp'],
>>>> source => "puppet:///ntp/files/${conf_file}",
>>>> }
>>>> }
>>>>
>>>> # class {'ntp': }
>>>>
>>>> So my questions...
>>>>
>>>> 1. I tested this by moving /etc/ntp.conf on my test client but it doesn't
>>>> seem to replace the file though it clearly says 'ensure => file'
>>>> Is my understanding wrong?
>>>>
>>>
>>> That should replace the file. What output are you getting (if
>>> anything)?
>>>
>>> % cat ../test.pp
>>> file { 'blab':
>>> path => '/tmp/blab.txt',
>>> ensure => 'file',
>>> content => 'asdf',
>>> }
>>>
>>> % puppet apply ../test.pp
>>> notice: /Stage[main]//File[blab]/ensure: defined content as
>>> '{md5}912ec803b2ce49e4a541068d495ab570'
>>> notice: Finished catalog run in 0.06 seconds
>>>
>>> % rm /tmp/blab.txt
>>>
>>> % puppet apply ../test.pp
>>> notice: /Stage[main]//File[blab]/ensure: defined content as
>>> '{md5}912ec803b2ce49e4a541068d495ab570'
>>> notice: Finished catalog run in 0.06 seconds
>>>
>>> % puppet apply ../test.pp
>>> notice: Finished catalog run in 0.04 seconds
>>>
>>>> 2. Files ntp.conf.el & ntp.conf.debian are located in
>>>> /etc/puppet/modules/ntp/files - source =>
>>>> 'puppet://puppet:///ntp/files/${conf_file} is this correct?
>>>>
>>>
>>> You should include 'modules' in the 'puppet://' URI, since the form
>>> without it has been deprecated for a while. IIRC it should look
>>> something like:
>>>
>>> puppet:///modules/ntp/files/${conf_file}
>> -----
>> I sort of think it should just work but it doesn't
>>
>> # mv /etc/ntp.conf /root/
>> root@ubuntu:/var/www/puppet-dashboard# puppet agent --test --verbose
>> --server ubuntu.ttinet
>> info: Retrieving plugin
>> info: Caching catalog for ubuntu.ttinet
>> info: Applying configuration version '1308606646'
>> notice: Finished catalog run in 0.14 seconds
>>
>> still no /etc/ntp.conf
>>
>> root@ubuntu:/var/www/puppet-dashboard# puppet apply
>> /etc/puppet/modules/ntp/manifests/ntp.pp
>> notice: Finished catalog run in 0.01 seconds
>>
>> above is what I got from the 'puppet apply' command and before from puppet
>> agent command, neither replaced /etc/ntp.conf and neither indicated an error.
>>
>> root@ubuntu:/var/www/puppet-dashboard# ls -l /etc/ntp.conf
>> ls: cannot access /etc/ntp.conf: No such file or directory
>>
>> and this was after I changed the source as you indicated...
>>
>> # tail -n 5 /etc/puppet/modules/ntp/manifests/ntp.pp
>> source => "puppet:///modules/ntp/files/${conf_file}",
>> }
>> }
>>
>> # class {'ntp': }
>>
>> Craig
>>
>
> Doesn't look like you're including the ntp class?
>
> The line that would do it is commented out in
> /etc/puppet/modules/ntp/manifests/ntp.pp, if you're going to apply
> /etc/puppet/modules/ntp/manifests/ntp.pp directly.
----
I thought it should work at least for the 'puppet agent' commands...
# cat manifests/site.pp
import "templates"
import "nodes"
import "modules"
root@ubuntu:/etc/puppet# cat manifests/templates.pp
class baseclass {
}
node default {
include baseclass
include ntp
include facts
}
and the nodes all have
include baseclass
in them
Craig
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.