Saltstack: Error: unable to cache file 'salt://foo/bar/test.sh' from saltenv base in minion

Viewed 435

I have configured 2 env in salt prod & nonprod. In nonprod env I am trying the schedule a job which will run a script in the minion.

These are my files looks like... Salt version is 3001.1

/etc/salt/master

file_roots:
  nonprod:
    - /srv/salt/nonprod
  prod:
    - /srv/salt/prod

pillar_roots:
  nonprod:
    - /srv/nonprod_pillar
  prod:
    - /srv/prod_pillar

/srv/salt/nonprod/top.sls

nonprod:
  minion1:
    - match: glob
    - foo.bar

/srv/salt/nonprod/foo/bar/init.sls

backup_job:
  schedule.present:
    - function: cmd.script
    - job_args:
      - salt://foo/bar/test.sh
      - env: nonprod
    - when:
      - Monday 02:36am

The script "test.sh" is present under /srv/salt/nonprod/foo/bar/test.sh

Could anyone please tell me what am I doing wrong.

1 Answers

The error indicates that the Minion is looking for the test.sh in "base" environment. It is possible that the job_args you passed with the environment name was ignored.

There is another way to reference files from Salt master - by appending ?saltenv=<envname> to the file source.

Something like below:

backup-job:
  schedule.present:
    - function: cmd.script
    - job_args:
        - salt://foo/bar/test.sh?saltenv=nonprod
    - when:
        - Monday 10:30pm
Related