Skip to content

Commit

Permalink
Allow lists as smart_devices, fixes stuvusIT#15
Browse files Browse the repository at this point in the history
  • Loading branch information
devster31 committed Nov 13, 2020
1 parent 3bc09cc commit ae46882
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion templates/smartd.conf.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# {{ ansible_managed }}
{% set elements = [] %}
{% set n_devices = smartd_devices | length %}
{% if smartd_devices is mapping %}
{%- set names = smartd_devices.keys() | list | d([]) %}
{%- set configs = smartd_devices.values() | list | d([]) %}
{%- for i in range(n_devices) %}
{{- elements.append({"name": names[i], "config": configs[i]}) -}}
{%- endfor %}
{% else %}
{%- set names = smartd_devices | map(attribute="name") | list | d([]) %}
{%- set configs = smartd_devices | map(attribute="config") | list | d([]) %}
{%- for i in range(n_devices) %}
{{- elements.append({"name": names[i], "config": configs[i]}) -}}
{%- endfor %}
{% endif %}


{% for name,config in smartd_devices.items() | d([]) %}
{% for d in elements | d([]) %}
{% set name = d.name %}
{% set config = d.config %}
{{- name -}}
{%- if config.type|d(smartd_default_type) != 'auto' %}
{{- " -d " }}{{ config.type|d(smartd_default_type) -}}
Expand Down

0 comments on commit ae46882

Please sign in to comment.