Commit b417ba3c authored by liamjbennett's avatar liamjbennett

initial commit

parents
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
kafka: "#{source_dir}"
.*.sw?
pkg
spec/fixtures
.rspec_system
.vagrant
*.iml
.idea/
--format documentation
--color
---
language: ruby
bundler_args: --without development
before_install: rm Gemfile.lock || true
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
script: bundle exec rake test
env:
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.2.0"
- PUPPET_VERSION="~> 3.3.0"
- PUPPET_VERSION="~> 3.4.0"
matrix:
exclude:
- rvm: 2.0.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"
YYYY-MM-DD Release 0.1.0
- something you did
- something else you did
This module has grown over time based on a range of contributions from
people using it. If you follow these contributing guidelines your patch
will likely make it into a release a little quicker.
## Contributing
1. Fork the repo.
2. Run the tests. We only take pull requests with passing tests, and
it's great to know that you have a clean slate
3. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
or fixing a bug, please add a test.
4. Make the test pass.
5. Push to your fork and submit a pull request.
## Dependencies
The testing and development tools have a bunch of dependencies,
all managed by [bundler](http://bundler.io/) according to the
[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
By default the tests use a baseline version of Puppet.
If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:
export PUPPET_VERSION="~> 3.2.0"
Install the dependencies like so...
bundle install
## Syntax and style
The test suite will run [Puppet Lint](http://puppet-lint.com/) and
[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
check various syntax and style things. You can run these locally with:
bundle exec rake lint
bundle exec rake syntax
## Running the unit tests
The unit test suite covers most of the code, as mentioned above please
add tests if you're adding new functionality. If you've not used
[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
about how best to test your new feature. Running the test suite is done
with:
bundle exec rake spec
Note also you can run the syntax, style and unit tests in one go with:
bundle exec rake test
## Integration tests
The unit tests just check the code runs, not that it does exactly what
we want on a real machine. For that we're using
[beaker](https://github.com/puppetlabs/beaker).
This fires up a new virtual machine (using vagrant) and runs a series of
simple tests against it after applying the module. You can run this
with:
bundle exec rake acceptance
This will run the tests on an Ubuntu 12.04 virtual machine. You can also
run the integration tests against Centos 6.5 with.
RS_SET=centos-64-x64 bundle exec rake acceptances
If you don't want to have to recreate the virtual machine every time you
can use `RS_DESTROY=no` and `RS_PROVISION=no`. On the first run you will
at least need `RS_PROVISION` set to yes (the default). The Vagrantfile
for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`.
source "http://rubygems.org"
group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem "puppet-lint"
gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git'
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
end
group :development do
gem "travis"
gem "travis-lint"
gem "beaker"
gem "beaker-rspec"
gem "vagrant-wrapper"
gem "puppet-blacksmith"
gem "guard-rake"
end
GIT
remote: https://github.com/rodjek/rspec-puppet.git
revision: 389f99ef666521fec1b4530fe69dc1ab84a060a8
specs:
rspec-puppet (1.0.1)
rspec
GEM
remote: http://rubygems.org/
specs:
CFPropertyList (2.2.8)
addressable (2.3.6)
archive-tar-minitar (0.5.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.40.3)
json (~> 1.4)
nokogiri (>= 1.4.4)
backports (3.6.0)
beaker (1.12.0)
aws-sdk (~> 1.38)
blimpy (~> 0.6)
docker-api
fission (~> 0.4)
google-api-client (~> 0.7.1)
inifile (~> 2.0)
json (~> 1.8)
mime-types (~> 1.25)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (= 1.5.10)
rbvmomi (= 1.8.1)
unf (~> 0.1)
beaker-rspec (2.2.4)
beaker (~> 1.10)
rspec (~> 2.14)
serverspec (~> 1.0)
specinfra (~> 1.0)
blimpy (0.6.7)
fog
minitar
thor
builder (3.2.2)
celluloid (0.15.2)
timers (~> 1.1.0)
coderay (1.1.0)
diff-lcs (1.2.5)
docker-api (1.10.11)
archive-tar-minitar
excon (>= 0.28)
json
ethon (0.7.0)
ffi (>= 1.3.0)
excon (0.33.0)
extlib (0.9.16)
facter (1.7.5)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.3)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.11.1)
builder
excon (~> 0.20)
formatador (~> 0.2.0)
json (~> 1.7)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0)
ruby-hmac
formatador (0.2.4)
gh (0.13.2)
addressable
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
google-api-client (0.7.1)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (>= 0.9.0)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
retriable (>= 1.4)
signet (>= 0.5.0)
uuidtools (>= 2.1.0)
guard (2.6.1)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-rake (0.0.9)
guard
rake
hashr (0.0.22)
hiera (1.3.2)
json_pure
highline (1.6.21)
inifile (2.0.2)
json (1.8.1)
json_pure (1.8.1)
jwt (1.0.0)
launchy (2.4.2)
addressable (~> 2.3)
listen (2.7.5)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.5)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.5.10)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puppet (3.4.3)
facter (~> 1.6)
hiera (~> 1.0)
rgen (~> 0.6.5)
puppet-blacksmith (2.0.2)
nokogiri
puppet (>= 2.7.16)
rest-client
puppet-lint (0.3.2)
puppet-syntax (1.2.0)
puppet (>= 2.7.0)
rake
puppetlabs_spec_helper (0.4.1)
mocha (>= 0.10.5)
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
pusher-client (0.6.0)
json
websocket (~> 1.0)
rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.4)
ffi (>= 0.5.0)
rbvmomi (1.8.1)
builder
nokogiri (>= 1.4.1)
trollop
rest-client (1.6.7)
mime-types (>= 1.16)
retriable (1.4.1)
rgen (0.6.6)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
ruby-hmac (0.4.0)
safe_yaml (0.9.7)
serverspec (1.7.0)
highline
net-ssh
rspec (~> 2.13)
specinfra (~> 1.13)
signet (0.5.0)
addressable (>= 2.2.3)
faraday (>= 0.9.0.rc5)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
slop (3.5.0)
specinfra (1.13.0)
thor (0.19.1)
timers (1.1.0)
travis (1.6.11)
addressable (~> 2.3)
backports
faraday (~> 0.9)
faraday_middleware (~> 0.9)
gh (~> 0.13)
highline (~> 1.6)
launchy (~> 2.1)
pry (~> 0.9)
pusher-client (~> 0.4)
typhoeus (~> 0.6, >= 0.6.8)
travis-lint (1.8.0)
hashr (~> 0.0.22)
safe_yaml (~> 0.9.0)
trollop (2.0)
typhoeus (0.6.8)
ethon (>= 0.7.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
uuidtools (2.1.4)
vagrant-wrapper (1.2.1.1)
websocket (1.1.4)
PLATFORMS
ruby
DEPENDENCIES
beaker
beaker-rspec
guard-rake
puppet (~> 3.4.0)
puppet-blacksmith
puppet-lint
puppet-syntax
puppetlabs_spec_helper
rake
rspec-puppet!
travis
travis-lint
vagrant-wrapper
notification :off
guard 'rake', :task => 'test' do
watch(%r{^manifests\/(.+)\.pp$})
end
This diff is collapsed.
name 'puppet-kafka'
version '0.1.0'
source 'UNKNOWN'
author 'puppet'
license 'Apache License, Version 2.0'
summary 'UNKNOWN'
description 'UNKNOWN'
project_page 'UNKNOWN'
dependency 'puppetlabs/stdlib'
####Table of Contents
1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with kafka](#setup)
* [What kafka affects](#what-kafka-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with kafka](#beginning-with-kafka)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
##Overview
A one-maybe-two sentence summary of what the module does/what problem it solves. This is your 30 second elevator pitch for your module. Consider including OS/Puppet version it works with.
##Module Description
If applicable, this section should have a brief description of the technology the module integrates with and what that integration enables. This section 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 kafka affects
* A list of files, packages, services, or operations that the module will alter, impact, or execute on the system it's installed on.
* This is a great place to stick any warnings.
* Can be in list or paragraph form.
###Setup Requirements **OPTIONAL**
If your module requires anything extra before setting up (pluginsync enabled, etc.), mention it here.
###Beginning with kafka
The very basic steps needed for a user to get the module up and running.
If your most recent release breaks compatibility or requires particular steps for upgrading, you may wish to include an additional section here: Upgrading (For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
##Usage
Put the classes, types, and resources for customizing, configuring, and doing the fancy stuff with your module here.
##Reference
Here, list the classes, types, providers, facts, etc contained in your module. This section should include all of the under-the-hood workings of your module so people know what the module is touching on their system but don't need to mess with things. (We are working on automating this section!)
##Limitations
This is where you list OS compatibility, version compatibility, etc.
##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 may also add any additional sections you feel are necessary or important to include here. Please use the `## ` header.
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
# These two gems aren't always present, for instance
# on Travis with --without development
begin
require 'puppet_blacksmith/rake_tasks'
rescue LoadError
end
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
PuppetLint.configuration.fail_on_warnings = true
# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
# http://puppet-lint.com/checks/class_parameter_defaults/
PuppetLint.configuration.send('disable_class_parameter_defaults')
# http://puppet-lint.com/checks/class_inherits_from_params_class/
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
desc "Run syntax, lint, and spec tests."
task :test => [
:syntax,
:lint,
:spec,
]
# == Class kafka::config
#
# This class is called from kafka
#
class kafka::config {
$install_dir = "/usr/local/kafka-${kafka::version}-${kafka::scala_version}"
$conf_file = "${install_dir}/config/server.properties"
file { $conf_file:
owner => 'kafka',
group => 'kafka',
mode => '0644',
alias => 'kafka-cfg',
require => File['kafka-app-dir'],
content => template('kafka/server.properties.erb'),
}
#file { '/etc/init/kafka.conf':
# content => template('kafka/init/kafka.conf.erb'),
# mode => '0644',
# alias => 'kafka-init',
# require => File[$conf_file],
#}
}
# == Class: kafka
#
# Full description of class kafka here.
#
# === Parameters
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
#
class kafka (
$broker_id = $kafka::params::broker_id,
$hostname = $kafka::params::hostname,
$zookeeper_connect = $kafka::params::zookeeper_connect,
$mirror_url = $kafka::params::mirror_url,
$install_dir = $kafka::params::install_dir,
$version = $kafka::params::version,
$scala_version = $kafka::params::scala_version
) inherits kafka::params {
# validate parameters here
class { 'kafka::install': } ->
class { 'kafka::config': } ~>
class { 'kafka::service': } ->
Class['kafka']
}
# == Class kafka::install
#
class kafka::install {
$basefilename = "kafka_${kafka::scala_version}-${kafka::version}.tgz"
$basename = regsubst($basefilename, '(.+)\.tgz$', '\1')
$package_url = "${kafka::mirror_url}/kafka/${kafka::version}/${basefilename}"
$install_dir = "/usr/local/kafka-${kafka::version}-${kafka::scala_version}"
group { 'kafka':
ensure => present
}
user { 'kafka':
ensure => present,
shell => '/bin/bash',
require => Group['kafka']
}
file { $kafka::package_dir:
ensure => 'directory',
owner => 'kafka',
group => 'kafka'
}
file { "${install_dir}/${kafka::basename}":
ensure => directory,
owner => 'kafka',
group => 'kafka',
alias => 'kafka-app-dir'
}
ensure_resource('package','wget', {'ensure' => 'installed'})
exec { 'download-kafka-package':
command => "wget -O ${kafka::package_dir}/${basefilename} ${package_url} 2> /dev/null",
path => ['/usr/bin', '/bin'],
creates => "${kafka::package_dir}/${basefilename}",
require => [ File[$kafka::package_dir], Package['wget'] ]
}
exec { "untar ${basefilename}":
command => "tar xfvz ${kafka::package_dir}/${basefilename} -C ${install_dir} --strip-components=1",
creates => "${install_dir}/${basename}/config",
alias => 'untar-kafka',
require => [ Exec['download-kafka-package'], File['kafka-app-dir'] ],
user => 'kafka',
path => ['/bin', '/usr/bin', '/usr/sbin']
}
file { '/usr/local/kafka':
ensure => link,
target => $install_dir
}
}
# == Class kafka::params
#
# This class is meant to be called from kafka
# It sets variables according to platform
#
class kafka::params {
$datastore = '/var/kafka'
$package_dir = '/var/lib/kafka'
$mirror_url = 'http://mirrors.ukfast.co.uk/sites/ftp.apache.org'
$version = '0.8.1.1'
$scala_version = '2.8.0'
#http://kafka.apache.org/documentation.html#configuration
$broker_id = '0'
$port = '9092'
$host_name = $::fqdn
$advertised_host_name = $::fqdn
$advertised_port = '9092'
$num_network_threads = '2'
$num_io_threads = '8'
$socket_send_buffer_bytes = '1048576'
$socket_receive_buffer_bytes = '1048576'
$socket_request_max_bytes = '104857600'
$log_dirs = '/tmp/kafka-logs'
$num_partitions = '2'
$log_flush_interval_messages = '10000'
$log_flush_interval_ms = '1000'
$log_retention_hours = '168'
$log_retention_bytes = '1073741824'
$log_segment_bytes = '536870912'
$log_retention_check_interval_ms = '60000'
$log_cleaner_enable = false
$zookeeper_connect = 'localhost:2181'
$zookeeper_connect_timeout_ms = '1000000'
}
# == Class kafka::service
#
# This class is meant to be called from kafka
# It ensure the service is running
#
class kafka::service {
#service { 'kafka':
# ensure => running,
# provider => 'upstart',
# require => File['kafka-init'],
#}
}
require 'spec_helper_acceptance'
describe 'kafka class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'kafka': }
EOS
# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
describe package('kafka') do
it { should be_installed }
end
describe service('kafka') do
it { should be_enabled }
it { should be_running }
end
end
end
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
log_level: verbose
type: foss
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-server-12.04-amd64