Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow purge of confd dir as optional argument. #26

Merged
merged 3 commits into from
Oct 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
# Sample Usage:
#
# This class file is not called directly
class nginx::config inherits nginx::params {
class nginx::config(
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$confd_purge = $nginx::params::nx_confd_purge,
) inherits nginx::params {
File {
owner => 'root',
group => 'root',
Expand All @@ -27,6 +32,14 @@
file { "${nginx::params::nx_conf_dir}/conf.d":
ensure => directory,
}
if $confd_purge == true {
File["${nginx::params::nx_conf_dir}/conf.d"] {
ignore => "vhost_autogen.conf",
purge => true,
recurse => true,
}
}


file { "${nginx::config::nx_run_dir}":
ensure => directory,
Expand Down
15 changes: 12 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
# node default {
# include nginx
# }
class nginx {
class nginx (
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$confd_purge = $nginx::params::nx_confd_purge,
) inherits nginx::params {

include stdlib

Expand All @@ -37,8 +42,12 @@
}

class { 'nginx::config':
require => Class['nginx::package'],
notify => Class['nginx::service'],
worker_processes => $worker_processes,
worker_connections => $worker_connections,
proxy_set_header => $proxy_set_header,
confd_purge => $confd_purge,
require => Class['nginx::package'],
notify => Class['nginx::service'],
}

class { 'nginx::service': }
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$nx_run_dir = '/var/nginx'

$nx_conf_dir = '/etc/nginx'
$nx_confd_purge = false
$nx_worker_processes = 1
$nx_worker_connections = 1024
$nx_multi_accept = off
Expand Down
1 change: 1 addition & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
exec { 'rebuild-nginx-vhosts':
command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.d/* > ${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf",
refreshonly => true,
unless => "/usr/bin/test ! -f ${nginx::params::nx_temp_dir}/nginx.d/*",
subscribe => File["${nginx::params::nx_temp_dir}/nginx.d"],
}
service { "nginx":
Expand Down
4 changes: 2 additions & 2 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
user <%= scope.lookupvar('nginx::config::nx_daemon_user') %>;
worker_processes <%= scope.lookupvar('nginx::params::nx_worker_processes')%>;
worker_processes <%= worker_processes %>;

error_log <%= scope.lookupvar('nginx::params::nx_logdir')%>/error.log;
pid <%= scope.lookupvar('nginx::params::nx_pid')%>;

events {
worker_connections <%= scope.lookupvar('nginx::params::nx_worker_connections') %>;
worker_connections <%= worker_connections %>;
<% if scope.lookupvar('nginx::params::nx_multi_accept') == 'on' %>multi_accept on;<% end %>
}

Expand Down
2 changes: 1 addition & 1 deletion templates/conf.d/proxy.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ proxy_connect_timeout <%= scope.lookupvar('nginx::params::nx_proxy_connect_tim
proxy_send_timeout <%= scope.lookupvar('nginx::params::nx_proxy_send_timeout') %>;
proxy_read_timeout <%= scope.lookupvar('nginx::params::nx_proxy_read_timeout') %>;
proxy_buffers <%= scope.lookupvar('nginx::params::nx_proxy_buffers') %>;
<% scope.lookupvar('nginx::params::nx_proxy_set_header').each do |header| %>
<% proxy_set_header.each do |header| %>
proxy_set_header <%= header %>;
<% end %>