Skip to content

Commit

Permalink
chore(libsaltcli): add lib to check type of Salt command being used
Browse files Browse the repository at this point in the history
* 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: saltstack-formulas#102, saltstack-formulas#114 & saltstack-formulas#115
* Finalised from saltstack-formulas/libvirt-formula#71
* Required by saltstack-formulas#186
  • Loading branch information
myii committed Mar 25, 2020
1 parent f81c372 commit a6487b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions TEMPLATE/libsaltcli.jinja
Original file line number Diff line number Diff line change
@@ -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) %}

0 comments on commit a6487b5

Please sign in to comment.