Skip to content

Commit

Permalink
Merge pull request voxpupuli#2 from EagleDelta2/v1.1.2
Browse files Browse the repository at this point in the history
v1.1.2-release
  • Loading branch information
dhollinger committed Jun 19, 2015
2 parents e487b31 + 6780a48 commit 02df485
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 89 deletions.
6 changes: 6 additions & 0 deletions .fixtures.yml
@@ -0,0 +1,6 @@
fixtures:
repositories:
stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git
concat: git://github.com/puppetlabs/puppetlabs-concat.git
symlinks:
autofs: "#{source_dir}"
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -2,7 +2,8 @@
./*/.DS_Store
./pkg/*
.idea/
.idea/*
.exvim.autofs/
.exvim.autofs/*
autofs.exvim
Gemfile.lock
spec/fixtures/manifests/
spec/fixtures/modules/
16 changes: 16 additions & 0 deletions .travis.yml
@@ -0,0 +1,16 @@
---
sudo: false
language: ruby
bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec"
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
notifications:
email: false
3 changes: 2 additions & 1 deletion Gemfile
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'puppet', '>= 3.3'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', '>= 1.7.0'
51 changes: 0 additions & 51 deletions Gemfile.lock

This file was deleted.

8 changes: 6 additions & 2 deletions Readme.md
Expand Up @@ -45,17 +45,21 @@ generate the mapfiles and mount points from the entries in your YAML file.
###Example:

```yaml
---
mapOptions:
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'
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
tmp:
mount: '/tmp'
mapfile: '/etc/auto.tmp'
mapcontent: 'tempfiles -rw,noacl server.example.com:/path/to/tmp/mount'
mapcontent:
- 'tempfiles -rw,noacl server.example.com:/path/to/tmp/mount'
- 'temparchive -rw,noacl server.example.com:/path/to/tmp/archive'
options: '--timeout=60'
order: 02
```
Expand Down
7 changes: 7 additions & 0 deletions manifests/config.pp
Expand Up @@ -9,6 +9,13 @@
class autofs::config {
$map_options = hiera('mapOptions')

concat { '/etc/auto.master':
owner => 'root',
group => 'root',
mode => '0644',
notify => Service[ 'autofs' ],
}

create_resources( 'autofs::mount', $map_options)

}
8 changes: 3 additions & 5 deletions manifests/init.pp
Expand Up @@ -16,9 +16,7 @@
# Copyright 2014 David Hollinger III
#
class autofs {
anchor { 'autofs::begin': }
class { 'autofs::install': } ->
class { 'autofs::config': } ~>
class { 'autofs::service': }
anchor { 'autofs::end': }
include autofs::package
include autofs::config
include autofs::service
}
14 changes: 4 additions & 10 deletions manifests/mount.pp
Expand Up @@ -8,22 +8,16 @@
$order,
) {

concat { '/etc/auto.master':
owner => 'root',
group => 'root',
mode => '0644',
notify => Service[ 'autofs' ],
}

concat::fragment { 'autofs::fragment preamble /etc/auto.master':
concat::fragment { "autofs::fragment preamble ${mount}":
ensure => present,
target => '/etc/auto.master',
content => "${mount} ${mapfile} ${options}",
content => "${mount} ${mapfile} ${options}\n",
order => $order,
}

file { $mount:
ensure => directory,
ensure => directory,
require => Package[ 'autofs' ],
}

file { $mapfile:
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp → manifests/package.pp
Expand Up @@ -2,7 +2,7 @@
#
# This class ensures that autofs is installed.
#
class autofs::install {
class autofs::package {
Package {
ensure => installed
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
@@ -1,6 +1,6 @@
{
"name": "EagleDelta2-autofs",
"version": "1.1.1",
"version": "1.1.2",
"author": "David Hollinger",
"summary": "Module for installing and managing autofs",
"license": "Apache-2.0",
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/autofs_spec.rb
@@ -0,0 +1,16 @@
require 'spec_helper'
describe 'autofs', :type => :class do

context 'main init tests' do
let(:facts) do
{
:osfamily => 'RedHat',
:concat_basedir => '/etc'
}
end
it { should contain_class('autofs::package') }
it { should contain_class('autofs::config') }
it { should contain_class('autofs::service') }
end

end
8 changes: 6 additions & 2 deletions spec/classes/config_spec.rb
@@ -1,4 +1,8 @@
require 'spec_helper'
describe 'autofs::config' do
describe 'autofs::config', :type => :class do
hiera = Hiera.new(:config => 'spec/fixtures/hiera/hiera.yaml')
mapoptions = hiera.lookup('mapOptions', nil, nil)
let(:params) {{ :map_options => mapoptions}}

end

end
11 changes: 0 additions & 11 deletions spec/classes/init_spec.rb

This file was deleted.

19 changes: 19 additions & 0 deletions spec/classes/package_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'
describe 'autofs::package', :type => :class do
opsys = %w(
Debian
Ubuntu
RedHat
CentOS
)

opsys.each do |os|
context "install autofs #{os}" do
let(:facts){ {:osfamily => "#{os}"} }

it { should contain_package('autofs').with_ensure('installed') }

end
end

end
14 changes: 14 additions & 0 deletions spec/classes/service_spec.rb
@@ -0,0 +1,14 @@
require 'spec_helper'
describe 'autofs::service', :type => :class do

context 'test default service' do
it { should contain_service('autofs').with(
'ensure' => 'running',
'enable' => 'true',
'hasstatus' => 'true',
'hasrestart' => 'true',
)
}
end

end
42 changes: 42 additions & 0 deletions spec/defines/mount_spec.rb
@@ -0,0 +1,42 @@
require 'spec_helper'
describe 'autofs::mount', :type => :define do
let(:title) { 'auto.home' }

let(:facts) do
{
:concat_basedir => '/etc'
}
end

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

context 'with default parameters' do

it do
should contain_concat__fragment('autofs::fragment preamble /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'
)
end
end


end
7 changes: 7 additions & 0 deletions spec/fixtures/hiera/hiera.yaml
@@ -0,0 +1,7 @@
---
:backends:
- yaml
:hierarchy:
- test
:yaml:
:datadir: 'spec/fixtures/hiera'
11 changes: 11 additions & 0 deletions spec/fixtures/hiera/test.yaml
@@ -0,0 +1,11 @@
---
mapOptions:
home:
mount: '/home'
mapfile: '/etc/auto.home'
mapcontents:
- 'test'
- 'foo'
- 'bar'
options: '--timeout=120'
order: 01
42 changes: 42 additions & 0 deletions spec/spec_helper.rb
@@ -1 +1,43 @@
require 'rspec-puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
require 'mocha'
require 'hiera'
require 'erb'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
# include common helpers
support_path = File.expand_path(File.join(File.dirname(__FILE__), '..',
'spec/support/*.rb'))
Dir[support_path].each {|f| require f}
RSpec.configure do |c|
c.config = '/doesnotexist'
c.manifest_dir = File.join(fixture_path, 'manifests')
c.mock_with :rspec do |mock|
mock.syntax = [:expect, :should]
end
c.hiera_config = File.join(fixture_path, 'hiera/hiera.yaml')
c.include PuppetlabsSpec::Files

if ENV['PARSER'] == 'future'
c.parser = 'future'
end

c.before :each do
# Ensure that we don't accidentally cache facts and environment
# between test cases.
Facter::Util::Loader.any_instance.stubs(:load_all)
Facter.clear
Facter.clear_messages

# Store any environment variables away to be restored later
@old_env = {}
ENV.each_key {|k| @old_env[k] = ENV[k]}

if Gem::Version.new(`puppet --version`) >= Gem::Version.new('3.5')
Puppet.settings[:strict_variables]=true
end
end

c.after :each do
PuppetlabsSpec::Files.cleanup
end
end
6 changes: 3 additions & 3 deletions templates/auto.map.erb
Expand Up @@ -5,6 +5,6 @@
# #
###############################################################

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

0 comments on commit 02df485

Please sign in to comment.