Skip to content

Commit

Permalink
Merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloconnor committed Aug 7, 2014
1 parent a5325c9 commit 7330a31
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fixtures:
repositories:
apt: git://github.com/puppetlabs/puppetlabs-apt.git
concat: git://github.com/puppetlabs/puppetlabs-concat.git
datacat: git://github.com/richardc/puppet-datacat.git
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
uchiwa: "#{source_dir}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.*.sw?
pkg
!spec/fixtures/uchiwa
spec/fixtures
.rspec_system
.vagrant
4 changes: 2 additions & 2 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'pauloconnor-uchiwa'
version '0.1.0'
version '0.2.0'
source 'github.com/pauloconnor/pauloconnor-uchiwa'
author 'pauloconnor'
license 'Apache 2.0'
Expand All @@ -8,5 +8,5 @@ description 'Puppet module for installing Uchiwa'
project_page 'https://github.com/pauloconnor/pauloconnor-uchiwa'

dependency 'puppetlabs/apt'
dependency 'puppetlabs/concat'
dependency 'puppetlabs/stdlib'
dependency 'richardc/datacat'
58 changes: 33 additions & 25 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Tested with Travis CI

[![Build Status](https://travis-ci.org/pauloconnor/pauloconnor-uchiwa.png)](https://travis-ci.org/pauloconnor/pauloconnor-uchiwa)

## Upgrade Note

Versions greater than 0.2.0 are incompatible with previous versions of the Sensu-Puppet module.

## Installation

$ puppet module install pauloconnor-uchiwa
Expand All @@ -14,6 +18,7 @@ Tested with Travis CI
### Dependencies
- puppetlabs/apt
- puppetlabs/stdlib
- richardc/datacat

See `Modulefile` for details.

Expand All @@ -28,32 +33,35 @@ See `Modulefile` for details.

## Advanced example using multiple APIs

API definitions will default to the following values:

name => Definition Name
host => ''
ssl => false
port => 4567
user => 'sensu'
pass => 'sensu'
path => ''
timeout => 5000

This is an example of a 2 API setup:

node 'uchiwa-server.foo.com' {
class { 'uchiwa':
apis => {
'API 1' =>
{
name => 'API 1',
host => '10.56.5.8',
ssl => false,
port => 4567,
user => 'sensu',
pass => 'sensu',
path => '',
timeout => 5000
},
'API 2' =>
{
name => 'API 2',
host => '10.16.1.25',
ssl => false,
port => 4567,
user => 'sensu',
pass => 'sensu',
path => '',
timeout => 5000
}
}
class { 'uchiwa': }

uchiwa::api { ' API 1':
host => '10.56.5.8',
}

uchiwa::api { 'API 2':
host => '10.16.1.25',
ssl => true,
port => 7654,
user => 'sensu',
pass => 'saBEnX8PQoyz2LG',
path => '/sensu',
timeout => 5000
}
}

## License
Expand Down
56 changes: 56 additions & 0 deletions manifests/api.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# uchiwa::api
# Used for defining APIS
# uchiwa::api { ' API 1':
# host => '10.56.5.8',
# }
#
# uchiwa::api { 'API 2':
# host => '10.16.1.25',
# ssl => true,
# port => 7654,
# user => 'sensu',
# pass => 'saBEnX8PQoyz2LG',
# path => '/sensu',
# timeout => 5000
#}
define uchiwa::api(
$host,
$ssl = false,
$port = 4567,
$user = 'sensu',
$pass = 'sensu',
$path = '',
$timeout = 5000
) {

validate_re($name, '^[a-zA-Z0-9_ ]*$')
validate_re($host, '^[a-zA-Z0-9_.]*$')
validate_bool($ssl)
validate_re($port, '^[0-9]*$')
validate_re($user, '^[a-zA-Z0-9_]*$')
validate_re($path, '^[a-zA-Z0-9_/]*$')
validate_re($timeout, '^[0-9]*$')

datacat_fragment { "uchiwa-api-${name}":
target => '/etc/sensu/uchiwa.json',
data => {
api => [" {
\"name\": \"${title}\",
\"host\": \"${host}\",
\"port\": ${port},
\"ssl\": ${ssl},
\"user\": \"${user}\",
\"pass\": \"${pass}\",
\"path\": \"${path}\",
\"timeout\": ${timeout}
}"],
host => $uchiwa::host,
port => $uchiwa::port,
user => $uchiwa::user,
pass => $uchiwa::pass,
stats => $uchiwa::stats,
refresh => $uchiwa::refresh
},
}

}
9 changes: 2 additions & 7 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
#
class uchiwa::config {

file { '/etc/sensu/uchiwa.json':
ensure => 'present',
owner => 'root',
group => 'root',
mode => '0655',
content => template('uchiwa/etc/sensu/uchiwa.json.erb'),
datacat { '/etc/sensu/uchiwa.json':
template => 'uchiwa/etc/sensu/uchiwa.json.erb',
}

}
20 changes: 2 additions & 18 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#
# [*repo_source*]
# String
# Default:
# Default: undef
# What's the url for the repo we should install?
#
# [*repo_key_id*]
Expand Down Expand Up @@ -87,20 +87,6 @@
# Default: 10000
# Determines the interval to pull the Sensu API, in milliseconds
#
# [*apis*]
# Hash
# Default: { 'API 1' =>
# {
# host => '127.0.0.1',
# ssl => false,
# port => 4567,
# user => '',
# pass => '',
# path => '',
# timeout => 5000
# }
# }
# A Ruby Hash of APIs that the dashboard should connect to.
#
class uchiwa (
$package_name = $uchiwa::params::package_name,
Expand All @@ -118,8 +104,7 @@
$user = $uchiwa::params::user,
$pass = $uchiwa::params::pass,
$stats = $uchiwa::params::stats,
$refresh = $uchiwa::params::refresh,
$apis = $uchiwa::params::apis
$refresh = $uchiwa::params::refresh
) inherits uchiwa::params {

# validate parameters here
Expand All @@ -139,7 +124,6 @@
validate_string($pass)
validate_string($stats)
validate_string($refresh)
validate_hash($apis)

class { 'uchiwa::install': } ->
class { 'uchiwa::config': } ~>
Expand Down
12 changes: 0 additions & 12 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,4 @@
$stats = 10
$refresh = 10000


$apis = { 'API 1' =>
{
host => '127.0.0.1',
ssl => false,
port => 4567,
user => '',
pass => '',
path => '',
timeout => 5000
}
}
}
4 changes: 2 additions & 2 deletions manifests/repo/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
enabled => 1,
baseurl => $url,
gpgcheck => 0,
name => 'uchiwa',
descr => 'uchiwa',
name => 'sensu',
descr => 'sensuapp.org uchiwa repo',
before => Package['uchiwa'],
}
}
Expand Down
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
],
"name": "pauloconnor-uchiwa",
"version": "0.1.0",
"version": "0.2.0",
"author": "pauloconnor",
"summary": "Puppet module for installing Uchiwa",
"license": "Apache 2.0",
Expand All @@ -65,7 +65,8 @@
"issues_url": "https://github.com/pauloconnor/pauloconnor-uchiwa/issues",
"description": "Puppet module for installing Uchiwa",
"dependencies": [
{"name":"puppetlabs/apt"},
{"name":"puppetlabs/stdlib"},
{"name":"puppetlabs/apt"}
{"name":"richardc/datacat"}
]
}
2 changes: 1 addition & 1 deletion spec/classes/uchiwa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
context 'defaults' do
it { should create_class('uchiwa::repo::yum') }
it { should contain_package('uchiwa').with_ensure('latest') }
it { should contain_file('/etc/sensu/uchiwa.json').with_ensure('present') }
it { should contain_file('/etc/sensu/uchiwa.json') }
end

