天天看點

puppet 第一個腳本

    由于樓主最近剛換工作,來到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":}