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

Update map and mount defined types to address #59 #61

Merged
merged 4 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 16 additions & 3 deletions manifests/map.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@
# @param order Order in which entries will appear in the autofs map file.

define autofs::map (
String $mapcontent,
Array $mapcontent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking change

Copy link
Member Author

@dhollinger dhollinger Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That has not been in a module release yet and was just merged earlier today before I identified some limitations that needed to be addressed.

Brings up a point - are breaking changes only tied to releases or to any merge?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay \o/

Stdlib::Absolutepath $mapfile,
Integer $order = 1,
Enum['autofs/auto.map.erb', 'autofs/auto.map.exec.erb'] $template = 'autofs/auto.map.erb',
String $mapmode = '0644',
Boolean $replace = true,
Integer $order = 1,
) {

concat { $mapfile:
ensure => present,
owner => 'root',
group => 'root',
mode => $mapmode,
replace => $replace,
require => Package['autofs'],
notify => Service['autofs'],
}

concat::fragment{"${mapfile}_${mapcontent}":
target => $mapfile,
content => "${mapcontent}\n",
content => template($template),
order => $order,
}

Expand Down
27 changes: 10 additions & 17 deletions manifests/mount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
group => 'root',
mode => '0644',
ensure_newline => true,
notify => Service[ 'autofs' ],
notify => Service['autofs'],
}
}

Expand All @@ -96,7 +96,7 @@
target => $master,
content => "+dir:${map_dir}",
order => $order,
require => File[ $map_dir ],
require => File[$map_dir],
}
}

Expand All @@ -106,25 +106,18 @@
group => 'root',
mode => $mapperms,
content => $contents,
require => File[ $map_dir ],
notify => Service[ 'autofs' ],
require => File[$map_dir],
notify => Service['autofs'],
}
}

if $mapfile {
concat { $mapfile:
ensure => present,
owner => 'root',
group => 'root',
mode => $mapperms,
replace => $replace,
require => Package[ 'autofs' ],
notify => Service[ 'autofs' ],
}
concat::fragment{"${mapfile}_entries":
target => $mapfile,
content => template($maptempl),
order => 1,
autofs::map { $title:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

mapfile => $mapfile,
mapcontent => $mapcontents,
replace => $replace,
template => $maptempl,
mapmode => $mapperms,
}
}
}
9 changes: 4 additions & 5 deletions spec/acceptance/autofs_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,10 @@ class { 'autofs':
it { is_expected.not_to be_running }
end

# Skipped until we can pinpoint why serverspec
# doesn't properly check if an Upstart service
# is enabled or not
describe service('autofs') do
xit { is_expected.not_to be_enabled }
unless default[:platform] =~ %r{ubuntu-14.04-amd64}
describe service('autofs') do
it { is_expected.not_to be_enabled }
end
end
end
end
Expand Down
24 changes: 3 additions & 21 deletions spec/acceptance/autofs_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,23 @@
it 'applies' do
pp = <<-EOS
class { 'autofs': }
autofs::mount { 'data':
mount => '/data',
autofs::map { 'datamap':
mapfile => '/etc/auto.data',
mapcontents => ['dataB -o rw /mnt/dataB'],
options => '--timeout=120',
order => 01
mapcontent => [ 'dataB -o rw /mnt/dataB', 'dataC -o rw /mnt/dataC' ],
}
autofs::map {'dataC':
mapfile => '/etc/auto.data',
mapcontent => 'dataC -o rw /mnt/dataC',
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe file('/etc/auto.master') do
it 'exists and have content' do
is_expected.to exist
is_expected.to be_owned_by 'root'
is_expected.to be_grouped_into 'root'
shell('cat /etc/auto.master') do |s|
expect(s.stdout).to match(%r{/data /etc/auto.data --timeout=120})
end
end
end

describe file('/etc/auto.data') do
it 'exists and have content' do
is_expected.to exist
is_expected.to be_owned_by 'root'
is_expected.to be_grouped_into 'root'
shell('cat /etc/auto.data') do |s|
expect(s.stdout).to match(%r{(dataA -o rw /mnt/dataA|dataC -o rw /mnt/dataC)})
expect(s.stdout).to match(%r{(dataB -o rw /mnt/dataA|dataC -o rw /mnt/dataC)})
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion templates/auto.map.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
###############################################################
<% end -%>

<% @mapcontents.each do |content| -%>
<% @mapcontent.each do |content| -%>
<%= content %>
<% end -%>
2 changes: 1 addition & 1 deletion templates/auto.map.exec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
###############################################################
<% end -%>

<% @mapcontents.each do |content| -%>
<% @mapcontent.each do |content| -%>
<%= content %>
<% end -%>