main
Ricard Illa 2023-01-25 10:53:02 +01:00
parent eb8b8b678e
commit 3053ddd02c
7 changed files with 122 additions and 0 deletions

View File

@ -8,6 +8,13 @@
- name: mount rw
command: /usr/local/bin/rw
- name: set-up eudev
hosts: suricata
become: true
roles:
- eudev
tags: eudev
- name: basic roles
hosts:
- caladan
@ -157,6 +164,14 @@
roles:
- wireguard
- name: set up NUT
hosts:
- suricata
become: true
roles:
- nut
tags: nut
- name: setup gopass
become: true
hosts:

View File

@ -172,6 +172,38 @@ all:
- "hdmi_group=2"
- "hdmi_mode=4"
nut_device:
name: nutdev1
config:
driver: "usbhid-ups"
port: "auto"
vendorid: "0764"
productid: "0601"
product: "OR1500ERM1U"
serial: "GBULZ2000030"
vendor: "CPS"
bus: "001"
nut_mode: netserver
nut_admin_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
396261663339336265643530373931633034326338386337363539663634663
438626465393132386134383935623061666134646130353138333561326665
330a62346364313562303633643663303430376664356461666166373232316
465653633323235653833303463366330376136356234633339396532643938
3634300a6165363061623264306339303366313365316636383631366262336
564313139303133343633353034613661633639633563356466363865643533
3937323163
nut_upsmon_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
313636333565356536333862386361393439666563353938343934623532366
433363738623862623035663138643532346330346339376437353563633365
320a33356464656230316565376339333331373832643631366562666331333
137386235666437663766313833616135303339643539353931313966623638
3962360a3131383461393435633363366437663535306430343631313935343
465343465343038383961306132653066643933646237313234326435663834
3865663534
caladan:
ansible_host: caladan
ansible_user: ansible

BIN
roles/nut/.DS_Store vendored Normal file

Binary file not shown.

26
roles/nut/tasks/main.yml Normal file
View File

@ -0,0 +1,26 @@
---
- name: install NUT for alpine
apk:
name:
- nut
when: ansible_distribution == "Alpine"
- name: set NUT mode
lineinfile:
path: /etc/nut/nut.conf
regexp: '^MODE='
line: "MODE={{ nut_mode }}"
- name: set up /etc/nut/upsmon.conf
blockinfile:
path: /etc/nut/upsmon.conf
block: |
MONITOR {{ nut_device.name }} 1 {{ nut_upsmon_password }} {{ nut_types[nut_mode] }}
- name: set up upsd
include_tasks: upsd.yml
when: nut_mode in ["standalone", "netserver"]
- name: set up upsmon
include_tasks: upsmon.yml

30
roles/nut/tasks/upsd.yml Normal file
View File

@ -0,0 +1,30 @@
---
- name: add UPS device(s) config to /etc/nut/ups.conf
blockinfile:
path: /etc/nut/ups.conf
block: |
[{{ nut_device.name }}]
{% for key, value in nut_device.config.items() %} {{ key }} = "{{ value }}"
{% endfor %}
- name: set up NUT user(s) to /etc/nut/upsd.users
blockinfile:
path: /etc/nut/upsd.users
block: |
[admin]
password = "{{ nut_admin_password }}"
actions = SET
instcmds = ALL
[upsmon]
password = "{{ nut_upsmon_password }}"
upsmon {{ nut_types[nut_mode] }}
- name: start and enable nut-upsd
service:
name: nut-upsd
runlevel: default
state: started
enabled: true
when: ansible_distribution == "Alpine"

View File

@ -0,0 +1,15 @@
---
- name: set up /etc/nut/upsmon.conf
blockinfile:
path: /etc/nut/upsmon.conf
block: |
MONITOR {{ nut_device.name }} 1 upsmon {{ nut_upsmon_password }} {{ nut_types[nut_mode] }}
- name: start and enable nut-upsmon
service:
name: nut-upsmon
runlevel: default
state: started
enabled: true
when: ansible_distribution == "Alpine"

4
roles/nut/vars/main.yml Normal file
View File

@ -0,0 +1,4 @@
nut_types:
standalone: primary
netserver: primary
clientserver: secondary