ansible-legacy/roles/nutserver/tasks/main.yml

58 lines
1.1 KiB
YAML

---
- name: install packages
apt:
state: latest
pkg:
- nut
install_recommends: no
force_apt_get: yes
become: yes
- name: copy config files, scripts and services
copy:
src: "{{ item }}"
dest: "/{{ item }}"
force: yes
mode: preserve
become: yes
with_items:
- etc/zabbix/zabbix_agentd.conf.d/nut.conf
- name: configure nut
lineinfile:
path: /etc/nut/nut.conf
regexp: '^MODE='
line: 'MODE=standalone'
owner: root
group: root
mode: '0640'
become: yes
- name: configure ups in nut
blockinfile:
state: present
path: /etc/nut/ups.conf
backup: yes
marker: "# {mark}"
marker_begin: "BEGIN MANAGED BY PLANTROON"
marker_end: "END MANAGED BY PLANTROON"
insertafter: '^maxretry'
block: |
[cyberpower]
driver = usbhid-ups
port = auto
desc = "CP Sineware"
pollinterval = 5
become: yes
- name: enable services
systemd:
name: "{{ item }}"
state: restarted
enabled: yes
become: yes
with_items:
- zabbix-agent
- nut-driver