-
Notifications
You must be signed in to change notification settings - Fork 5.5k
State sls must allow include from any environment allowed in top.sls #2683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
this does look good, just to be sure, this automatically checks for top files in the declared environments that are included? I am working through the logic and think that this might not be a good idea, unless you are allowing for the top files to be statically assigned to specific environments |
I'm probably just not familiar enough with the project yet, but I'm confused when you say "top files." I am only familiar with creating a single top file in the base file root. Is this not always the case? |
Ahh, I see my misunderstanding, I thought you were including top files, (which you can do from the main top file) |
There should be no change in syntax. Let's see if I can put together an example: /etc/salt/master file_roots:
base:
- /srv/salt/base
dev:
- /srv/salt/dev
prod:
- /srv/salt/prod /srv/salt/base/top.sls base:
'*':
- core
dev:
'dev-web*':
- webserver
prod:
'prod-web*':
- webserver salt:// file server tree
With this patch, the webserver.sls file in each role environment can include role.webserver from the base environment because base matches on '*'. include:
- role.webserver
# extend states from base: role.webserver
# ...
# add new role/environment specific states
# ... Now, add I hope that makes sense. Thank you for taking the time to discuss this. Did that answer the syntax question? |
This is cleaned up a bit and more efficient: tsclausing@213f976 |
… the minion has access via top.
I like the capability, but I fear that this will make people start include:
So the the environment is explicit? I understand where you are going here, On Fri, Nov 23, 2012 at 10:57 PM, T. Scot Clausing <[email protected]
|
I really don't like the idea of include:
- sls.in.current.env
- xenv: sls.to.resolve Where OR Maybe we can do both.
Thoughts? |
I like the both approach, explicit declaration and dynamic allowance, awesome! |
New syntax in commit tsclausing@1fa275f allows the following: include:
- foo
- env: bar
- _xenv: baz
Look good? I'll need to update the corresponding docs as well if we decide to move forward. |
#2683 - include state sls from any env which the minion matches in top
Looks awesome, do you think that we need the underscore before the xenv? |
The underscore is an attempt to follow the convention of Is this a good line of thinking, or is there something else to consider? |
This is a good line of thinking! Very nice! Thanks! |
doesn't actually work. it chokes if you feed it an unordered dict (i.e. env: value or _xenv: value) [DEBUG ] Results of YAML rendering: Data failed to compile:
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2483, in call_highstate |
Seems like there has been a regression. I'm using 2015.5.5, however the issue seems to be present even in the development branch. @tsclausing had made an edit to state.py (1fa275f) mentioned above back in 2012. It looks like some part of that commit made it into the present-day state.sls. On the 2015.5.5 tag, state.sls file line 2593, you can see part of his code. However it seems to have been pushed down, in that line 2578 is executed first, which fails with the error seen there if the _xenv dict key is used in the include. It looks like the order of that check would need to be shuffled around to allow the _xenv option to work again. |
Currently, the include declaration in a state sls file only allows includes from within the same environment: see here. This means that the only way to include files from environment B in environment A is to add environment B's file root to environment A's file roots.
Instead of having to include cross environment via file_roots, the include declaration should just respect environments from top.sls.
I've attempted a fix here:
tsclausing@ba8436a
tsclausing@7ae8f76 <- backwards compatible
tsclausing@213f976 <- more efficient
Looking forward to your feedback. This is my first attempt to contribute, so please be gentle :)
The text was updated successfully, but these errors were encountered: