-
-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from codemeister64/apcupsd-role
Add Apcupsd role
- Loading branch information
Showing
10 changed files
with
487 additions
and
0 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
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 |
---|---|---|
|
@@ -57,6 +57,10 @@ | |
tags: | ||
- airsonic | ||
|
||
- role: apcupsd | ||
tags: | ||
- apcupsd | ||
|
||
- role: bazarr | ||
tags: | ||
- bazarr | ||
|
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,24 @@ | ||
--- | ||
apcupsd_enabled: false | ||
|
||
# directories | ||
apcupsd_data_directory: "{{ docker_home }}/apcupsd" | ||
|
||
# network | ||
apcupsd_port: "3551" | ||
|
||
# specs | ||
apcupsd_memory: 1g | ||
|
||
# docker | ||
apcupsd_container_name: apcupsd | ||
|
||
# ups config | ||
apcupsd_onbatterydelay: 6 | ||
apcupsd_batterylevel: 5 | ||
apcupsd_minutes: 5 | ||
apcupsd_timeout: 0 | ||
apcupsd_annoy: 300 | ||
apcupsd_annoydelay: 60 | ||
apcupsd_nologon: "disable" | ||
apcupsd_killdelay: 0 |
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,6 @@ | ||
--- | ||
provisioner: | ||
inventory: | ||
group_vars: | ||
all: | ||
apcupsd_enabled: true |
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,10 @@ | ||
--- | ||
- name: Stop | ||
hosts: all | ||
become: true | ||
tasks: | ||
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role" | ||
include_role: | ||
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" | ||
vars: | ||
apcupsd_enabled: false |
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,18 @@ | ||
--- | ||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- include_vars: | ||
file: ../../defaults/main.yml | ||
|
||
- name: Get container state | ||
docker_container_info: | ||
name: "{{ apcupsd_container_name }}" | ||
register: result | ||
|
||
- name: Check Apcupsd is running | ||
assert: | ||
that: | ||
- result.container['State']['Status'] == "running" | ||
- result.container['State']['Restarting'] == false |
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,18 @@ | ||
--- | ||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- include_vars: | ||
file: ../../defaults/main.yml | ||
|
||
- name: Try and stop and remove Apcupsd | ||
docker_container: | ||
name: "{{ apcupsd_container_name }}" | ||
state: absent | ||
register: result | ||
|
||
- name: Check Apcupsd is stopped | ||
assert: | ||
that: | ||
- not result.changed |
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,48 @@ | ||
--- | ||
|
||
- name: Start Apcupsd | ||
block: | ||
- name: Create Apcupsd Directories | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
with_items: | ||
- "{{ apcupsd_data_directory }}" | ||
|
||
- name: "Check if Apcupsd config exists" | ||
ansible.builtin.stat: | ||
path: "{{ apcupsd_data_directory }}/apcupsd.conf" | ||
register: apcupsd_config_path | ||
|
||
- name: Template Apcupsd config | ||
ansible.builtin.template: | ||
src: apcupsd.conf | ||
dest: "{{ apcupsd_data_directory }}/apcupsd.conf" | ||
when: not apcupsd_config_path.stat.exists | ||
|
||
- name: Apcupsd Docker Container | ||
community.docker.docker_container: | ||
name: "{{ apcupsd_container_name }}" | ||
image: gregewing/apcupsd | ||
pull: true | ||
privileged: true | ||
volumes: | ||
- "/var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket" | ||
- "{{ apcupsd_data_directory }}/apcupsd.conf:/etc/apcupsd/apcupsd.conf" | ||
ports: | ||
- "{{ apcupsd_port }}:3551" | ||
devices: | ||
- "{{ apcupsd_device }}:{{ apcupsd_device }}" | ||
env: | ||
TZ: "{{ ansible_nas_timezone }}" | ||
restart_policy: unless-stopped | ||
memory: "{{ apcupsd_memory }}" | ||
when: apcupsd_enabled is true | ||
|
||
- name: Stop Apcupsd | ||
block: | ||
- name: Stop Apcupsd | ||
community.docker.docker_container: | ||
name: "{{ apcupsd_container_name }}" | ||
state: absent | ||
when: apcupsd_enabled is false |
Oops, something went wrong.