forked from simoncaron/ansible-role-nut
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Service errors when installing client only from source
Showing
9 changed files
with
152 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
gather_facts: true | ||
pre_tasks: | ||
- name: Create NUT configuration folder. | ||
ansible.builtin.file: | ||
path: "/etc/nut" | ||
state: directory | ||
mode: '0755' | ||
- name: Copy dummy-ups.dev file | ||
ansible.builtin.copy: | ||
src: "../dummy-ups.dev" | ||
dest: "/etc/nut/dummy-ups.dev" | ||
mode: '0755' | ||
roles: | ||
- role: salvoxia.nut | ||
nut_install_from_source: true | ||
nut_source_tag: v2.8.2 | ||
nut_packages: | ||
- nut-client | ||
nut_users: | ||
- name: monitor | ||
password: changeme | ||
role: secondary | ||
nut_ups: | ||
- name: dummy_ups | ||
monitoruser: monitor | ||
driver: dummy-ups | ||
device: /etc/nut/dummy-ups.dev | ||
description: "Dummy UPS for testing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: debian-12 | ||
image: geerlingguy/docker-debian12-ansible | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
pre_build_image: true | ||
cgroupns_mode: host | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
- name: debian-11 | ||
image: geerlingguy/docker-debian11-ansible | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
pre_build_image: true | ||
cgroupns_mode: host | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
- name: ubuntu-2404 | ||
image: geerlingguy/docker-ubuntu2404-ansible | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
pre_build_image: true | ||
cgroupns_mode: host | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
- name: ubuntu-2204 | ||
image: geerlingguy/docker-ubuntu2404-ansible | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
pre_build_image: true | ||
cgroupns_mode: host | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
gather_facts: true | ||
tasks: | ||
- name: Get installed NUT version | ||
ansible.builtin.include_tasks: ../../tasks/get_installed_nut_version.yml | ||
|
||
- name: Verify installed version matches desired version | ||
ansible.builtin.assert: | ||
that: | ||
- nut_installed_version is defined | ||
- nut_installed_version == "v2.8.2" | ||
|
||
- name: Gather installed services | ||
ansible.builtin.service_facts: | ||
|
||
- name: Verify NUT services are running | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_facts.services['nut-monitor.service'] is defined | ||
- ansible_facts.services['nut-monitor.service'].state == 'running' | ||
- ansible_facts.services['nut-server.service'].state == 'stopped' | ||
- ansible_facts.services['nut-server.service'].status == 'masked' | ||
|
||
- name: Gather package facts | ||
ansible.builtin.package_facts: | ||
when: nut_installed_version is defined | ||
|
||
- name: Verify no NUT packages are installed | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_facts.packages['nut-client'] is not defined | ||
- ansible_facts.packages['nut-server'] is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Determine service unit file | ||
ansible.builtin.systemd_service: | ||
name: "{{ service_name }}" | ||
register: service_status | ||
|
||
- name: "Restart service." | ||
ansible.builtin.service: | ||
name: "{{ service_name }}" | ||
state: restarted | ||
when: service_status.status['LoadState'] != 'masked' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters