Skip to content

Instantly share code, notes, and snippets.

@liuyu
Last active August 29, 2015 14:03
Show Gist options
  • Save liuyu/b068aaafc5a659e377bf to your computer and use it in GitHub Desktop.
Save liuyu/b068aaafc5a659e377bf to your computer and use it in GitHub Desktop.
Puppet企业应用技巧
# 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