Skip to content

Commit

Permalink
Add 'require' for parent dir of upstream, map, and geo configs as well (
Browse files Browse the repository at this point in the history
  • Loading branch information
William Yardley committed Nov 2, 2016
1 parent 310d43a commit af61b94
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 13 deletions.
6 changes: 4 additions & 2 deletions manifests/resource/geo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# [*proxy_recursive*] - Changes the behavior of address acquisition when
# specifying trusted proxies via 'proxies' directive
# [*proxies*] - Hash of network->value mappings.

#
# Actions:
#
# Requires:
Expand Down Expand Up @@ -74,6 +74,7 @@
if ($proxy_recursive != undef) { validate_bool($proxy_recursive) }

$root_group = $::nginx::config::root_group
$conf_dir = "${::nginx::config::conf_dir}/conf.d"

$ensure_real = $ensure ? {
'absent' => 'absent',
Expand All @@ -86,9 +87,10 @@
mode => '0644',
}

file { "${::nginx::config::conf_dir}/conf.d/${name}-geo.conf":
file { "${conf_dir}/${name}-geo.conf":
ensure => $ensure_real,
content => template('nginx/conf.d/geo.erb'),
notify => Class['::nginx::service'],
require => File[$conf_dir],
}
}
12 changes: 7 additions & 5 deletions manifests/resource/mailhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
validate_string($xclient)
validate_array($server_name)

$config_file = "${::nginx::config::conf_dir}/conf.mail.d/${name}.conf"
$config_dir = "${::nginx::config::conf_dir}/conf.mail.d"
$config_file = "${config_dir}/${name}.conf"

# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
# and support does not exist for it in the kernel.
Expand All @@ -146,10 +147,11 @@
}

concat { $config_file:
owner => 'root',
group => $root_group,
mode => '0644',
notify => Class['::nginx::service'],
owner => 'root',
group => $root_group,
mode => '0644',
notify => Class['::nginx::service'],
require => File[$config_dir],
}

if (($ssl_port == undef) or ($listen_port + 0) != ($ssl_port + 0)) {
Expand Down
6 changes: 4 additions & 2 deletions manifests/resource/map.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# [*mappings*] - Hash of map lookup keys and resultant values
# [*hostnames*] - Indicates that source values can be hostnames with a
# prefix or suffix mask.

#
# Actions:
#
# Requires:
Expand Down Expand Up @@ -81,6 +81,7 @@
if ($default != undef) { validate_string($default) }

$root_group = $::nginx::config::root_group
$conf_dir = "${::nginx::config::conf_dir}/conf.d"

$ensure_real = $ensure ? {
'absent' => absent,
Expand All @@ -93,9 +94,10 @@
mode => '0644',
}

file { "${::nginx::config::conf_dir}/conf.d/${name}-map.conf":
file { "${conf_dir}/${name}-map.conf":
ensure => $ensure_real,
content => template('nginx/conf.d/map.erb'),
notify => Class['::nginx::service'],
require => File[$conf_dir],
}
}
9 changes: 6 additions & 3 deletions manifests/resource/upstream.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@
default => 'conf.d',
}

$conf_dir = "${::nginx::config::conf_dir}/${conf_dir_real}"

Concat {
owner => 'root',
group => $root_group,
mode => '0644',
}

concat { "${::nginx::config::conf_dir}/${conf_dir_real}/${name}-upstream.conf":
ensure => $ensure_real,
notify => Class['::nginx::service'],
concat { "${conf_dir}/${name}-upstream.conf":
ensure => $ensure_real,
notify => Class['::nginx::service'],
require => File[$conf_dir],
}

# Uses: $name, $upstream_cfg_prepend
Expand Down
1 change: 1 addition & 0 deletions spec/defines/resource_geo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
describe 'basic assumptions' do
let(:params) { default_params }

it { is_expected.to contain_file("/etc/nginx/conf.d/#{title}-geo.conf").that_requires('File[/etc/nginx/conf.d]') }
it do
is_expected.to contain_file("/etc/nginx/conf.d/#{title}-geo.conf").with(
'owner' => 'root',
Expand Down
1 change: 1 addition & 0 deletions spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
describe 'basic assumptions' do
let(:params) { default_params }
it { is_expected.to contain_class('nginx::config') }
it { is_expected.to contain_concat("/etc/nginx/conf.mail.d/#{title}.conf").that_requires('File[/etc/nginx/conf.mail.d]') }
it do
is_expected.to contain_concat("/etc/nginx/conf.mail.d/#{title}.conf").with('owner' => 'root',
'group' => 'root',
Expand Down
1 change: 1 addition & 0 deletions spec/defines/resource_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
describe 'basic assumptions' do
let(:params) { default_params }

it { is_expected.to contain_file("/etc/nginx/conf.d/#{title}-map.conf").that_requires('File[/etc/nginx/conf.d]') }
it do
is_expected.to contain_file("/etc/nginx/conf.d/#{title}-map.conf").with(
'owner' => 'root',
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_upstream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
describe 'basic assumptions' do
let(:params) { default_params }

it { is_expected.to contain_concat("/etc/nginx/conf.d/#{title}-upstream.conf") }
it { is_expected.to contain_concat("/etc/nginx/conf.d/#{title}-upstream.conf").that_requires('File[/etc/nginx/conf.d]') }
it { is_expected.to contain_concat__fragment("#{title}_upstream_header").with_content(%r{upstream #{title}}) }

it do
Expand Down

0 comments on commit af61b94

Please sign in to comment.