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

全部博文(47)

文章存档

2013年(20)

2012年(20)

2011年(7)

分类: LINUX

2012-10-31 16:06:55

cd /etc/puppet/modules/
[root@puppet nginx]# tree 
.
|-- files
|   |-- nginx
|   |-- nginx-1.0.15.tar.gz
|   `-- nginx_install.sh
|-- manifests
|   |-- first.pp
|   |-- init.pp
|   |-- install.pp
|   |-- nginxfile.pp
|   `-- service.pp
`-- templates

3 directories, 8 files
安装过程

mkdir  -p /etc/puppet/modules
cd /etc/puppet/modules
mkdir  -p nginx/{manifests,templates,files}

cd  /etc/puppet/modules/nginx/files
wget


[root@puppet manifests]# cat init.pp
class nginx {
      include nginx::first,nginx::nginxfile,nginx::install,nginx::service
}

[root@puppet manifests]# cat first.pp
class nginx::first {
      package { "pcre-devel":
               ensure => 'present',
               before => Class["nginx::nginxfile"],
}
}
[root@puppet manifests]# cat nginxfile.pp
class nginx::nginxfile {
               file { "/data/soft/nginx-1.0.15.tar.gz":
               source => 'puppet://puppet.cctvcjw.com/modules/nginx/nginx-1.0.15.tar.gz',
               mode => 0777,
               ensure => 'present',
              
}

        file { "/data/soft/nginx_install.sh":
               source => 'puppet://puppet.cctvcjw.com/modules/nginx/nginx_install.sh',
               mode => 0777,
               ensure => 'present',

}
        file { "/etc/rc.d/init.d/nginx":
               source => 'puppet://puppet.cctvcjw.com/modules/nginx/nginx',
               mode => 0777,
               ensure => 'present',
               before => Class["nginx::install"],
}

}

[root@puppet manifests]# cat install.pp
class  nginx::install {
       exec { "/bin/bash /data/soft/nginx_install.sh":
              path=>'/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin',
              cwd =>'/data/soft',
               require =>Class["nginx::nginxfile"],
              before => Class["nginx::service"],

}
 
}

[root@puppet manifests]# cat service.pp
class nginx::service {
         service { "nginx": 
               ensure =>'running',
               enable => 'true',
               name => 'nginx',
               hasrestart => 'true',
               hasstatus =>'false',
               require => Class["nginx::install"],
 }
}


[root@puppet manifests]# cat  ../files/nginx_install.sh
#!/bin/bash
#cd /data/soft
tar xvzf nginx-1.0.15.tar.gz
cd nginx-1.0.15
./configure --prefix=/usr/local/nginx/   --with-http_ssl_module  --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module


make
make install



[root@puppet manifests]# cat  ../files/nginx
#!/bin/bash
# chkconfig: 35 85 15
# description: nginx service

start(){
 if [  -f  "/usr/local/nginx/logs/nginx.pid" ] 
     then
         echo 'nginx service status is start'
     else
         /usr/local/nginx/sbin/nginx  

fi
}

stop(){
  if [    -f  "/usr/local/nginx/logs/nginx.pid"  ]
          then
            num=`cat  /usr/local/nginx/logs/nginx.pid`
           kill $num
     else
          echo 'nginx service status is stop'
    fi

}

restart(){
    if [    -f  "/usr/local/nginx/logs/nginx.pid"  ]
          then
            num=`cat  /usr/local/nginx/logs/nginx.pid`
           kill $num
            /usr/local/nginx/sbin/nginx
     else
            /usr/local/nginx/sbin/nginx
    fi




}


case "$1" in
start)
  start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo 'usage service nginx {restart|stop|start}'
esac








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

上一篇:fastdfs

下一篇:puppet 数组和依赖

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