Add Hiera support

This supports creating resourses directly in Hiera for better separation of data
This commit is contained in:
Pan 2013-07-18 15:10:12 -07:00
parent 9c7712a190
commit 1257cb3355
2 changed files with 38 additions and 1 deletions

View file

@ -66,3 +66,30 @@ Add an smtp proxy
}
}
</pre>
# Hiera Support
Define the nginx resources in Hiera. Here are the examples:
<pre>
nginx::nginx_upstreams:
'puppet_rack_app':
ensure: present
members:
- localhost:3000
- localhost:3001
- localhost:3002
nginx::nginx_vhosts:
'www.puppetlabs.com':
www_root: '/var/www/www.puppetlabs.com'
'rack.puppetlabs.com':
ensure: present
proxy: 'http://puppet_rack_app'
nginx::nginx_locations:
'static':
location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"'
vhost: www.puppetlabs.com
'userContent':
location: /userContent
vhost: www.puppetlabs.com
www_root: /var/www/html
</pre>

View file

@ -42,7 +42,10 @@ class nginx (
$configtest_enable = $nginx::params::nx_configtest_enable,
$service_restart = $nginx::params::nx_service_restart,
$mail = $nginx::params::nx_mail,
$server_tokens = $nginx::params::nx_server_tokens
$server_tokens = $nginx::params::nx_server_tokens,
$nginx_vhosts = {},
$nginx_upstreams = {},
$nginx_locations = {},
) inherits nginx::params {
include stdlib
@ -72,6 +75,13 @@ class nginx (
service_restart => $service_restart,
}
validate_hash($nginx_upstreams)
create_resources('nginx::resource::upstream', $nginx_upstreams)
validate_hash($nginx_vhosts)
create_resources('nginx::resource::vhost', $nginx_vhosts)
validate_hash($nginx_locations)
create_resources('nginx::resource::location', $nginx_locations)
# Allow the end user to establish relationships to the "main" class
# and preserve the relationship to the implementation classes through
# a transitive relationship to the composite class.