Refactor matterbridge profile
All checks were successful
ci/lysergic/push/pipeline Pipeline was successful
All checks were successful
ci/lysergic/push/pipeline Pipeline was successful
- reduce pillar calls - no longer define possible configuration options, apply settings from pillar 1:1 Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
f678de8560
commit
650854fa27
@ -1,35 +1,33 @@
|
|||||||
{%- set header = salt['pillar.get']('managed_header_pound') -%}
|
{%- set header = salt['pillar.get']('managed_header_pound') -%}
|
||||||
{%- set myfqdn = salt['grains.get']('fqdn') -%}
|
|
||||||
{%- set mypillar = 'profile:matterbridge:instances:' ~ instance ~ ':' -%}
|
|
||||||
{%- set myaccounts = mypillar ~ 'accounts' -%}
|
|
||||||
{%- set mygateways = mypillar ~ 'gateways' -%}
|
|
||||||
{%- set generalopts = ['RemoteNickFormat', 'IgnoreFailureOnStart', 'MessageSplit', 'MediaDownloadSize', 'MediaDownloadPath', 'MediaServerDownload', 'LogFile'] -%}
|
|
||||||
{%- set accountopts = ['Nick', 'NickServNick', 'NickServPassword', 'Server', 'UseTLS', 'UseSASL', 'Label', 'Charset', 'IgnoreNicks', 'RunCommands', 'UseRelayMsg', 'RemoteNickFormat'] -%}
|
|
||||||
{{ header }}
|
{{ header }}
|
||||||
|
|
||||||
|
{%- if general | length %}
|
||||||
[general]
|
[general]
|
||||||
{% for option in generalopts %}
|
{%- for option, value in general.items() %}
|
||||||
{%- if salt['pillar.get'](mypillar ~ option, None) != None %}
|
{%- if value is string %}
|
||||||
{{ option }}="{{ salt['pillar.get'](mypillar ~ option) }}"
|
{%- set value = '"' ~ value ~ '"' %}
|
||||||
{%- endif -%}
|
{%- endif %}
|
||||||
{%- endfor -%}
|
{{ option }}={{ value }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for account, config in salt['pillar.get'](myaccounts).items() %}
|
{%- for account, config in accounts.items() %}
|
||||||
[{{ config['protocol'] }}.{{ account }}]
|
[{{ account }}]
|
||||||
{%- for option in accountopts %}
|
{%- for option, value in config.items() %}
|
||||||
{%- if salt['pillar.get'](myaccounts ~ ':' ~ account ~ ':' ~ option, None) != None %}
|
{%- if value is string %}
|
||||||
{{ option }}="{{ config[option] }}"
|
{%- set value = '"' ~ value ~ '"' %}
|
||||||
{%- endif -%}
|
{%- endif %}
|
||||||
|
{{ option }}={{ value }}
|
||||||
|
{%- endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor -%}
|
|
||||||
|
|
||||||
{% for gateway, config in salt['pillar.get'](mygateways).items() %}
|
{%- for gateway, config in gateways.items() %}
|
||||||
[[gateway]]
|
[[gateway]]
|
||||||
name="{{ gateway }}"
|
name="{{ gateway }}"
|
||||||
enable=true
|
enable=true
|
||||||
{% for account, channel in config.items() %}
|
{%- for account, channel in config.items() %}
|
||||||
[[gateway.inout]]
|
[[gateway.inout]]
|
||||||
account="{{ account }}"
|
account="{{ account }}"
|
||||||
channel="{{ channel }}"
|
channel="{{ channel }}"
|
||||||
|
{%- endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{%- endfor -%}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{%- set mypillar = 'profile:matterbridge' -%}
|
{%- set mypillar = salt['pillar.get']('profile:matterbridge') -%}
|
||||||
{%- set instances = salt['pillar.get'](mypillar ~ ':instances') or [] -%}
|
{%- set instances = mypillar['instances'] | default([]) -%}
|
||||||
|
|
||||||
matterbridge_packages:
|
matterbridge_packages:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
@ -31,7 +31,12 @@ matterbridge_files:
|
|||||||
- /etc/matterbridge/{{ instance }}.toml:
|
- /etc/matterbridge/{{ instance }}.toml:
|
||||||
- context:
|
- context:
|
||||||
instance: {{ instance }}
|
instance: {{ instance }}
|
||||||
|
general: {{ instances[instance]['general'] | default({}) }}
|
||||||
|
accounts: {{ instances[instance]['accounts'] }}
|
||||||
|
gateways: {{ instances[instance]['gateways'] }}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
{%- for instance in instances %}
|
||||||
matterbridge_{{ instance }}_service:
|
matterbridge_{{ instance }}_service:
|
||||||
service.running:
|
service.running:
|
||||||
- name: matterbridge@{{ instance }}.service
|
- name: matterbridge@{{ instance }}.service
|
||||||
|
Loading…
Reference in New Issue
Block a user