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
  • Loading branch information
myii committed May 27, 2019
1 parent 9b88cf4 commit 7721eb0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions template/libsaltcli.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- 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') == '/' %}
{%- set cli = 'local' %}
{%- else %}
{%- set cli = 'ssh' %}
{%- endif %}
{%- else %}
{%- set cli = 'unknown' %}
{%- endif %}

0 comments on commit 7721eb0

Please sign in to comment.