diff --git a/README.md b/README.md index b407c03..c67facb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Ansible Role: NUT -================= +# Ansible Role: NUT + [![Build Status](https://github.com/salvoxia/ansible-role-nut/workflows/Release/badge.svg)](https://github.com/simoncaron/ansible-role-nut/actions?query=workflow%3Release) [![Ansible Galaxy Downloads](https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F39509%2F%3Fformat%3Djson)](https://galaxy.ansible.com/ui/standalone/roles/salvoxia/nut/) @@ -57,13 +57,62 @@ nut_users: ``` Explanation for all possible attributes: -| Attribute | Description | -| :------------------- | :------------ | -| `name` | Name for the NUT user
__Mandatory__ | -| `password` | The user's password
__Mandatory__ | -| `role` | Either the `user type` filed of the MONITOR directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html) and/or the `upsmon` directive in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html). Allowe vlaues are `primary` and `secondary`
__Mandatory__ | -| `actions` | Used to set allowed actions for the user in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html)
Only effective effect if `nut_mode` is either `netserver` or `standalone`
__Optional__ | -| `instcmds` | Used to set allowed instant commands for the user in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html)
Only effective effect if `nut_mode` is either `netserver` or `standalone`
__Optional__ | + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
+ +`name` + + +Name for the NUT user
__Mandatory__ +
+ +`password` + +The user's password
__Mandatory__ +
+ +`role` + + +Either the `user type` filed of the MONITOR directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html) and/or the `upsmon` directive in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html).
Allowed vlaues are `primary` and `secondary`
__Mandatory__ +
+ +`actions` + + +Used to set allowed actions for the user in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html)
Only effective effect if `nut_mode` is either `netserver` or `standalone`
__Optional__ +
+ +`instcmds` + + +Used to set allowed instant commands for the user in [`upsd.users`](https://networkupstools.org/docs/man/upsd.users.html)
Only effective effect if `nut_mode` is either `netserver` or `standalone`
__Optional__ +
### `nut_ups` @@ -100,38 +149,257 @@ nut_ups: maxretry = 10 retrydelay = 1 ``` -Explanation for all possible attributes -| Attribute | Description | -| :------------------- | :------------ | -| `name` | An arbitrary string that must identify univocally the UPS
__Mandatory__ | -| `monitoruser` | The NUT user to use for monitoring this UPS. Must reference an existing user defined in [`nut_users`](#nut_users).
__Mandatory__ | -| `driver` | Depends on your hardware and must be one of the [available NUT driver](http://networkupstools.org/stable-hcl.html). Be sure the NUT version installed on your server has that specific driver available
__Mandatory__ for `nut_mode` set to `netserver` or `standalone`| -| `device` | Port where the UPS is listening (typically an USB port or a serial device). It is translated to the `port` directive in [`ups.conf`](https://networkupstools.org/docs/man/ups.conf.html)
__Mandatory__ for `nut_mode` set to `netserver` or `standalone`| -| `description` | An arbitrary string used for debugging and reporting purposes
__Optional__ | -| `monitorhost` | The host that UPS can be monitored with. Is used as the host in the `MONITOR` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
__Optional__, default: `localhost` | -| `powervalue` | The number of power supplies that the UPS feeds on this system. Is used as `powervalue` in the `MONITOR` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
__Optional__, default: `1` | -| `extra` | Optional multiline text to be inserted verbatim in the global section of the relevant configuration file
__Optional__ | +Explanation for all possible attributes: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
+ +`name` + + +An arbitrary string that must identify univocally the UPS
__Mandatory__ +
+ +`monitoruser` + +The NUT user to use for monitoring this UPS. Must reference an existing user defined in [`nut_users`](#nut_users).
__Mandatory__ +
+ +`driver` + + +Depends on your hardware and must be one of the [available NUT driver](http://networkupstools.org/stable-hcl.html). Be sure the NUT version installed on your server has that specific driver available
__Mandatory__ for `nut_mode` set to `netserver` or `standalone` +
+ +`device` + + +Port where the UPS is listening (typically an USB port or a serial device). It is translated to the `port` directive in [`ups.conf`](https://networkupstools.org/docs/man/ups.conf.html)
__Mandatory__ for `nut_mode` set to `netserver` or `standalone` +
+ +`description` + + +An arbitrary string used for debugging and reporting purposes
__Optional__ +
+ +`monitorhost` + + +The host that UPS can be monitored with. Is used as the host in the `MONITOR` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
__Optional__, default: `localhost` +
+ +`powervalue` + + +The number of power supplies that the UPS feeds on this system. Is used as `powervalue` in the `MONITOR` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
__Optional__, default: `1` +
+ +`powervalue` + + +`extra` | Optional multiline text to be inserted verbatim in the global section of the relevant configuration file
__Optional__ +
### Misc Variables All these variables are optional: -| Variable | Description | -| :------------------- | :------------ | -| `nut_services` | List of service names to enable
Default: `nut-driver-enumerator`, `nut-monitor`, `nut-server` | -| `nut_enable_service` | Flag indicating whether to start the services defined in `nut_services` after configuration. Default: `true` | -| `nut_upssched_cmdscript_content` | Contents of a custom `upssched-cmd` script. | -| `nut_upssched_cmdscript` | Path on the Ansible host to a custom `upssched-cmd` script. Sets the `CMDSCRIPT` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
If `nut_upssched_cmdscript_content` is not empty, the contents of that variable will be stored under that path. | -| `nut_upssched_pipefn` | Sets the `PIPEFN` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Default: `/run/nut/upssched/upssched.pipe`| -| `nut_upssched_lockfn` | Sets the `LOCKFN` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Default: `/run/nut/upssched/upssched.lock`| -| `nut_upssched_at_commands` | Define `AT` directives for [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Refer to [defaults/main.yml](defaults/main.yml) for an example. | -| `nut_upsmon_notify` | Define custom `NOTIFYMSG` and `NOTIFYFLAG` directives for [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
Refer to [defaults/main.yml](defaults/main.yml) for an example. | -| `nut_upsmon_notifycmd` | Path to a custom notification script. Sets the `NOTIFYCMD` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html). | -| `nut_upsmon_notifycmd_content` | Contents of a custom upsmon notification script. | -| `nut_upsmon_notifycmd` | Path to a custom notification script. Sets the `NOTIFYCMD` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
If `nut_upsmon_notifycmd_content` is not empty, the contents of that variable will be stored under that path. | -| `nut_ups_extra` | Additional content to append to the `ups.conf` file | -| `nut_upsd_extra` | Additional content to append to the `upsd.conf` file | -| `nut_upsmon_extra` | Additional content to append to the `upsmon.conf` file | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDescription
+ +`nut_services` + + +List of service names to enable
Default: +```yaml +nut_services: + - nut-driver-enumerator + - nut-monitor + - nut-server +``` +
+ +`nut_enable_service` + + +Flag indicating whether to start the services defined in `nut_services` after configuration.
Default: `true` +
+ +`nut_upssched_cmdscript_content` + + +Contents of a custom `upssched-cmd` script. +
+ +`nut_upssched_cmdscript` + + +Path on the Ansible host to a custom `upssched-cmd` script. Sets the `CMDSCRIPT` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
If `nut_upssched_cmdscript_content` is not empty, the contents of that variable will be stored under this path. +
+ +`nut_upssched_pipefn` + + +Sets the `PIPEFN` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Default: `/run/nut/upssched/upssched.pipe` +
+ +`nut_upssched_lockfn` + + +Sets the `LOCKFN` directive in [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Default: `/run/nut/upssched/upssched.lock` +
+ +`nut_upssched_at_commands` + + +Define `AT` directives for [`upssched.conf`](https://networkupstools.org/docs/man/upssched.conf.html).
Example: +```yaml +nut_upssched_at_commands: + - notifytype: ONBATT + upsname: * + command: START-TIMER commbad 30 +``` +
+ +`nut_upsmon_notify` + + +Define custom `NOTIFYMSG` and `NOTIFYFLAG` directives for [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
Example: +```yaml +nut_upsmon_notify: + - name: ONLINE + msg: UPS %s on line power + flag: SYSLOG+WALL+EXEC + - name: ONBATT + msg: UPS %s on battery + flag: SYSLOG+WALL+EXEC +``` +
+ +`nut_upsmon_notifycmd_content` + + +Contents of a custom upsmon notification script. +
+ +`nut_upsmon_notifycmd` + + +Path to a custom notification script. Sets the `NOTIFYCMD` directive in [`upsmon.conf`](https://networkupstools.org/docs/man/upsmon.conf.html).
If `nut_upsmon_notifycmd_content` is not empty, the contents of that variable will be stored under that path. +
+ +`nut_ups_extra` + + +Additional content to append to the `ups.conf` file +
+ +`nut_upsd_extra` + + +Additional content to append to the `upsd.conf` file +
+ +`nut_upsmon_extra` + + +Additional content to append to the `upsmon.conf` file +
+ ## Example Playbook