Skip to content

Feature: Add env parameter to "state" functions. (e.g. state.highstate, state.show_highstate) #4474

Closed

Description

@salticus

Environments dev and test refer to the same directory under file_roots. Running state.show_highstate reports a number of "duplicate" state ids between the two environments.

Although not urgent, the environment parameter on highstate/show_highstate would make testing an entire collection of states a little easier.

The module state.sls does include environment parameters which is a good stop-gap.

Using salt 0.14.0

The long version

file_roots:
  dev:
    - /srv/salt/states
  test:
    - /srv/salt/states

Why do this?

All states are developed in a single directory for convenience. The top file then selects certain states for each environment. For example a dev environment uses sqlite on a single box which is replaced with a dedicated postgres server in the test environment.

dev:
  'dev':
    - django_project
test:
  'test-server':
    - django_project
  'test-db':
    - postgres

However running state.highstate lumps all environments into a single namespace.

$ salt-call --local state.show_highstate
local:
    - Detected conflicting IDs, SLS IDs need to be globally unique.
    -     The conflicting ID is "project.install::django_projects" and is found in SLS "test:project.install" and SLS "dev:project.install"
   ...repeat above for every state under file_roots...
$ salt-call --local state.show_highstate env=test
Error running 'state.show_highstate': show_highstate() takes no arguments (1 given)

Activity

  1. thatch45 commented on Apr 11, 2013

    @thatch45
    Contributor

    Ahh, I follow.
    The minion config can statically set the environment, this should be easy to add, gimme a second

  2. thatch45 commented on Apr 11, 2013

    @thatch45
    Contributor

    @salticus can you test this out, it should work, if not let me know and I will spend more time refining

  3. salticus commented on Apr 22, 2013

    @salticus
    Author

    785829f works ok for me. Several other execution functions could use environment parameters (e.g. state.show_highstate). I'll try to put together a decent pull request with some tests, but it probably won't make 0.15.

  4. thatch45 commented on Apr 22, 2013

    @thatch45
    Contributor

    Thanks, I will wait on your pull req!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions