Hassan
Hassan

Reputation: 63

How to change file_roots and pillar_roots in salt command without updating the configuration file

All of our salt scripts are located in /srv/salt/ and /srv/pillar/ directories and they are synced with SVN.

In salt configuration file (/etc/salt/master) I have defined the file_roots and pillar_roots as below so once any salt command is executed, it uses these paths.

file_roots:
  base:
    - /srv/salt/

pillar_roots:
  base:
    - /srv/pillar/

I want to create a new directory and duplicate all the scripts there (/srv/salt_test/salt/ and /srv/salt_test/pillar/) for test.

Is there any way that I can pass parameters to salt command to force it to use these test path? Something like:

$salt file_roots=/srv/salt_test/salt/  pillar_roots=/srv/salt_test/pillar/ servername.domain.com state.sls weblogic.install

Thanks a lot in advance.

Upvotes: 1

Views: 2058

Answers (1)

Hassan
Hassan

Reputation: 63

I found the solution and would like to share it here:

I've updated /etc/salt/master as below:

file_roots:
  base:
    - /srv/salt/
  test:
    - /srv/salt_test/

pillar_roots:
  base:
    - /srv/pillar/
  test:
    - /srv/pillar_test/

Then restarted salt on master and minions. Now I can use saltEnv=test pillarEnv=test options to force salt master to read scripts from /srv/pillar_test/ and /srv/salt_test/

Sample:

$salt minion.domain.com state.sls weblogic.install saltEnv=test pillarEnv=test

Hope it will be useful for someone else.

Upvotes: 2

Related Questions