Hi Thomas,
thanks for reply.
Meanwhile I've found way how to achieve what I wanted... I was fidling around with wrong option.
My desired behavior was achieved by this:
master config:
root@ub22-test:~# cat /etc/salt/master.d/saltenv.conf
file_roots:
base:
- /srv/salt/formulas
test:
- /srv/saltenv/test/formulas
state_top_saltenv: base
top.sls for both environments
root@ub22-test:~# cat /srv/salt/formulas/top.sls
base:
'*':
- test
root@ub22-test:~# cat /srv/saltenv/test/formulas/top.sls
test:
'*':
- test
output of show_top:
root@ub22-test:~# salt ub22-test state.show_top
ub22-test:
----------
base:
- test
root@ub22-test:~# salt ub22-test state.show_top saltenv=base
ub22-test:
----------
base:
- test
root@ub22-test:~# salt ub22-test state.show_top saltenv=test
ub22-test:
----------
test:
ok.. here are two almost identical states .. with identical IDs in different environments:
root@ub22-test:~# cat /srv/salt/formulas/test/init.sls
{{ sls }} this is test:
test.succeed_without_changes
root@ub22-test:~# cat /srv/saltenv/test/formulas/test/init.sls
{{ sls }} this is test:
test.fail_without_changes
so now call without without specifying saltenv:
root@ub22-test:~# salt ub22-test state.highstate test=true
ub22-test:
----------
ID: test this is test
Function: test.succeed_without_changes
Result: True
Comment: Success!
Started: 20:46:21.216050
Duration: 0.402 ms
Changes:
Summary for ub22-test
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 0.402 ms
and here is run with specified saltenv=test
root@ub22-test:~# salt ub22-test state.highstate test=true saltenv=test
ub22-test:
----------
ID: test this is test
Function: test.fail_without_changes
Result: False
Comment: If we weren't testing, this would be a failure!
Started: 20:46:48.484537
Duration: 1.709 ms
Changes:
Summary for ub22-test
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 1.709 ms
This was tested on master 3004.1 and 3006.5.. works in both cases..
Still.. I am not completely sure why it worked, cause description of that option is bit vague and from my point of view it offer too much room for interpretation:
This option has no default value. Set it to an environment name to ensure that only the top file from that environment is considered during a highstate.
Note
Using this value does not change the merging strategy. For instance, if top_file_merging_strategy is set to merge, and state_top_saltenv is set to foo, then any sections for environments other than foo in the top file for the foo environment will be ignored. With state_top_saltenv set to base, all states from all environments in the base top file will be applied, while all other top files are ignored. The only way to set state_top_saltenv to something other than base and not have the other environments in the targeted top file ignored, would be to set top_file_merging_strategy to merge_all.
But still.. I am glad that I was able to find solution to my issue :)
Hope it helps somebody else with same issue..
Best regards,
Peter