Last active
August 29, 2015 14:03
-
-
Save liuyu/b068aaafc5a659e377bf to your computer and use it in GitHub Desktop.
Puppet企业应用技巧
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# only rsync nginx virtualhost directory form server | |
file { 'virtualhost_directory': | |
name => '/usr/local/nginx/conf/vhost', | |
ensure => directory, | |
force => true, | |
recurse => remote, | |
source => "puppet:///modules/nginx/vhost", | |
} | |
# vhost.conf.erb | |
server { | |
listen 80; | |
server_name <%= domain %>; | |
location / { | |
index index.html index.htm; | |
root <%= documentroot %>; | |
} | |
} | |
# config.pp | |
class nginx::config { | |
define nginx_vhost($domain,$documentroot) { | |
file { 'vhost': | |
name => '/usr/local/nginx/conf/vhost', | |
ensure => directory, | |
} | |
file { 'virtualhost': | |
name => '/usr/local/nginx/conf/vhost/virtualhost.conf', | |
content => template('nginx/vhost.conf.erb'), | |
require => File['/usr/local/nginx/conf/vhost'], | |
} | |
} | |
} | |
# liuyu.github.io.pp | |
node 'liuyu.github.io' { | |
include nginx | |
include nginx::config | |
nginx::config::nginx_vhost { 'test': | |
domain => 'liuyu.github.io', | |
documentroot => '/data/wwwroot/liuyu.github.io', | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment