saltstack / saltstack/salt

[BUG] `env_order` does not work as advertised; omitted envs can't be included

Open
#58,100 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

The docs at https://docs.saltstack.com/en/latest/ref/configuration/master.html#env-order say (emphasis mine):

When top_file_merging_strategy is set to merge, and no environment is specified for a highstate, this config option allows for the order in which top files are evaluated to be explicitly defined.

But env_order is clearly being checked for a non-highstate state, and when an environment is explicitly specified.

Setup

Relevant master configuration excerpt:

file_roots:
  base:
    - /srv/salt
  dev:
    - /srv/salt/dev
env_order:
  - base

/srv/salt/dev/foo.sls:

include:
  - bar

/srv/salt/dev/bar.sls:

bar:
  test.succeed_without_changes: []

Steps to Reproduce the behavior

# salt-call state.apply foo saltenv=dev
[ERROR   ] Nonexistent saltenv 'dev' found in include of 'bar' within SLS 'dev:foo'
local:
    Data failed to compile:
----------
    No matching salt environment for environment 'dev' found
----------
    Nonexistent saltenv 'dev' found in include of 'bar' within SLS 'dev:foo'

Expected behavior

State should run. Both files are in the dev environment. If I add dev to the env_order, it works.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
           Salt: 3001
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.1
        libgit2: Not Installed
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: Not Installed
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.8 (default, Apr  2 2020, 13:34:55)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 17.0.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7 Core
         locale: UTF-8
        machine: x86_64
        release: 5.4.0-42-generic
         system: Linux
        version: CentOS Linux 7 Core

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 failure with salt-call state.apply foo saltenv=dev and the shown env_order configuration. Trace how env_order, the explicit saltenv, and the include in dev:foo are handled, then verify that the state runs without adding dev to env_order and that the documented behavior is covered by a regression test.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.