summaryrefslogtreecommitdiffstats
path: root/salt/profile/matterbridge
diff options
context:
space:
mode:
Diffstat (limited to 'salt/profile/matterbridge')
-rw-r--r--salt/profile/matterbridge/files/etc/matterbridge/matterbridge.toml.j235
-rw-r--r--salt/profile/matterbridge/init.sls45
2 files changed, 80 insertions, 0 deletions
diff --git a/salt/profile/matterbridge/files/etc/matterbridge/matterbridge.toml.j2 b/salt/profile/matterbridge/files/etc/matterbridge/matterbridge.toml.j2
new file mode 100644
index 0000000..11204f3
--- /dev/null
+++ b/salt/profile/matterbridge/files/etc/matterbridge/matterbridge.toml.j2
@@ -0,0 +1,35 @@
+{%- 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 }}
+
+[general]
+{% for option in generalopts %}
+{%- if salt['pillar.get'](mypillar ~ option, None) != None %}
+{{ option }}="{{ salt['pillar.get'](mypillar ~ option) }}"
+{%- endif -%}
+{%- endfor -%}
+
+{% for account, config in salt['pillar.get'](myaccounts).items() %}
+[{{ config['protocol'] }}.{{ account }}]
+{%- for option in accountopts %}
+{%- if salt['pillar.get'](myaccounts ~ ':' ~ account ~ ':' ~ option, None) != None %}
+{{ option }}="{{ config[option] }}"
+{%- endif -%}
+{% endfor %}
+{% endfor -%}
+
+{% for gateway, config in salt['pillar.get'](mygateways).items() %}
+[[gateway]]
+name="{{ gateway }}"
+enable=true
+{% for account, channel in config.items() %}
+ [[gateway.inout]]
+ account="{{ account }}"
+ channel="{{ channel }}"
+{% endfor %}
+{%- endfor -%}
diff --git a/salt/profile/matterbridge/init.sls b/salt/profile/matterbridge/init.sls
new file mode 100644
index 0000000..eee6df2
--- /dev/null
+++ b/salt/profile/matterbridge/init.sls
@@ -0,0 +1,45 @@
+{%- set mypillar = 'profile:matterbridge' -%}
+{%- set instances = salt['pillar.get'](mypillar ~ ':instances') or [] -%}
+
+matterbridge_packages:
+ pkg.installed:
+ - pkgs:
+ - matterbridge
+
+matterbridge_directory:
+ file.directory:
+ - user: root
+ - group: matterbridge
+ - clean: True
+ - require:
+ - pkg: matterbridge_packages
+{%- if instances | length > 0 %}
+ - file: matterbridge_files
+{%- endif %}
+ - names:
+ - /etc/matterbridge
+
+{%- if instances | length > 0 %}
+matterbridge_files:
+ file.managed:
+ - user: root
+ - mode: '0644'
+ - template: jinja
+ - source: salt:///{{ slspath }}/files/etc/matterbridge/matterbridge.toml.j2
+ - names:
+{%- for instance in instances %}
+ - /etc/matterbridge/{{ instance }}.toml:
+ - context:
+ instance: {{ instance }}
+
+matterbridge_{{ instance }}_service:
+ service.running:
+ - name: matterbridge@{{ instance }}.service
+ - enable: True
+{%- endfor %}
+{%- endif %}
+
+matterbridge_cleanup_timer:
+ service.running:
+ - name: matterbridge-cleanup.timer
+ - enable: True