puppet 3.x 弃用的一些语法

本文介绍Puppet 3.x版本中对于资源引用、文件与执行依赖关系及文件与服务间关系的新写法,帮助用户了解从2.7版本升级后所需做出的调整。

最近发现puppet 日志中报警告信息,如下:

 puppet puppet-master[17329]: Deprecation notice:  Resource references should now be capitalized on line 21 in file /etc/puppet/environments/production/modules/check_mk/manifests/debian.pp


经过查看,原来是puppet 3.x 弃用了一些2.7 的写法,具体如下:


file 与exec 依赖关系

file {"/tmp/check_upgrade.sh":
         mode    => 755,
         owner   => root,
         group   => root,
         source  => "puppet:///check_mk/check_upgrade.sh"
}

 exec {"/tmp/check_upgrade.sh":
        cwd => "/tmp",
        user => root,
        subscribe => File["/tmp/check_upgrade.sh"],
        refreshonly => true, ####如果/tmp/check_upgrade.sh 文件发生变化则执行改shell 文件
  }
弃用原来的如下:
file {"/tmp/check_upgrade.sh":
         source  => "puppet:///check_mk/check_upgrade.sh"
         alias => check,
}
exec {"/tmp/check_upgrade.sh"
          require => File ["check"],

file 与service 之间的关系
   file {"check_mk":
          #notify => service["xinetd"],
          name => "/etc/xinetd.d/check_mk",
          owner => root,
          group => root,
          mode => 0644,
          source => "puppet:///check_mk/check_mk",
          require => Package["xinetd"],    

     }
     service { "xinetd":
          ensure => running,
          enable => true,
          require => Package["xinetd"],
          subscribe=>File [check_mk], ###文件check_mk 变化则reload 服务,不是restart 服务

     }
弃用以前的:
# define the service to restart
service { "sshd":
    ensure  => "running",
    enable  => "true",
    require => Package["openssh-server"],
}

# add a notify to the file resource
file { "/etc/ssh/sshd_config":
    notify  => Service["sshd"],  # this sets up the relationship
    mode    => 600,
    owner   => "root",
    group   => "root",
    require => Package["openssh-server"],
    content => template("ssh/sshd_config.erb"),

}

http://hi.baidu.com/nessus1/item/5d1012514c82954e4eff20d0

转载于:https://my.oschina.net/u/142602/blog/155748

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值