Chinaunix首页 | 论坛 | 博客
  • 博客访问: 300490
  • 博文数量: 47
  • 博客积分: 1667
  • 博客等级: 上尉
  • 技术积分: 686
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 16:20
文章分类

全部博文(47)

文章存档

2013年(20)

2012年(20)

2011年(7)

分类: LINUX

2012-11-29 11:34:33

1,新建了个class
[root@web1.test.com /etc/puppet/modules/cron/manifests]# ls
init.pp  install.pp  puppet.pp  service.pp
[root@web1.test.com /etc/puppet/modules/cron/manifests]# cat *
class cron {
      include cron::install,cron::service,cron::puppet
}
class cron::install {
          package  { "crond":
               name => 'vixie-cron',
               ensure => 'installed',
#               before => Class[cron::service],
}
}
class cron::puppet {
      cron { "puppet":
             ensure => 'present',
             command => '/usr/bin/puppet agent  --test  --server=web1.cctvcj.com',
             hour=>'*',
             minute=> '*/5',
             require => Class['cron::install'],
             user => 'root',
}
}
class cron::service {
       service { "cron":
              name =>'crond',
              ensure =>running,
              hasrestart => true,
              hasstatus => true,
              enable => true,
              require =>Class['cron::install'],
}
}
以上从代码上来说是对的,但是在puppet就是执行不了,客户端执行后会出现错误
puppet agent  --test  --server=web1.cctvcj.com --debug

debug: Puppet::Type::Cron::ProviderCrontab: file crontab does not exist
err: Could not run Puppet configuration client: Could not find a default provider for cron

但是只要把init.pp把cron::puppet 去掉又是可以用的
[root@web1.test.com /etc/puppet/modules/cron/manifests]# cat init.pp
class cron {
      include cron::install,cron::service
}

客户端执行是可以成功的
notice: /Stage[main]/Cron::Service/Service[cron]/ensure: ensure changed 'stopped' to 'running'



等上面执行完了以后在将cron::puppet加入init.pp又是可以的
[root@web1.test.com /etc/puppet/modules/cron/manifests]# cat init.pp
class cron {
      include cron::install,cron::service,cron::puppet
}




客户端执行
info: Caching catalog for web4.cctvcj.com
info: Applying configuration version '1354189285'
notice: /Stage[main]/Cron::Puppet/Cron[puppet]/command: command changed 'puppet agent  --test  --server=web1.cctvcj.com' to '/usr/bin/puppet agent  --test  --server=web1.cctvcj.com'
notice: Finished catalog run in 1.48 seconds

我用的是puppet 版本是2.6.1


同样的代码在puppet 2.7.9下已经修正了

[root@web4.cctvcj.com ~/puppet-2.7.9]# puppet agent  --test  --server=web1.cctvcj.com
info: Caching catalog for web4.cctvcj.com
info: Applying configuration version '1354190978'
notice: /Stage[main]/Cron::Install/Package[crond]/ensure: created
notice: /Stage[main]/Cron::Puppet/Cron[puppet]/ensure: created
notice: /Stage[main]/Cron::Service/Service[cron]/ensure: ensure changed 'stopped' to 'running'
notice: Finished catalog run in 12.23 seconds
[root@web4.cctvcj.com ~/puppet-2.7.9]# crontab  -l
# HEADER: This file was autogenerated at Thu Nov 29 20:12:56 +0800 2012 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: puppet
*/5 * * * * /usr/bin/puppet agent  --test  --server=web1.cctvcj.com



阅读(2876) | 评论(0) | 转发(0) |
0

上一篇:puppet 数组和依赖

下一篇:mysql load data

给主人留下些什么吧!~~