Skip to content

Commit 1d28c0f

Browse files
author
Dan Foster
committed
Initial commit
0 parents  commit 1d28c0f

14 files changed

+306
-0
lines changed

.fixtures.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fixtures:
2+
forge_modules:
3+
symlinks:
4+
networker: "#{source_dir}"

Gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://rubygems.org'
2+
3+
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
4+
gem 'puppet', puppetversion
5+
gem 'puppetlabs_spec_helper', '>= 0.1.0'
6+
gem 'puppet-lint', '>= 0.3.2'
7+
gem 'facter', '>= 1.7.0'
8+
gem 'rspec', '< 3.0.0'
9+
gem 'beaker-rspec'

README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# networker
2+
3+
#### Table of Contents
4+
5+
1. [Overview](#overview)
6+
2. [Module Description - What the module does and why it is useful](#module-description)
7+
3. [Setup - The basics of getting started with networker](#setup)
8+
* [What networker affects](#what-networker-affects)
9+
* [Setup requirements](#setup-requirements)
10+
* [Beginning with networker](#beginning-with-networker)
11+
4. [Usage - Configuration options and additional functionality](#usage)
12+
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
13+
5. [Limitations - OS compatibility, etc.](#limitations)
14+
6. [Development - Guide for contributing to the module](#development)
15+
16+
## Overview
17+
18+
A one-maybe-two sentence summary of what the module does/what problem it solves.
19+
This is your 30 second elevator pitch for your module. Consider including
20+
OS/Puppet version it works with.
21+
22+
## Module Description
23+
24+
If applicable, this section should have a brief description of the technology
25+
the module integrates with and what that integration enables. This section
26+
should answer the questions: "What does this module *do*?" and "Why would I use
27+
it?"
28+
29+
If your module has a range of functionality (installation, configuration,
30+
management, etc.) this is the time to mention it.
31+
32+
## Setup
33+
34+
### What networker affects
35+
36+
* A list of files, packages, services, or operations that the module will alter,
37+
impact, or execute on the system it's installed on.
38+
* This is a great place to stick any warnings.
39+
* Can be in list or paragraph form.
40+
41+
### Setup Requirements **OPTIONAL**
42+
43+
If your module requires anything extra before setting up (pluginsync enabled,
44+
etc.), mention it here.
45+
46+
### Beginning with networker
47+
48+
The very basic steps needed for a user to get the module up and running.
49+
50+
If your most recent release breaks compatibility or requires particular steps
51+
for upgrading, you may wish to include an additional section here: Upgrading
52+
(For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
53+
54+
## Usage
55+
56+
Put the classes, types, and resources for customizing, configuring, and doing
57+
the fancy stuff with your module here.
58+
59+
## Reference
60+
61+
Here, list the classes, types, providers, facts, etc contained in your module.
62+
This section should include all of the under-the-hood workings of your module so
63+
people know what the module is touching on their system but don't need to mess
64+
with things. (We are working on automating this section!)
65+
66+
## Limitations
67+
68+
This is where you list OS compatibility, version compatibility, etc.
69+
70+
## Development
71+
72+
Pull requests are gratefully received.

Rakefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
require 'puppet-lint/tasks/puppet-lint'
4+
PuppetLint.configuration.send('disable_80chars')
5+
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
6+
7+
desc "Validate manifests, templates, and ruby files"
8+
task :validate do
9+
Dir['manifests/**/*.pp'].each do |manifest|
10+
sh "puppet parser validate --noop #{manifest}"
11+
end
12+
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
13+
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
14+
end
15+
Dir['templates/**/*.erb'].each do |template|
16+
sh "erb -P -x -T '-' #{template} | ruby -c"
17+
end
18+
end
19+
20+
Rake::Task[:default].clear
21+
task :default => [:validate,:lint,:spec]

manifests/.init.pp.swp

12 KB
Binary file not shown.

manifests/init.pp

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# == Class: networker
2+
#
3+
# Full description of class networker here.
4+
#
5+
# === Examples
6+
#
7+
# class { 'networker':
8+
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
9+
# }
10+
#
11+
# === Authors
12+
#
13+
# Dan Foster <dan@zem.org.uk>
14+
#
15+
# === Copyright
16+
#
17+
# Copyright 2015 Dan Foster, unless otherwise noted.
18+
#
19+
class networker (
20+
$service_ports = $networker::params::service_ports,
21+
$connection_ports = $networker::params::connection_ports,
22+
$server = $networker::params::server
23+
) inherits networker::params
24+
25+
$shortserver = inline_template("<%= '${server}'.split('.')[0] %>")
26+
27+
package { 'lgtoclnt':
28+
ensure => present
29+
}
30+
31+
file { '/.nsr':
32+
ensure => file,
33+
source => 'puppet:///modules/networker/dotnsr',
34+
}
35+
36+
file { '/nsr/res':
37+
ensure => 'directory',
38+
recurse => true,
39+
require => Package['lgtoclnt']
40+
}
41+
42+
file { '/nsr/res/servers':
43+
ensure => file,
44+
content => "${server}
45+
${shortserver}
46+
",
47+
require => File['/nsr/res']
48+
}
49+
50+
service { 'networker':
51+
ensure => running,
52+
require => Package['lgtoclnt']
53+
}
54+
55+
exec { "/usr/bin/nsrports -s ${server} -S ${service_ports}":
56+
refreshonly => true,
57+
subscribe => Package['lgtoclnt'],
58+
require => Service['networker'],
59+
}
60+
61+
exec { "/usr/bin/nsrports -S ${service_ports}":
62+
refreshonly => true,
63+
subscribe => Package['lgtoclnt'],
64+
require => Service['networker'],
65+
}
66+
67+
exec { "/usr/bin/nsrports -s ${server} -C ${connection_ports}":
68+
refreshonly => true,
69+
subscribe => Package['lgtoclnt'],
70+
require => Service['networker'],
71+
}
72+
73+
exec { "/usr/bin/nsrports -C ${connection_ports}":
74+
refreshonly => true,
75+
subscribe => Package['lgtoclnt'],
76+
require => Service['networker'],
77+
}
78+
79+
firewall {'050 allow central backups service ports':
80+
port => $service_ports,
81+
action => accept,
82+
source => $server
83+
}
84+
85+
firewall {'050 allow central backups connection ports':
86+
port => $connection_ports,
87+
action => accept,
88+
source => $server
89+
}
90+
91+
}

manifests/params.pp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# == Class: networker::params
2+
#
3+
# === Parameters
4+
#
5+
# Document parameters here.
6+
#
7+
# [*sample_parameter*]
8+
# Explanation of what this parameter affects and what it defaults to.
9+
# e.g. "Specify one or more upstream ntp servers as an array."
10+
#
11+
class networker::params {
12+
}

metadata.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "danfoster-networker",
3+
"version": "0.1.0",
4+
"author": "danfoster",
5+
"summary": "Manages EMC Networker client",
6+
"license": "Apache 2.0",
7+
"source": "https://github.com/danfoster/puppet-networker",
8+
"project_page": "https://github.com/danfoster/puppet-networker",
9+
"issues_url": "https://github.com/danfoster/puppet-networker/issues",
10+
"tags": ["backup","networker"],
11+
"dependencies": [
12+
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
13+
]
14+
}
15+

spec/acceptance/module_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe '<%= metadata.name %> class' do
4+
describe 'running puppet code' do
5+
it 'apply manifest' do
6+
pp = <<-EOS
7+
class { '<%= metadata.name %>': }
8+
EOS
9+
10+
# Run it twice and test for idempotency
11+
apply_manifest(pp, :catch_failures => true)
12+
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
13+
end
14+
end
15+
16+
end

spec/acceptance/nodesets/default.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
centos-65-x64:
3+
roles:
4+
- master
5+
- default
6+
platform: el-6-x86_64
7+
box: puppetlabs/centos-6.5-64-nocm
8+
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.5-64-nocm
9+
hypervisor: vagrant
10+
CONFIG:
11+
type: foss
12+
log_level: verbose

spec/classes/init_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'spec_helper'
2+
describe 'networker' do
3+
4+
context 'with defaults for all parameters' do
5+
it { should contain_class('networker') }
6+
end
7+
end

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/module_spec_helper'

spec/spec_helper_acceptance.rb

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'beaker-rspec'
2+
require 'beaker-rspec/helpers/serverspec'
3+
4+
unless ENV['BEAKER_provision'] == 'no'
5+
hosts.each do |host|
6+
# Install Puppet
7+
foss_opts = { :default_action => 'gem_install' }
8+
9+
10+
hosts.each do |host|
11+
if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
12+
on hosts, "mkdir -p #{host['distmoduledir']}"
13+
end
14+
end
15+
end
16+
17+
RSpec.configure do |c|
18+
# Project root
19+
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
20+
21+
# Readable test descriptions
22+
c.formatter = :documentation
23+
24+
# Configure all nodes in nodeset
25+
c.before :suite do
26+
# Install module
27+
puppet_module_install(:source => proj_root, :module_name => 'networker')
28+
hosts.each do |host|
29+
# Install and dep modules, e.g.
30+
# on host, puppet('module','install','puppetlabs-firewall'), { :acceptable_exit_codes => [0,1] }
31+
end
32+
end
33+
end

tests/init.pp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The baseline for module testing used by Puppet Labs is that each manifest
2+
# should have a corresponding test manifest that declares that class or defined
3+
# type.
4+
#
5+
# Tests are then run by using puppet apply --noop (to check for compilation
6+
# errors and view a log of events) or by fully applying the test in a virtual
7+
# environment (to compare the resulting system state to the desired state).
8+
#
9+
# Learn more about module testing here:
10+
# http://docs.puppetlabs.com/guides/tests_smoke.html
11+
#
12+
include networker

0 commit comments

Comments
 (0)