架构如下:
============================
manifests
===========================
1,at /etc/puppet/mainfests
------------------
site.pp
+++++++++
import "modules.pp"
import "nodes/*.pp"
-------------------------------
2,at /etc/puppet/manifests/
nodes
-------------------
node_master.pp
++++++++
node 'master.puppet.com' {
include nginx
include php
include mysql
}
---------------------------------------------
3,at /etc/puppet/mainfests
---------------------
modules.pp
++++++++++++
import "nginx"
import "php"
import "mysql"
===================================
modules
===================================
1,at /etc/puppet/modules/nginx/manifests
---------------------------
init.pp
+++++++++++
class nginx{
include nginx::install,nginx::config,nginx::service
}
include nginx::install,nginx::config,nginx::service
}
----------------------
install.pp
++++++++++++
class nginx::install {
package {
"nginx-stable":
ensure => installed;
}
}
package {
"nginx-stable":
ensure => installed;
}
}
------------------------
config.pp
+++++++++
class nginx::config{
file {
"/usr/local/nginx/nginx.conf":
source => "puppet:///modules/nginx/nginx.conf",
require => Class["nginx::install"],
notify => Class["nginx::service"],
}
file {
"/usr/local/nginx/fcgi.conf":
source => "puppet:///modules/nginx/fcgi.conf",
require => Class["nginx::install"],
notify => Class["nginx::service"],
}
}
file {
"/usr/local/nginx/nginx.conf":
source => "puppet:///modules/nginx/nginx.conf",
require => Class["nginx::install"],
notify => Class["nginx::service"],
}
file {
"/usr/local/nginx/fcgi.conf":
source => "puppet:///modules/nginx/fcgi.conf",
require => Class["nginx::install"],
notify => Class["nginx::service"],
}
}
------------------------------
service.pp
++++++++++++
class nginx::service{
service {
"nginx":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["nginx::config"],
}
}
service {
"nginx":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["nginx::config"],
}
}
---------------------------------
2,at /etc/puppet/modules/php/manifests
---------------------
init.pp
++++++++++++
class php{
include php::install,php::config,php::service
}
include php::install,php::config,php::service
}
--------------
install.pp
+++++++++++++++++
class php::install {
package {[
"php",
"php-cli",
"php-common",
"php-devel",
"php-fpm",
"php-gd",
"php-mbstring",
"php-mcrypt",
"php-mysql",
"php-pdo",
"php-pear",
"php-redis",
"php-xml",
"php-xmlrpc"]:
ensure => installed;
}
}
package {[
"php",
"php-cli",
"php-common",
"php-devel",
"php-fpm",
"php-gd",
"php-mbstring",
"php-mcrypt",
"php-mysql",
"php-pdo",
"php-pear",
"php-redis",
"php-xml",
"php-xmlrpc"]:
ensure => installed;
}
}
--------------
config.pp
+++++++++++++
class php::config{
file {
"/etc/php.ini":
source => "puppet:///modules/php/php.ini",
require => Class["php::install"],
notify => Class["php::service"],
}
file {
"/etc/php-fpm.conf":
source => "puppet:///modules/php/php-fpm.conf",
require => Class["php::install"],
notify => Class["php::service"],
}
file {
"/etc/php-fpm.d/www.conf":
source => "puppet:///modules/php/www.conf",
require => Class["php::install"],
notify => Class["php::service"],
}
}
file {
"/etc/php.ini":
source => "puppet:///modules/php/php.ini",
require => Class["php::install"],
notify => Class["php::service"],
}
file {
"/etc/php-fpm.conf":
source => "puppet:///modules/php/php-fpm.conf",
require => Class["php::install"],
notify => Class["php::service"],
}
file {
"/etc/php-fpm.d/www.conf":
source => "puppet:///modules/php/www.conf",
require => Class["php::install"],
notify => Class["php::service"],
}
}
----------------------------
service.pp
+++++++++
class php::service{
service {
"php-fpm":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["php::config"],
}
}
service {
"php-fpm":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["php::config"],
}
}
----------------------------------------------------
3,at /etc/puppet/modules/mysql/manifests
------------------
init.pp
++++++++++++
class mysql{
include mysql::install,mysql::config,mysql::service
}
include mysql::install,mysql::config,mysql::service
}
--------------
install.pp
+++++++++++
class mysql::install {
package {[
"MySQL-client",
"MySQL-devel",
"MySQL-server",
"MySQL-shared",
"MySQL-shared-compat"]:
ensure => installed;
}
}
package {[
"MySQL-client",
"MySQL-devel",
"MySQL-server",
"MySQL-shared",
"MySQL-shared-compat"]:
ensure => installed;
}
}
----------------------
config.pp
++++++++
class mysql::config{
file {
"/etc/my.cnf":
source => "puppet:///modules/mysql/my.cnf",
require => Class["mysql::install"],
notify => Class["mysql::service"],
}
}
file {
"/etc/my.cnf":
source => "puppet:///modules/mysql/my.cnf",
require => Class["mysql::install"],
notify => Class["mysql::service"],
}
}
-------------------------
service.pp
+++++++++++++++++
class mysql::service{
service {
"mysql":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["mysql::config"],
}
}
service {
"mysql":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["mysql::config"],
}
}
下一篇:cacti客户端的编写