Skip to content

Commit

Permalink
Merge pull request #306 from sensu/redis_password
Browse files Browse the repository at this point in the history
Added Redis password support
  • Loading branch information
jlambert121 committed Feb 2, 2015
2 parents 1a76727 + 9ece56f commit fc7baf6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Installs and manages the open source monitoring framework [Sensu](http://sensuap

## Sensu version supported

The module currently supports Sensu version 0.12 and later. If not explictly stated it should always
support the latest Sensu release. Please log an issue if you identify any incompatibilties.
The module currently supports Sensu version 0.12 and later. If not explicitly stated it should always
support the latest Sensu release. Please log an issue if you identify any incompatibilities.

## Upgrade note

Expand Down Expand Up @@ -54,36 +54,37 @@ Debian & Ubuntu:

## Quick start

Before this puppet module can be used, the following items must be configured on the server.
Before this Puppet module can be used, the following items must be configured on the server.

- Install redis
- Install rabbitmq
- Add users to rabbitmq
- Install Redis
- Install RabbitMQ
- Add users to RabbitMQ
- Install dashboard (optional)

To quickly try out sensu, spin up a test VM with Vagrant that already has these prerequisites installed.
To quickly try out Sensu, spin up a test virtual machine with Vagrant that already has these prerequisites installed.

vagrant up
vagrant status
vagrant ssh sensu-server
$ vagrant up
$ vagrant status
$ vagrant ssh sensu-server

You can then access the api

curl http://admin:secret@localhost:4567/info
You can then access the API.

$ curl http://admin:secret@localhost:4567/info

Navigate to `192.168.56.10:3000` to use the uchiwa dashboard

username => uchiwa
password => uchiwa

Navigate to `192.168.56.10:15672` to manage rabbitmq
Navigate to `192.168.56.10:15672` to manage RabbitMQ

username => sensu
password => correct-horse-battery-staple

See the [tests directory](https://github.com/sensu/sensu-puppet/tree/vagrant/tests) and [Vagrantfile](https://github.com/sensu/sensu-puppet/blob/vagrant/Vagrantfile) for examples on setting up the prerequisites.

See the [tests
directory](https://github.com/sensu/sensu-puppet/tree/vagrant/tests) and
[Vagrantfile](https://github.com/sensu/sensu-puppet/blob/vagrant/Vagrantfile)
for examples on setting up the prerequisites.

## Basic example

Expand Down Expand Up @@ -382,8 +383,8 @@ apache/manifests/service.pp

## Installing Gems into the embedded ruby

If you are using the embedded ruby that ships with sensu, you can install gems
by using the `sensu_gem` package provier:
If you are using the embedded ruby that ships with Sensu, you can install gems
by using the `sensu_gem` package provider:

package { 'redphone':
ensure => 'installed',
Expand Down
13 changes: 11 additions & 2 deletions lib/puppet/provider/sensu_redis_config/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def flush

def create
conf['redis'] = {}
self.port = resource[:port]
self.host = resource[:host]
self.port = resource[:port]
self.host = resource[:host]
self.password = resource[:password]
end

def config_file
Expand Down Expand Up @@ -51,4 +52,12 @@ def host
def host=(value)
conf['redis']['host'] = value
end

def password
conf['redis']['password']
end

def password=(value)
conf['redis']['password'] = value
end
end
4 changes: 4 additions & 0 deletions lib/puppet/type/sensu_redis_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def initialize(*args)
defaultto 'localhost'
end

newproperty(:password) do
desc "The password used to connect to Redis"
end

autorequire(:package) do
['sensu']
end
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
# Integer. Redis port to be used by sensu
# Default: 6379
#
# [*redis_password*]
# String. Password to be used to connect to Redis
# Default: ''
#
# [*api_bind*]
# String. IP to bind api service
# Default: 0.0.0.0
Expand Down Expand Up @@ -219,6 +223,7 @@
$rabbitmq_ssl_cert_chain = undef,
$redis_host = 'localhost',
$redis_port = 6379,
$redis_password = '',
$api_bind = '0.0.0.0',
$api_host = 'localhost',
$api_port = 4567,
Expand Down
7 changes: 4 additions & 3 deletions manifests/redis/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
}

sensu_redis_config { $::fqdn:
ensure => $ensure,
host => $sensu::redis_host,
port => $sensu::redis_port,
ensure => $ensure,
host => $sensu::redis_host,
port => $sensu::redis_port,
password => $sensu::redis_password,
}

}
10 changes: 6 additions & 4 deletions spec/classes/sensu_redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

context 'be configurable' do
let(:params) { {
:redis_host => 'redis.domain.com',
:redis_port => 1234
:redis_host => 'redis.domain.com',
:redis_port => 1234,
:redis_password => 'password'
} }

it { should contain_sensu_redis_config('testhost.domain.com').with(
:host => 'redis.domain.com',
:port => 1234
:host => 'redis.domain.com',
:port => 1234,
:password => 'password'
)}
end # be configurable

Expand Down

0 comments on commit fc7baf6

Please sign in to comment.