saltstack / saltstack/salt

[BUG] 3002.5 salt-ssh: `file.read` and `cmd.run` both run on master.

Open
#59,737 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.file.html says it's for managing files on the minion, but when I use salt.file.read() in a pillar SLS file with salt-ssh, it returns the contents of the file on the master instead of the minion. salt.cmd.run() has the same behavior.

Setup

foo.sls in my pillar:

file.read: {{ salt.file.read('/etc/hostname') }}
cmd.run: {{ salt.cmd.run('cat /etc/hostname') }}

Steps to Reproduce the behavior

Run salt-ssh some-minion pillar.items.

Expected behavior

I think pillar.items should show the contents of /etc/hostname on the minion, but instead it shows the contents of that file on the local machine where I ran salt-ssh.

Versions Report

salt-ssh --versions-report (Provided by running salt-ssh --versions-report. Please also mention any differences in master/minion versions.)

The minion is Debian buster stable.

$ salt-ssh --versions-report
Salt Version:
          Salt: 3002.2
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.2
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: 1.1.3
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.9.7
        pygit2: Not Installed
        Python: 3.9.1+ (default, Feb  5 2021, 13:46:56)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: debian testing bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-3-amd64
        system: Linux
       version: Debian GNU/Linux testing bullseye

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 behavior with the pillar SLS example and salt-ssh some-minion pillar.items. Trace how pillar.items evaluates salt.file.read and salt.cmd.run under salt-ssh, then verify that both calls read or execute on the minion rather than the local machine.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.