【发布时间】:2016-03-08 15:23:55
【问题描述】:
我正在为 jfryman 的 nginx 模块编写一些扩展。
我有许多安装了 nginx 的服务器,并且有不同的站点:
例如
Live = site1.domain
Staging = site1.staging.domain
Development = site1.development.domain, site2.development.domain, site3.development.domain (etc)
因此,为了保持理智,我根据文档创建了一些模块“额外”文件:即 modules/nginx/manifests/amcustom/site1.pp 等。
现在 - 所有这些站点都包含 Nginx 的自定义配置,所以为了不重复相同的代码,我创建了以下作为变量的“模板” - 它被称为 ~/modules/nginx/manifests/amcustom /ux_std_vhost.pp 并包含:
class nginx::amcustom::ux_std_vhost {
file { $nginx_dirs:
ensure => 'directory',
owner => 'gitpull',
group => 'www-data',
mode => 0750,
}
nginx::resource::vhost { "${webshortname}.${domain}":
ensure => present,
rewrite_to_https => true,
www_root => "${full_web_path}/${webshortname}.${domain}/latest/",
index_files => [ 'index.html' ],
location_cfg_append => $location_cfg_append,
ssl => true,
ssl_cert => "puppet:///modules/nginx/$webshortname.$domain.nginx.crt",
ssl_key => "puppet:///modules/nginx/$webshortname.$domain.key",
ssl_protocols => 'TLSv1 TLSv1.1 TLSv1.2',
ssl_ciphers => '"EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH !EDH+aRSA !RC4 !a
NULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"',
vhost_cfg_ssl_prepend => {
'add_header' => '"Strict-Transport-Security" "max-age=15768000"'
},
location_raw_append => [ 'if ($http_origin ~* (https?://[^/]*\.domain(:[0-9]+)?)) {', 'add_header "Access-Control-Allow-Origin" "$http_origin";', '}' ],
}
}
我需要做的是使用这个“标准”文件,并为每个站点传递变量:
~/amcustom/site1.pp
~/amcustom/site2.pp
...etc
这些配置文件的内容是:
class nginx::amcustom::site1_config inherits nginx::amcustom::ux_std_vhost {
# Define my Variables:
$full_web_path = [ '/var/sites' ]
$webshortname = [ 'site1' ]
$domain = [ 'domain' ]
$location_cfg_append = undef
$nginx_dirs = [ "$full_web_path/", "$full_web_path/$webshortname.$domain/" ]
}
class nginx::amcustom::site1 {
include ::nginx,nginx::amcustom::site1_config
require users::amcustom::gitpull_ux
}
我的问题是我指定的变量没有传递给我的类(详细的 nginx::resource::vhost)并且报告的错误是:
puppet-agent[20280]: Failed to apply catalog: Parameter path failed on File[undef]: File paths must be fully qualified, not 'undef' at /etc/puppet/environments/development/modules/nginx/manifests/amcustom/ux_std_vhost.pp:8
puppet 文档目前让我大吃一惊,因此非常感谢您提供一些易于理解的帮助。
TIA。
上午
【问题讨论】:
标签: variables inheritance module include puppet