1
0
IaC/ansible/roles/nut_server/tasks/main.yaml

73 lines
1.6 KiB
YAML
Raw Normal View History

2024-01-09 08:05:03 -05:00
- name: Template out ups.conf
ansible.builtin.template:
dest: /etc/nut/ups.conf
group: root
mode: '0644'
2024-01-11 00:15:16 -05:00
owner: root
src: ups.conf.j2
trim_blocks: true
notify:
- Restart nut-driver-enumerator
2024-01-09 08:05:03 -05:00
- name: Template out upsd.conf
ansible.builtin.template:
dest: /etc/nut/upsd.conf
group: nut
mode: '0640'
2024-01-11 00:15:16 -05:00
owner: root
src: upsd.conf.j2
trim_blocks: true
notify:
- Restart nut-server
2024-01-09 08:05:03 -05:00
- name: Template out upsd.users
ansible.builtin.template:
dest: /etc/nut/upsd.users
group: nut
mode: '0640'
2024-01-11 00:15:16 -05:00
owner: root
src: upsd.users.j2
trim_blocks: true
notify:
- Restart nut-server
2024-01-09 08:05:03 -05:00
2024-01-11 00:15:16 -05:00
- name: Open nut server firewall port (UFW)
2024-01-09 08:05:03 -05:00
community.general.ufw:
rule: allow
2024-01-11 00:15:16 -05:00
to_ip: "{{ nut_server_listen_address | string }}"
to_port: "{{ nut_server_listen_port | string }}"
2024-01-09 08:05:03 -05:00
proto: tcp
comment: "NUT server"
2024-01-11 00:15:16 -05:00
- name: Chown nut server cert to nut user
ansible.builtin.file:
group: nut
mode: '0600'
owner: nut
path: "{{ nut_server_certificate_file }}"
notify:
- Restart nut-server
- name: Start and enable nut-driver-enumerator
ansible.builtin.service:
name: nut-driver-enumerator.service
state: started
enabled: true
register: nut_driver_enumerator_started
2024-01-09 08:05:03 -05:00
- name: Start and enable nut-server
ansible.builtin.service:
2024-01-11 00:15:16 -05:00
name: nut-server.service
state: started
enabled: true
register: nut_server_started
- name: Start and enable nut targets
ansible.builtin.service:
name: "{{ item }}"
state: started
2024-01-09 08:05:03 -05:00
enabled: true
2024-01-11 00:15:16 -05:00
loop:
- nut-driver.target
- nut.target