Yelp/puppet-uchiwa — pull request #21 by queeno (2014-11-12 00:38:45+00:00)
Title: Remove uchiwa::api and pass API data via class params

The puppet-uchiwa module doesn't produce a clean puppet run unless a user defines at least one uchiwa::api.

It would be ideal if the module could define default parameters over-writable by the user, for example by using hiera.

For these two reasons, I changed the module's current structure, replacing `uchiwa::api` with an array of hashes, passed to the `init.pp` class.

In other words, what the user could achieve by declaring...:

```puppet
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
}
```

...now they can achieve by passing an array of hashes to the uchiwa class declaration:

```puppet
class { 'uchiwa':
sensu_api_endpoints => [{
name => 'API 1',
host => '10.56.5.8'
},
{
name => 'API 2',
host => '10.16.1.25',
ssl => true,
port => 7654,
user => 'sensu',
pass => 'saBEnX8PQoyz2LG',
path => '/sensu',
timeout => 5000,
}],
}
```

Or data can be overwritten by hiera:

```yaml
uchiwa::sensu_api_endpoints:
- name: 'API 1'
host: '10.56.5.8'
- name: 'API 2'
host: '10.16.1.25'
ssl: true
port: 7654
user: 'sensu'
pass: 'saBEnX8PQoyz2LG'
path: '/sensu',
timeout: 5000
```

If `$sensu_api_endpoints` is not populated when including the class, then the default params defined in `params.pp` will be used:

```puppet
$sensu_api_endpoints = [{
name => 'sensu',
host => '127.0.0.1',
ssl => false,
insecure => false,
port => 4567,
user => 'sensu',
pass => 'sensu',
path => '',
timeout => 5000,
}]
```

If a hash lacks of some params, the defaults are used instead. For example, if we include the uchiwa class above defined in the puppet catalog, the `uchiwa.json` file will look like this:

```json
{
"sensu": [
{
"name": "API 1",
"host": "10.56.5.8",
"ssl": false,
"insecure": false,
"port": 4567,
"user": "sensu",
"pass": "sensu",
"path": "",
"timeout": 5000
},
{
"name": "API 2",
"host": "10.16.1.25",
"ssl": true,
"insecure": false,
"port": 7654,
"user": "sensu",
"pass": "saBEnX8PQoyz2LG",
"path": "/sensu",
"timeout": 5000
}
],
"uchiwa": {
"host": "localhost",
"port": 3000,
"user": "",
"pass": "",
"stats": 10,
"refresh": 10000
}
}
```

This PR introduces incompatible changes with previous versions of puppet-uchiwa. Unfortunately leaving both methods of passing the sensu API endpoint params turned out not to be a very trivial task.

Since we don't make use of it, I removed the `richardc/datacat` dependency from the module.

I have also added relevant beaker tests and updated the documentation.