context 'setting version' do
Expand Down
32 changes: 13 additions & 19 deletions templates/etc/sensu/uchiwa.json.erb
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
{
"sensu": [
<% scope.lookupvar('uchiwa::apis').each_with_index do |(name,api),index| -%>
{
"name": "<%= name %>",
"host": "<%= api['host'] %>",
"port": <%= api['port'] || 4567 %>,
"ssl": <%= api['ssl'] || false %>,
"user": "<%= api['user'] %>",
"pass": "<%= api['pass'] %>",
"path": "<%= api['path'] %>",
"timeout": <%= api['timeout'] || 5000 %>
}<%= ',' if index < scope.lookupvar('uchiwa::apis').length - 1 %>
<% end -%>
],
<%-
apis = Array.new
@data['api'].each do |a|
apis << a
end %>
<%= apis.join(",\n") %>
],
"uchiwa": {
"host": "<%= scope.lookupvar('uchiwa::host') %>",
"port": <%= scope.lookupvar('uchiwa::port') %>,
"user": "<%= scope.lookupvar('uchiwa::user') %>",
"pass": "<%= scope.lookupvar('uchiwa::pass') %>",
"stats": <%= scope.lookupvar('uchiwa::stats') %>,
"refresh": <%= scope.lookupvar('uchiwa::refresh') %>
"host": "<%= @data['host'] %>",
"port": <%= @data['port'] %>,
"user": "<%= @data['user'] %>",
"pass": "<%= @data['pass'] %>",
"stats": <%= @data['stats'] %>,
"refresh": <%= @data['refresh'] %>
}
}

0 comments on commit 7330a31

Please sign in to comment.