由于楼主最近刚换工作,来到sina,之前觉得自己的技术还可以,谁知道到这才知道自己还是个渣
来到sina第一个要学习的东西就是puppet,这个太关键了
楼主用了大概一个星期的时间来学习puppet,下面奉上第一个脚本
首先创建applepush模块,编写里面的init.pp文件
需求判断服务是否正常,如果不正常重启服务,如果配置文件修改了,重启服务
/* vim: set :expandtab:shiftwidth=4:tabstop=4:smarttab */
class applepush(
) {
$apns_conf = "$globalvar::install_prefix/apns/conf/apns.conf"
$collector_conf = "$globalvar::install_prefix/apns/conf/collector.conf"
package {['sae-apns-rest']:
ensure => present,
}
package {['sae-apns']:
ensure => present,
notify => Service['apns'],
}
file { $apns_conf:
ensure => file,
content => template('applepush/apns.conf.erb'),
require => [Package['sae-apns'],Package['sae-apns-rest']],
notify => Service['apns'],
}
service { "apns":
ensure => running,
enable => false,
hasstatus => true,
hasrestart => true,
}
file { $collector_conf:
ensure => file,
content => template('applepush/collector.conf.erb'),
notify => Service['collector'],
}
service { 'collector':
ensure => running,
enable => false,
hasstatus => true,
hasrestart => true,
}
logrotate::rule { "apns_logs":
path => '/data0/logs/apns/*',
rotate => 5,
rotate_every => "day",
sharedscripts => true,
}
}
在根目录下的文件中
class{"applepush":}