-
-
Notifications
You must be signed in to change notification settings - Fork 881
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
Switch to using concat{} instead of lots of file{} magic. #167
Changes from all commits
6516820
2533623
a42f971
d2ec91d
0922eb7
dd81086
9a39249
2459844
2023ca1
7532832
d849c31
eb31df4
0e1d4ad
a9c445b
684fafc
486d03b
2ccd399
390b491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ pkg/ | |
.librarian/ | ||
.tmp/ | ||
pkg/ | ||
Gemfile.lock | ||
spec/fixtures/ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,15 @@ | |
validate_array($index_files) | ||
validate_array($server_name) | ||
|
||
# Variables | ||
$vhost_dir = "${nginx::config::nx_conf_dir}/sites-available" | ||
$vhost_enable_dir = "${nginx::config::nx_conf_dir}/sites-enabled" | ||
$vhost_symlink_ensure = $ensure ? { | ||
'absent' => absent, | ||
default => 'link', | ||
} | ||
$config_file = "${vhost_dir}/${name}.conf" | ||
|
||
File { | ||
ensure => $ensure ? { | ||
'absent' => absent, | ||
|
@@ -181,6 +190,13 @@ | |
default => $error_log, | ||
} | ||
|
||
concat { $config_file: | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0644', | ||
notify => Class['nginx::service'], | ||
} | ||
|
||
if ($ssl == true) and ($ssl_port == $listen_port) { | ||
$ssl_only = true | ||
} | ||
|
@@ -231,22 +247,21 @@ | |
} | ||
} | ||
|
||
# Use the File Fragment Pattern to construct the configuration files. | ||
# Create the base configuration file reference. | ||
if ($listen_port != $ssl_port) { | ||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-001": | ||
ensure => $ensure ? { | ||
'absent' => absent, | ||
default => 'file', | ||
}, | ||
concat::fragment { "${name}-header": | ||
target => $config_file, | ||
content => template('nginx/vhost/vhost_header.erb'), | ||
notify => Class['nginx::service'], | ||
order => '001', | ||
} | ||
} | ||
|
||
# Create a proper file close stub. | ||
if ($listen_port != $ssl_port) { | ||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-699": content => template('nginx/vhost/vhost_footer.erb'), } | ||
concat::fragment { "${name}-footer": | ||
target => $config_file, | ||
content => template('nginx/vhost/vhost_footer.erb'), | ||
order => '699', | ||
} | ||
} | ||
|
||
# Create SSL File Stubs if SSL is enabled | ||
|
@@ -260,25 +275,19 @@ | |
undef => "${nginx::params::nx_logdir}/ssl-${domain_log_name}.error.log", | ||
default => $error_log, | ||
} | ||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-700-ssl": | ||
ensure => $ensure ? { | ||
'absent' => absent, | ||
default => 'file', | ||
}, | ||
|
||
concat::fragment { "${name}-ssl-header": | ||
target => $config_file, | ||
content => template('nginx/vhost/vhost_ssl_header.erb'), | ||
notify => Class['nginx::service'], | ||
order => '700', | ||
} | ||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-999-ssl": | ||
ensure => $ensure ? { | ||
'absent' => absent, | ||
default => 'file', | ||
}, | ||
concat::fragment { "${name}-ssl-footer": | ||
target => $config_file, | ||
content => template('nginx/vhost/vhost_ssl_footer.erb'), | ||
notify => Class['nginx::service'], | ||
order => '999', | ||
} | ||
|
||
#Generate ssl key/cert with provided file-locations | ||
|
||
$cert = regsubst($name,' ','_') | ||
|
||
# Check if the file has been defined before creating the file to | ||
|
@@ -294,4 +303,12 @@ | |
source => $ssl_key, | ||
}) | ||
} | ||
|
||
file{ "${name}.conf symlink": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by this here. I know that this pull incorporates the Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you suggesting this module just put the vhost file in Also if there's no symlink there'll be no way to remove a site from |
||
ensure => $vhost_symlink_ensure, | ||
path => "${vhost_enable_dir}/${name}.conf", | ||
target => $config_file, | ||
require => Concat[$config_file], | ||
notify => Service['nginx'], | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about
ensure => absent
to clean up mess from old concat?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It crossed my mind - I left it out since it's a temp folder anyway so things should get wiped out periodically without help from the module.
I'll add it back so people's systems get cleaned up a little.