Skip to content

Commit

Permalink
Merge pull request voxpupuli#12 from dhollinger/v1.3.0
Browse files Browse the repository at this point in the history
Merge for 1.3.0 release
  • Loading branch information
dhollinger committed Apr 9, 2016
2 parents 408eb18 + e61d58e commit 5f9e5c5
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 53 deletions.
39 changes: 39 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,38 @@ autofs::mounts:
order: 01
```

##### Autofs `+dir:` options

The autofs module now supports the use of the `+dir:` option in the auto.master.
This option is 100% functional, but does require some work to simplify it.

###### Usage

Define:
```puppet
autofs::mount { 'home':
mount => '/home',
mapfile => '/etc/auto.home',
mapcontents => ['* -user,rw,soft,intr,rsize=32768,wsize=32768,tcp,nfsvers=3,noacl server.example.com:/path/to/home/shares'],
options => '--timeout=120',
order => 01,
use_dir => true
}
```

Hiera:
```yaml
---
autofs::mounts:
home:
mount: '/home'
mapfile: '/etc/auto.home'
mapcontents:
- '* -user,rw,soft,intr,rsize=32768,wsize=32768,tcp,nfsvers=3,noacl server.example.com:/path/to/home/shares'
options: '--timeout=120'
order: 01
use_dir: true
```

#### Parameters
* **mount_name** - This is a logical, descriptive name for what what autofs will be
Expand All @@ -138,6 +170,13 @@ mapfile generation.
when mounting the automounts.
* **order** - This Mapping describes where in the auto.master file the entry will
be placed. Order CANNOT be duplicated.
* **master** - This Parameter sets the path to the auto.master file. Defaults to
`/etc/auto.master`.
* **map_dir** - This Parameter sets the path to the Autofs configuration directory
for map files. Applies only to autofs 5.0.5 or later. Defaults to
`/etc/auto.master.d`.
* **use_dir** - This Parameter tells the module if it is going to use $map_dir.
Defaults to `false`.
* **direct** - Boolean to allow for indirect map. Defaults to true to be backwards compatible.
* **execute** - Boolean to set the map to be executable. Defaults to false to be backward compatible.

Expand Down
17 changes: 0 additions & 17 deletions manifests/config.pp

This file was deleted.

8 changes: 4 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
#
#
class autofs(
$mounts = undef
$mounts = undef,
$use_map_dir = false,
$map_dir = '/etc/auto.master.d'
) {
class { 'autofs::package': }
class { 'autofs::config': }
class { 'autofs::service': }
contain 'autofs::package'
contain 'autofs::config'
contain 'autofs::service'

if ( $mounts != undef ) {
class { 'autofs::mounts': mount => $mounts }
}
Expand Down
43 changes: 36 additions & 7 deletions manifests/mount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,44 @@
$mapcontents,
$options,
$order,
$direct=true,
$execute=false
$master = '/etc/auto.master',
$map_dir = '/etc/auto.master.d',
$use_dir = false,
$direct = true,
$execute = false
) {

concat::fragment { "autofs::fragment preamble ${mount} ${mapfile}":
ensure => present,
target => '/etc/auto.master',
content => "${mount} ${mapfile} ${options}\n",
order => $order,
if !defined(Concat[$master]) {
concat { $master:
owner => 'root',
group => 'root',
mode => '0644',
notify => Service[ 'autofs' ],
}
}

if $use_dir == false {
concat::fragment { "autofs::fragment preamble ${mount} ${mapfile}":
ensure => present,
target => $master,
content => "${mount} ${mapfile} ${options}\n",
order => $order,
}
} else {
file { $map_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}

concat::fragment { 'autofs::fragment preamble map directory':
ensure => present,
target => $master,
content => "+dir:${map_dir}",
order => $order,
require => File[ $map_dir ],
}
}

if $execute {
Expand Down
4 changes: 4 additions & 0 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
'RedHat', 'CentOS': {
package { 'autofs': }
}
'Solaris': {
# Solaris includes autofs
# Block to prevent failures
}
default: {
fail("${::operatingsystem} not supported.")
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dhollinger-autofs",
"version": "1.2.0",
"version": "1.3.0",
"author": "David Hollinger III",
"summary": "Module for installing and managing autofs",
"license": "Apache-2.0",
Expand Down
1 change: 0 additions & 1 deletion spec/classes/autofs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}
end
it { should contain_class('autofs::package') }
it { should contain_class('autofs::config') }
it { should contain_class('autofs::service') }
end

Expand Down
11 changes: 0 additions & 11 deletions spec/classes/config_spec.rb

This file was deleted.

57 changes: 45 additions & 12 deletions spec/defines/mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@

let(:params) do
{
:mount => '/home',
:mapfile => '/etc/auto.home',
:mount => '/home',
:mapfile => '/etc/auto.home',
:mapcontents => %W( test foo bar ),
:options => '--timeout=120',
:order => '01'
:options => '--timeout=120',
:order => '01',
:master => '/etc/auto.master'
}
end

context 'with default parameters' do

it do
should contain_concat('/etc/auto.master')
should contain_concat__fragment('autofs::fragment preamble /home /etc/auto.home').with('target' => '/etc/auto.master')
end

# it do
# should contain_file('/home').with('ensure' => 'directory')
# end

it do
should contain_file('/etc/auto.home').with(
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0644'
'owner' => 'root',
'group' => 'root',
'mode' => '0644'
)
end
end
Expand All @@ -55,8 +53,43 @@
end
end

context 'with executable map' do
context 'with EL7 directory' do
let(:params) do
{
:mount => '/home',
:mapfile => '/etc/auto.master.d/home.autofs',
:mapcontents => %W( test foo bar ),
:options => '--timeout=120',
:order => '01',
:map_dir => '/etc/auto.master.d',
:use_dir => true
}
end

it do
should contain_concat__fragment('autofs::fragment preamble map directory')
end

it do
should contain_file('/etc/auto.master.d').with(
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0755'
)

should contain_file('/etc/auto.master.d/home.autofs').with(
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0644'
)
end
end


context 'with executable map' do
let (:params) do
{
:mount => '/home',
:mapfile => '/etc/auto.home',
Expand Down

0 comments on commit 5f9e5c5

Please sign in to comment.