saltstack / saltstack/salt

Jinja condition is not being evaluated correctly in salt-ssh minion

Open
#56,030 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-low
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

I need to check if salt module exist before executing it. So I have a Jinja condition in statefile but it is not working on salt-ssh minion.

Setup
{% if 'network.fqdns' in salt %}
fqdns:
  module.run:
    - name: network.fqdns
{% endif%}

Above excerpt correctly returns nothing when executed on a regular minion and network.fqdns module is not available. But when executed on a salt-ssh minion, it returns.

   module_|-fqdns_|-network.fqdns_|-run": {
            "__id__": "fqdns",
            "__run_num__": 10,
            "changes": {},
            "comment": "Module function network.fqdns is not available",
            "duration": 343.473,
            "name": "network.fqdns",
            "result": false,
            "start_time": "13:14:03.907709"
        }

which is not what I expect.

Steps to Reproduce Issue

Execute a state with a condition like above, once on a regular minion and once on salt-ssh minion. Regular minion will return nothing in case module is not there while salt-ssh minions will return the result as mentioned above.

Versions Report
Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.5.2
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Jan 11 2017, 10:56:06) [GCC]
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
 
System Versions:
           dist: SuSE 12 x86_64
         locale: UTF-8
        machine: x86_64
        release: 4.4.21-69-default
         system: Linux
        version: SUSE Linux Enterprise Server  12 x86_64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the state with the Jinja condition on both a regular minion and a salt-ssh minion, then compare how the available module names are exposed during rendering. Done means an unavailable network.fqdns module is omitted consistently instead of producing a failed module.run result on salt-ssh.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.