From a6487b5cf9cf2736d1e5f386be4b418d7bc2461b Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 27 May 2019 18:36:57 +0100 Subject: [PATCH] chore(`libsaltcli`): add lib to check type of Salt command being used * To distinguish between: - `salt-minion` - `salt-call` - `salt-ssh` * Invoked like `map.jinja`: - `{%- from tplroot ~ "/libsaltcli.jinja" import cli with context %}` * Based upon work done in PRs: #102, #114 & #115 * Finalised from https://github.com/saltstack-formulas/libvirt-formula/pull/71 * Required by #186 --- TEMPLATE/libsaltcli.jinja | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 TEMPLATE/libsaltcli.jinja diff --git a/TEMPLATE/libsaltcli.jinja b/TEMPLATE/libsaltcli.jinja new file mode 100644 index 00000000..6bd11ad8 --- /dev/null +++ b/TEMPLATE/libsaltcli.jinja @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# vim: ft=jinja + +{#- Determine the type of command being run #} +{%- if salt['config.get']('__cli') == 'salt-minion' %} +{%- set cli = 'minion' %} +{%- elif salt['config.get']('__cli') == 'salt-call' %} +{%- if salt['config.get']('root_dir').endswith('/running_data') %} +{%- set cli = 'ssh' %} +{%- else %} +{%- set cli = 'local' %} +{%- endif %} +{%- else %} +{%- set cli = 'unknown' %} +{%- endif %} +{%- do salt['log.debug']('[libsaltcli] the salt command type has been identified to be: ' ~ cli) %}