Skip to content

Can not override file_roots and pillar_roots with salt --config-dir option #25344

Closed

Description

@MrCitron

Hi,
here is my use case : our states and pillars comes from a git repo and are cloned in the master filesystem as file_roots and pillar_roots.

/etc/salt/master.d/custom.conf :

file_roots:
  base:
    - /app/cd-factory/salt-states

pillar_roots:
  base:
    - /app/cd-factory/salt-pillars

But now, we want to control what revision for the states and pillars for every salt command we run (inside jenkins job for example)

I thought I just need to copy the conf file into a per job directory and alter the file_roots and pillar_roots as follows :

$myworkspace/conf/master :

file_roots:
  base:
    - $myworkspace_dir/cd-factory/salt-states

pillar_roots:
  base:
    - $myworkspace_dir/cd-factory/salt-pillars

and run salt command with -c $myworkspace/conf.

This is not working without restarting the master daemon and even then it seems like my specific configuration does not override the general one.

Maybe this is not the right way to achieve my goal and any other solution to handle this use case is welcome.

Activity

  1. basepi commented on Jul 13, 2015

    @basepi
    Contributor

    file_roots and pillar_roots are global master config options, and so are not affected by using -c with just a basic salt command. You must use -c with the salt-master command when starting the master. These config options also always require a master restart (as is expected, since they must be in place when the master is started).

    Hope that helps!

  2. added
    expected-behavior
    on Jul 13, 2015
  3. added this to the Blocked milestone on Jul 13, 2015
  4. MrCitron commented on Jul 16, 2015

    @MrCitron
    ContributorAuthor

    Thanks @basepi, actually this is not really helping as I still have no solution to use different versions of my states file when running salt command.

    For now, I will limit my job to one execution at the same time to avoid mixing different versions of my state files during highstate.

    Anyway, any advice regarding my need will be appreciated.

  5. basepi commented on Jul 23, 2015

    @basepi
    Contributor

    Rather than use different file_roots and pillar_roots, why not just target different files within those directories? Just run salt '*' state.sls firstdir.test for firstdir/test.sls and salt '*' state.sls seconddir.test for seconddir/test.sls. You can also use environments and target the environment on the command line using salt '*' state.sls test saltenv=myenv.

    Finally, you could compile different highstates into separate topfiles and use state.top to target the correct topfile.

  6. redarqas commented on Oct 13, 2015

    @redarqas

    It would be very useful to make config-dir override working with salt cli. Not making it global config option.

  7. basepi commented on Oct 15, 2015

    @basepi
    Contributor

    That would be useful -- however, it's hard because of the salt architecture. Basically, the salt-cli fires off a command to the minions. The minions then run that command, reaching out to the master for any files they need. The master does not match requests from minions with running CLI jobs, and so has no ability to change the file_roots or similar on the fly in that manner. They have to be changed at master runtime.

  8. stale commented on Jan 20, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

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

    expected-behaviorstale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions