Skip to content

Commit

Permalink
Use a common service role for other service roles
Browse files Browse the repository at this point in the history
  • Loading branch information
claha committed Sep 23, 2023
1 parent e15bcd9 commit a5e384b
Show file tree
Hide file tree
Showing 69 changed files with 652 additions and 686 deletions.
2 changes: 0 additions & 2 deletions roles/autorestic/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
---
service_name: "{{ ansible_role_name }}"
service_path: "{{ services_path }}/{{ service_name }}"
autorestic_docker: true
6 changes: 6 additions & 0 deletions roles/autorestic/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "autorestic"

- name: Create directories
ansible.builtin.file:
path: "{{ service_path }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/dashdot/defaults/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/dashdot/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "dashdot"

- name: Create directories
ansible.builtin.file:
path: "{{ service_path }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/diun/defaults/main.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/diun/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/diun/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "diun"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/doku/defaults/main.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/doku/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/doku/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "doku"

- name: Create directories
ansible.builtin.file:
path: "{{ service_path }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/dozzle/defaults/main.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/dozzle/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/dozzle/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "dozzle"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/duckdns/defaults/main.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/duckdns/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/duckdns/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "duckdns"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
2 changes: 0 additions & 2 deletions roles/gatus/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
service_name: "{{ ansible_role_name }}"
service_path: "{{ services_path }}/{{ service_name }}"
gatus_icmp_endpoints: []
gatus_dns_endpoints: []
gatus_healthcheck_endpoints: []
6 changes: 0 additions & 6 deletions roles/gatus/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/gatus/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "gatus"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/github_deploy/defaults/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/github_deploy/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "github-deploy"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
2 changes: 0 additions & 2 deletions roles/glances/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
---
service_name: "{{ ansible_role_name }}"
service_path: "{{ services_path }}/{{ service_name }}"
glances_proxy: false
6 changes: 0 additions & 6 deletions roles/glances/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/glances/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "glances"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/healthchecks/defaults/main.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/healthchecks/handlers/main.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/healthchecks/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "healthchecks"

- name: Create service directory
ansible.builtin.file:
path: "{{ service_path }}"
Expand Down
14 changes: 6 additions & 8 deletions roles/homeassistant/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
---
service_name: "{{ ansible_role_name }}"
service_path: "{{ services_path }}/{{ service_name }}"
stocks: []
funds: []
glances: []
glances_used_sensors:
homeassistant_stocks: []
homeassistant_funds: []
homeassistant_glances: []
homeassistant_glances_used_sensors:
- etc_hosts_used_percent
- etc_hosts_used
- etc_hosts_free
- ram_used_percent
- ram_used
- ram_free
- cpu_used
glances_unused_sensors:
homeassistant_glances_unused_sensors:
- etc_resolv_conf_used
- etc_resolv_conf_used_percent
- etc_resolv_conf_free
Expand All @@ -28,7 +26,7 @@ glances_unused_sensors:
- total
- thread
- sleeping
static_template_sensors:
homeassistant_static_template_sensors:
- name: Usage
unit_of_measurement: "%"
state: 0
Expand Down
6 changes: 0 additions & 6 deletions roles/homeassistant/handlers/main.yaml

This file was deleted.

20 changes: 13 additions & 7 deletions roles/homeassistant/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---
- name: Setup service
ansible.builtin.include_role:
name: service
vars:
service_name: "homeassistant"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
Expand Down Expand Up @@ -61,36 +67,36 @@
name: hass_cli_hide_entity
vars:
hass_cli_hide_entity_id: "sensor.stock_{{ item.name | lower | replace(' ', '_') }}" # yamllint disable rule:line-length
loop: "{{ stocks }}"
loop: "{{ homeassistant_stocks }}"

- name: Hide fund entities
ansible.builtin.include_role:
name: hass_cli_hide_entity
vars:
hass_cli_hide_entity_id: "sensor.fund_{{ item.name | lower | replace(' ', '_') }}" # yamllint disable rule:line-length
loop: "{{ funds }}"
loop: "{{ homeassistant_funds }}"

- name: Hide glances entities
ansible.builtin.include_role:
name: hass_cli_hide_entity
vars:
hass_cli_hide_entity_id: "sensor.{{ item.0.hostname | replace('.', '_') }}_{{ item.1 }}" # yamllint disable rule:line-length
with_nested:
- "{{ glances }}"
- "{{ glances_used_sensors }}"
- "{{ homeassistant_glances }}"
- "{{ homeassistant_glances_used_sensors }}"

- name: Disable glances entities
ansible.builtin.include_role:
name: hass_cli_disable_entity
vars:
hass_cli_disable_entity_id: "sensor.{{ item.0.hostname | replace('.', '_') }}_{{ item.1 }}" # yamllint disable rule:line-length
with_nested:
- "{{ glances }}"
- "{{ glances_unused_sensors }}"
- "{{ homeassistant_glances }}"
- "{{ homeassistant_glances_unused_sensors }}"

- name: Hide static template entities
ansible.builtin.include_role:
name: hass_cli_hide_entity
vars:
hass_cli_hide_entity_id: "sensor.{{ item.name | lower }}_{{ item.state }}"
loop: "{{ static_template_sensors }}"
loop: "{{ homeassistant_static_template_sensors }}"
18 changes: 9 additions & 9 deletions roles/homeassistant/templates/lovelace-monitor.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ views:
cards:
- type: vertical-stack
cards:
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- type: statistics-graph
title: {{ instance.name }}
chart_type: line
Expand Down Expand Up @@ -36,18 +36,18 @@ views:
- type: entities
title: Used
entities:
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- entity: sensor.{{ instance.hostname | replace('.', '_') }}_ram_used
name: {{ instance.name }}
{% endfor %}
- type: entities
title: Free
entities:
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- entity: sensor.{{ instance.hostname | replace('.', '_') }}_ram_free
name: {{ instance.name }}
{% endfor %}
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- type: statistics-graph
title: {{ instance.name }}
chart_type: line
Expand Down Expand Up @@ -75,18 +75,18 @@ views:
- type: entities
title: Used
entities:
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- entity: sensor.{{ instance.hostname | replace('.', '_') }}_etc_hosts_used
name: {{ instance.name }}
{% endfor %}
- type: entities
title: Free
entities:
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- entity: sensor.{{ instance.hostname | replace('.', '_') }}_etc_hosts_free
name: {{ instance.name }}
{% endfor %}
{% for instance in glances %}
{% for instance in homeassistant_glances %}
- type: statistics-graph
title: {{ instance.name }}
chart_type: line
Expand All @@ -109,12 +109,12 @@ views:
cards:
- type: vertical-stack
cards:
{% for stock in stocks %}
{% for stock in homeassistant_stocks %}
- type: tile
entity: sensor.stock_{{ stock.name | lower | replace(' ','_') }}
color: green
{% endfor %}
{% for fund in funds %}
{% for fund in homeassistant_funds %}
- type: tile
entity: sensor.fund_{{ fund.name | lower | replace(' ','_') }}
color: green
Expand Down
4 changes: 2 additions & 2 deletions roles/homeassistant/templates/portfolio.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- platform: avanza_stock
scan_interval: 60
stock:
{% for stock in stocks %}
{% for stock in homeassistant_stocks %}
- id: {{ stock.id }}
name: Stock {{ stock.name }}
{% if stock.shares|int != 0 %}
Expand All @@ -29,7 +29,7 @@
- platform: avanza_stock
scan_interval: 60
stock:
{% for fund in funds %}
{% for fund in homeassistant_funds %}
- id: {{ fund.id }}
name: Fund {{ fund.name }}
{% if fund.shares|float != 0 %}
Expand Down
2 changes: 1 addition & 1 deletion roles/homeassistant/templates/static.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
minutes: "/1"
unique_id: {{ 'static.yaml' | hash('sha1') }}
sensor:
{% for sensor in static_template_sensors %}
{% for sensor in homeassistant_static_template_sensors %}
- name: {{ sensor.name }} {{ sensor.state }}
unique_id: -{{ sensor.name | lower | replace(' ','-') }}-{{ sensor.state }}
unit_of_measurement: "{{ sensor.unit_of_measurement }}"
Expand Down
3 changes: 0 additions & 3 deletions roles/homepage/defaults/main.yaml

This file was deleted.

Loading

0 comments on commit a5e384b

Please sign in to comment.