summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2023-01-22 19:20:53 +0100
committerGeorg Pfuetzenreuter2023-01-22 19:28:28 +0100
commit2e08c3cf360fe07f3dbe6c6f0951d56ee33c30a3 (patch)
tree865721b48c72288220b60e95efd9d7ad75ddba7b
parenta5754ea0cb540c40ff9ee59bff69c856be167d6f (diff)
downloadsalt-2e08c3cf360fe07f3dbe6c6f0951d56ee33c30a3.tar.gz
salt-2e08c3cf360fe07f3dbe6c6f0951d56ee33c30a3.tar.bz2
salt-2e08c3cf360fe07f3dbe6c6f0951d56ee33c30a3.zip
Connect syndic minions to syndic master
Syndics are generally the masters assigned to their region. We want the minions on syndics to connect to their upstream master ("master of masters") instead of to themselves. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
-rw-r--r--salt/profile/salt/minion.sls12
1 files changed, 11 insertions, 1 deletions
diff --git a/salt/profile/salt/minion.sls b/salt/profile/salt/minion.sls
index f55bb97..d9265c4 100644
--- a/salt/profile/salt/minion.sls
+++ b/salt/profile/salt/minion.sls
@@ -1,7 +1,17 @@
+{%- set netbox_pillar = salt['pillar.get']('netbox') -%}
+{%- if 'custom_fields' in netbox_pillar and 'salt.syndic' in netbox_pillar['custom_fields']['salt_roles'] -%}
+{%- set master = salt['pillar.get']('salt:master:syndic_master') -%}
+{%- elif 'config_context' in netbox_pillar -%}
+{%- set master = netbox_pillar['config_context']['salt_master'] -%}
+{%- else -%}
+{%- do salt.log.warning('Could not determine Salt master') -%}
+{%- set master = 'FIX-ME.lysergic.dev' -%}
+{%- endif -%}
+
/etc/salt/minion.d/master.conf:
file.managed:
- contents:
- - 'master: {{ salt['pillar.get']('netbox:config_context:salt_master') }}'
+ - 'master: {{ master }}'
- require_in:
- service: salt-minion
- watch_in: