paulbsd-salt/states/netbox/templates/configuration.py.j2

47 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-07-10 00:58:55 +02:00
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
{%- from "netbox/map.jinja" import netbox with context -%}
{%- macro subdict(data) %}
{%- for item, value in data.items() %}
{%- if value is string or value == "" %}
"{{ item|upper }}": "{{ value }}",
{%- else %}
"{{ item|upper }}": {{ value }},
{%- endif %}
{%- endfor %}
{%- endmacro %}
{%- for item, value in netbox.config.items() %}
{%- if value is mapping %}
{{ item|upper }} = {
{%- for item2, value2 in value.items() %}
{%- if value2 is mapping %}
"{{ item2 }}": {
{{ subdict(value2) }}
}{%- if not loop.last -%},{%- endif -%}
{%- elif value2 is string or value2 == "" %}
"{{ item2|upper }}": "{{ value2 }}",
{%- else %}
"{{ item2|upper }}": {{ value2 }},
{%- endif %}
{%- endfor %}
}
{% elif value is iterable and value is not string %}
{{ item|upper }} = [
{%- for v in value %}
{%- if v is string %}
"{{ v }}",
{%- else %}
{{ v }},
{%- endif %}
{%- endfor %}
]
{% else %}
{%- if value is string or value == "" %}
{{ item|upper }} = "{{ value }}"
{%- else %}
{{ item|upper }} = {{ value }}
{%- endif %}
{%- endif %}
{%- endfor %}