Skip to content

Commit

Permalink
Initial commit of working puppet module
Browse files Browse the repository at this point in the history
Initial commit of puppet module with testing baked in.

It's delicious
  • Loading branch information
jake-minted committed Feb 3, 2015
0 parents commit e973c0e
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fixtures:
forge_modules:
stdlib:
repo: "puppetlabs/stdlib"
ref: "4.3.2"
wget:
repo: "maestrodev/wget"
ref: "1.5.5"
git:
repo: "puppetlabs/git"
ref: "0.3.0"
symlinks:
"hub": "#{source_dir}"
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pkg/
Gemfile.lock
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
.idea/
*.iml
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source "https://rubygems.org"

group :development, :unit_tests do
gem 'rake'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper'
gem 'puppet-lint'
gem 'simplecov'
gem 'puppet_facts'
gem 'json'
end

group :system_tests do
gem 'beaker-rspec'
gem 'serverspec'
end

gem 'facter'
gem 'puppet'
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2015 Jake Champlin (Minted.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Hub Puppet Module
=================

This puppet module installs the CLI Utility Hub.

Also by dependency resolution, installs wget and git both from the forge.

```
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.3.2"},
{"name":"maestrodev/wget","version_requirement":">= 1.5.5"},
{"name":"puppetlabs/git","version_requirement":">= 0.3.0"},
]
```

This module has puppetlabs-spec tests written and beaker acceptance tests written to fully cover the extent of the module.

To test:
```bash
bundle install
rake spec # For RSpec Unit Tests
rake spec_clean # To clean out fixtures directory
rspec spec/acceptance # To Launch, Test, and Destroy a new Vagrant VM w/ Beaker
```

(c) 2015 Minted.com
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'

PuppetLint.configuration.ignore_paths = [ "spec/**/*.pp", "pkg/**/*.pp"]
22 changes: 22 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2015 Minted Inc.
# All Rights Reserved

class hub( $version = '2.2.0-rc1' ) {

include wget
include git

file { '/usr/local/src/install_hub.sh':
content => template('hub/install_hub.sh.erb'),
mode => '0755',
owner => root,
group => root,
} ~>

exec { 'install_hub':
cwd => '/usr/local/src',
command => '/usr/local/src/install_hub.sh',
refreshonly => true,
}

}
29 changes: 29 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "minted-hub",
"version": "0.0.1",
"author": "Jake Champlin",
"summary": "Installs Hub from Github",
"license": "Apache-2.0",
"source": "https://github.com/minted/minted-hub",
"project_page": "https://github.com/minted/minted-hub",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"operatingsystem_support": [
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04"
]
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.3.2"},
{"name":"maestrodev/wget","version_requirement":">= 1.5.5"},
{"name":"puppetlabs/git","version_requirement":">= 0.3.0"},
]
}
18 changes: 18 additions & 0 deletions spec/acceptance/hub_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper_acceptance'

describe 'hub class' do

it 'should work with no errors' do
pp = <<-EOS
class { 'hub':
version => '2.2.0-rc1',
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'should be installed' do
shell('/usr/local/bin/hub --version')
end
end
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-server-12.04-amd64
box: ubuntu-server-12042-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor: vagrant
CONFIG:
type: foss
vagrant_ssh_port_random: true
17 changes: 17 additions & 0 deletions spec/classes/hub_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'hub', :type => :class do
# Wget is included
it { should contain_class('wget') }

# Git Class is included
it { should contain_class('git') }

# Install Hub Script
it { should contain_file('/usr/local/src/install_hub.sh').with({
'mode' => '0755',
'owner' => 'root',
'group' => 'root',
})}

end
7 changes: 7 additions & 0 deletions spec/spec.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--format
s
--colour
--loadby
mtime
--backtrace
--deprecation-out
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'
27 changes: 27 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'beaker-rspec'

# Install Puppet
foss_opts = { :default_action => 'gem_install' }

install_puppet( foss_opts )

hosts.each do |host|
on host, "mkdir -p #{host['distmoduledir']}"
end

RSpec.configure do |c|
# Root Project
project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

c.formatter = :documentation

c.before :suite do
hosts.each do |host|
copy_module_to(host, :source => project_root, :module_name => 'hub')
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
on host, puppet('module install puppetlabs-stdlib --version 4.3.2'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module install maestrodev-wget --version 1.5.5'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module install puppetlabs-git --version 0.3.0'), { :acceptable_exit_codes => [0,1] }
end
end
end
17 changes: 17 additions & 0 deletions templates/install_hub.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

version=<%= @version %>
architecture=<%= scope['::architecture'] %>

name=hub-linux-${architecture}-${version}
filename=${name}.tar.gz
url=https://github.com/github/hub/releases/download/v${version}/${filename}

dirname=hub_${version}_linux_${architecture}

cd /usr/local/src
wget --no-check-certificate $url
tar xzf $filename
cd $dirname
cp etc/hub.bash_completion.sh /etc/bash_completion.d/
cp hub /usr/local/bin/
1 change: 1 addition & 0 deletions tests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class { 'hub': }

0 comments on commit e973c0e

Please sign in to comment.