Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ cache: pip
services:
- docker
env:
- ANSIBLE='ansible>=2.4.0'
- ANSIBLE='ansible~=2.7.0'
- ANSIBLE='ansible~=2.8.0'
- ANSIBLE='ansible~=2.9.0'
matrix:
fast_finish: true

Expand All @@ -14,12 +16,15 @@ install:
pip install
${ANSIBLE}
'ansible-lint>=3.4.15'
'molecule>=2.13.0'
${MOLECULE:-molecule>=2.15.0,<3.0.0}
docker
'testinfra>=1.7.0'

script:
- molecule test --all
- travis_wait 30 molecule test --all

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
webhooks:
urls: ['https://galaxy.ansible.com/api/v1/notifications/']
if: 'branch = master OR tag IS present'
on_failure: never
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

Items starting with `DEPRECATE` are important deprecation notices.

## 1.0.0 (2020-05-03)

First release
92 changes: 80 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ This roles configure the apcups daemon to monitor an UPS of APC brand.

## Requirements

Require Ansible >= 2.4
Require Ansible >= 2.5

### Dependencies

If you use the zabbix monitoring profile you will need the role [ansible-zabbix-agent](https://github.com/Turgon37/ansible-zabbix-agent)
* roles

| Name | Description |
| -------------------------------------------------------------------------------------- | -------------------------------------------- |
| [ansible-zabbix-agent](https://github.com/Turgon37/ansible-zabbix-agent) | If you use the zabbix monitoring profile |
| [ansible-prometheus-exporter](https://github.com/Turgon37/ansible-prometheus-exporter) | If you use the prometheus monitoring profile |

## OS Family

Expand All @@ -33,26 +38,79 @@ At this day the role can be used to :
* perform a minimal configuration (advanced one is planned)
* monitoring items for
* Zabbix
* Prometheus
* [local facts](#facts)

## Configuration

All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below. To see default values please refer to this file.

| Name | Types/Values | Description |
| ----------------------------- | -------------|------------------------------------------------------------------------------------------|
| `apcupsd__facts` | Boolean | Install the local fact script |
| `apcupsd__monitoring` | String | The name of the monitoring "profile" to use. Available 'zabbix' |
| `apcupsd__service_enabled` | Boolean | Enable or not the service |
| `apcupsd__net_server` | Boolean | Boolean to enable or not the nis server, it allow network client to query the UPS status |
| `apcupsd__net_server_address` | String | The network address on which the nis server will listen to |
| `apcupsd__net_server_port` | String | The network port on which the nis server will listen to |
| Name | Types/Values | Description |
| ---------------------------- | ------------ | ---------------------------------------------------------------------------- |
| `apcupsd__facts` | Boolean | Install the local fact script |
| `apcupsd__monitoring` | String/List | The name of the monitoring "profile" to use. Available 'zabbix','prometheus' |
| `apcupsd__service_enabled` | Boolean | Enable or not all instances' services |
| `apcupsd__instances` | Boolean | Dict of apcupsd instances (see below) |
| `apcupsd__instance_defaults` | Dict | Hash of default variables for all instance |

* Per instance variables

To declare an apcupsd instance, use the apcupsd__instances variable (refer to [exemple below](#example))

| Name | Types/Values | Description |
| -------------------- | --------------- | ---------------------------------------------------------------------------------------- |
| `net_server` | Boolean | Boolean to enable or not the nis server, it allow network client to query the UPS status |
| `net_server_address` | String | The network address on which the nis server will listen to |
| `net_server_port` | String | The network port on which the nis server will listen to |
| `upscable` | String | see apcupsd.conf doc |
| `upstype` | String | see apcupsd.conf doc |
| `device` | String | see apcupsd.conf doc |
| `polltime` | String | see apcupsd.conf doc |
| `upsclass` | String | see apcupsd.conf doc |
| `upsmode` | String | see apcupsd.conf doc |
| `eventsfilemax` | String | see apcupsd.conf doc |
| `scripts` | List of scripts | Define events handlers scripts(see below) |

* Scripts handlers

Each apcupsd instance supports multiple scripts handlers, using the `scripts` variable in instance configuration you can define spec like this

```
scripts:
- name: http_hook
event: all
content: |
[script content]
```

The `name` is free form but must be unique per event value.
Content is the script's raw `content`, this will be put in an executable file and will be called each time `event` is triggered.
`event` must be a single string with one of availables event

As an exemple, the following events exists
`killpower commfailure commok powerout onbattery offbattery mainsback failing timeout loadlimit runlimit doreboot doshutdown annoyme emergency changeme remotedown startselftest endselftest battdetach battattach`
In addition, a custom `all` event make its scripts to receive all event as `$1` argument (like apccontrol).

### Monitoring

You can enable one or more monitoring backend using `apcupsd__monitoring` variable.

#### Zabbix

#### Prometheus

| Name | Types/Values | Description |
| ----------------------------------- | ------------ | ----------------------------------------------------------------------------- |
| `apcupsd_exporter__version` | String | Which exporter version do you want |
| `apcupsd_exporter__web_listen_host` | String | Hostname on which prometheus exporter per instance will listen on |
| `apcupsd_exporter__web_listen_port` | Integer | Starting port number on which prometheus exporter per instance will listen on |
| `apcupsd_exporter__web_path` | String | Url prefix on which prometheus exporter will serve metrics |
| `apcupsd_exporter__network` | String | Network stack to use in prometheus exporter |

## Facts

By default the local fact are installed and expose the following variables :


* ```ansible_local.apcupsd.version_full```
* ```ansible_local.apcupsd.version_major```

Expand All @@ -71,5 +129,15 @@ Use it in a playbook as follows:
### Inventory

```
apcupsd__net_server_address: 127.0.0.1
apcupsd__instances:
ups01:
polltime: 10
scripts:
- name: http_hook
event: all
content: |
#!/bin/bash
curl --output - \
https://api.net/ \
--data-urlencode 'api=key'
```
Loading