From d654bf28ba7406110455fff947b2d7bb95e223a2 Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Mon, 21 Mar 2016 10:59:00 -0400 Subject: [PATCH] first commit --- .ruby-version | 1 + Gemfile | 8 ++++ Gemfile.lock | 66 +++++++++++++++++++++++++++++++ README.md | 83 +++++++++++++++++++++++++++++++++++++++ Rakefile | 17 ++++++++ manifests/config.pp | 14 +++++++ manifests/init.pp | 14 +++++++ manifests/install.pp | 11 ++++++ manifests/params.pp | 9 +++++ metadata.json | 15 +++++++ spec/classes/init_spec.rb | 7 ++++ spec/spec_helper.rb | 1 + templates/whats.yaml.erb | 7 ++++ tests/init.pp | 12 ++++++ 14 files changed, 265 insertions(+) create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 README.md create mode 100644 Rakefile create mode 100644 manifests/config.pp create mode 100644 manifests/init.pp create mode 100644 manifests/install.pp create mode 100644 manifests/params.pp create mode 100644 metadata.json create mode 100644 spec/classes/init_spec.rb create mode 100644 spec/spec_helper.rb create mode 100644 templates/whats.yaml.erb create mode 100644 tests/init.pp diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.1.0 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..430ec01 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' + +puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 4.0'] +gem 'puppet', puppetversion +gem 'puppetlabs_spec_helper', '>= 0.8.2' +gem 'puppet-lint', '>= 1.0.0' +gem 'facter', '>= 1.7.0' +gem 'puppet-retrospec' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..1a683de --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,66 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.2.8) + awesome_print (1.6.1) + diff-lcs (1.2.5) + facets (3.0.0) + facter (2.4.6) + CFPropertyList (~> 2.2.6) + hiera (3.1.0) + json_pure + json_pure (1.8.3) + metaclass (0.0.4) + mocha (1.1.0) + metaclass (~> 0.0.1) + puppet (4.4.0) + CFPropertyList (~> 2.2.6) + facter (> 2.0, < 4) + hiera (>= 2.0, < 4) + json_pure + puppet-lint (1.1.0) + puppet-retrospec (0.12.1) + awesome_print + facets + retrospec (~> 0.4) + trollop + puppet-syntax (2.1.0) + rake + puppetlabs_spec_helper (1.1.1) + mocha + puppet-lint + puppet-syntax + rake + rspec-puppet + rake (11.1.1) + retrospec (0.4.0) + trollop + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.4) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-puppet (2.3.2) + rspec + rspec-support (3.4.1) + trollop (2.1.2) + +PLATFORMS + ruby + +DEPENDENCIES + facter (>= 1.7.0) + puppet (>= 4.0) + puppet-lint (>= 1.0.0) + puppet-retrospec + puppetlabs_spec_helper (>= 0.8.2) + +BUNDLED WITH + 1.11.2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..916d6c2 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +# whats + +#### Table of Contents + +1. [Description](#description) +1. [Setup - The basics of getting started with whats](#setup) + * [What whats affects](#what-whats-affects) + * [Setup requirements](#setup-requirements) + * [Beginning with whats](#beginning-with-whats) +1. [Usage - Configuration options and additional functionality](#usage) +1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +1. [Limitations - OS compatibility, etc.](#limitations) +1. [Development - Guide for contributing to the module](#development) + +## Description + +Start with a one- or two-sentence summary of what the module does and/or what +problem it solves. This is your 30-second elevator pitch for your module. +Consider including OS/Puppet version it works with. + +You can give more descriptive information in a second paragraph. This paragraph +should answer the questions: "What does this module *do*?" and "Why would I use +it?" If your module has a range of functionality (installation, configuration, +management, etc.), this is the time to mention it. + +## Setup + +### What whats affects **OPTIONAL** + +If it's obvious what your module touches, you can skip this section. For +example, folks can probably figure out that your mysql_instance module affects +their MySQL instances. + +If there's more that they should know about, though, this is the place to mention: + +* A list of files, packages, services, or operations that the module will alter, + impact, or execute. +* Dependencies that your module automatically installs. +* Warnings or other important notices. + +### Setup Requirements **OPTIONAL** + +If your module requires anything extra before setting up (pluginsync enabled, +etc.), mention it here. + +If your most recent release breaks compatibility or requires particular steps +for upgrading, you might want to include an additional "Upgrading" section +here. + +### Beginning with whats + +The very basic steps needed for a user to get the module up and running. This +can include setup steps, if necessary, or it can be an example of the most +basic use of the module. + +## Usage + +This section is where you describe how to customize, configure, and do the +fancy stuff with your module here. It's especially helpful if you include usage +examples and code samples for doing things with your module. + +## Reference + +Here, include a complete list of your module's classes, types, providers, +facts, along with the parameters for each. Users refer to this section (thus +the name "Reference") to find specific details; most users don't read it per +se. + +## Limitations + +This is where you list OS compatibility, version compatibility, etc. If there +are Known Issues, you might want to include them under their own heading here. + +## Development + +Since your module is awesome, other users will want to play with it. Let them +know what the ground rules for contributing are. + +## Release Notes/Contributors/Etc. **Optional** + +If you aren't using changelog, put your release notes here (though you should +consider using changelog). You can also add any additional sections you feel +are necessary or important to include here. Please use the `## ` header. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a16ed29 --- /dev/null +++ b/Rakefile @@ -0,0 +1,17 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc "Validate manifests, templates, and ruby files" +task :validate do + Dir['manifests/**/*.pp'].each do |manifest| + sh "puppet parser validate --noop #{manifest}" + end + Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| + sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ + end + Dir['templates/**/*.erb'].each do |template| + sh "erb -P -x -T '-' #{template} | ruby -c" + end +end diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..0cbd1fb --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,14 @@ +class whats::config ( + $config_path = $::whats::config_path, + $puppetdb_server = $::whats::puppetdb_server, + $puppetdb_port = $::whats:::puppetdb_port, + $search_domains = $::whats::search_domains, + ) { + + file {$config_path: + content => template('whats/whats.yaml.erb'), + owner => root, + group => root, + mode => '0644', + } + } diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..b94fc69 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,14 @@ + +class whats ( + $version = $::whats::params::version, + $provider = $::whats::params::provider, + $config = $::whatts::params::config, + $puppetdb_server = $::whats::params::puppetdb_server, + $puppetdb_port = $::whats::params::puppetdb_port, + $search_domains = $::whats::params::search_domains, + ){ + + class {'::whats::install':} -> + class {'::whats::config':} + +} diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..2a1f0d7 --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,11 @@ +class whats::install ( + $version = $::whats::version, + $provider = $::whats::provider, + ) { + + package {'puppet-whats': + ensure => $version, + provider => $provider, + } + + } diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..28e656d --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,9 @@ +class whats::params { + String $version = 'latest' + String $provider = 'gem' + String $config = '/etc/whats.yaml' + String $puppetdb_server = 'puppetdb' + String $puppetdb_port = '8080' + Array $search_domains = ['local'] + + } diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..11fe4f9 --- /dev/null +++ b/metadata.json @@ -0,0 +1,15 @@ +{ + "name": "sjoeboo-whats", + "version": "0.1.0", + "author": "sjoeboo", + "summary": "Install puppet-whats gem and tempaltes a config file for you.", + "license": "Apache-2.0", + "source": "https://github.com/sjoeboo/puppet-whats.git", + "project_page": "https://github.com/sjoeboo/puppet-whats", + "issues_url": "https://github.com/sjoeboo/puppet-whats/issues", + "dependencies": [ + {"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"} + ], + "data_provider": null +} + diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..f978419 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' +describe 'whats' do + + context 'with defaults for all parameters' do + it { should contain_class('whats') } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/templates/whats.yaml.erb b/templates/whats.yaml.erb new file mode 100644 index 0000000..441800f --- /dev/null +++ b/templates/whats.yaml.erb @@ -0,0 +1,7 @@ +--- +puppetdb_host: '<%= @puppetdb_server %>'' +puppetdb_port: '<%= @puppetdb_port %>' +domains: +<% @search_domains.each do |dom| -%> + - '<%= @dom %> +<% end -%> diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000..0871906 --- /dev/null +++ b/tests/init.pp @@ -0,0 +1,12 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# http://docs.puppetlabs.com/guides/tests_smoke.html +# +include whats