-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow "multiple state declarations of the same type" when function is different #35592
Comments
@Ch3LL I looked that issue up already but it's not 100% the same I think. They need 2x "apache_site.enabled". I need "apache_site.enabled" + "apache_site.disabled" which is different. So, I let you the choice to close the issue if you think the internal implementation would be the same. :) |
Thanks for clarifying . Will add this as a feature request instead of treating as a duplciate thanks. |
Glad to see that this is already in the queue. Just wanted to add another (probably more common) example ... |
I ran into this exact issue today, with the following use case: |
same here trying to do:
|
|
Ran into this as well using:
|
I'd like this feature as well
|
Another use case:
|
One of the most 'in your face' features that should be added...but I'm guessing backwards compatibility limits this. |
And another, possibly quite common use case!
|
I would have liked to setup passwordless ssh keys to a repo host (without using 'id-rsa' for the keyfile) in one state
|
additional case: the alternatives system: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.alternatives.html openjdk.set.java:
alternatives.install:
- name: java
- link: /usr/bin/java
- path: /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java
- priority: 5
- require:
- pkg: openjdk.install
alternatives.set:
- name: java
- path: /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java |
👍 |
Another use case:
file.append would create file with the wrong permission (aka root) if the files doesn't exist and you can't define that info. So you must run an empty manage that will create an empty file if absent with the proper permissions, then append logically follow. |
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. |
not stale |
Thank you for updating this issue. It is no longer marked as stale. |
👍 |
Hello, Is this still in the pipeline? Similar requirement:
Thanks, |
To us this is no longer a pressing issue as it is just a convenience feature is is actually not needed in more complex scenarios (which evolve when using salt a lot). We also experienced confusion -- when reusing a state id -- among those who are not so experienced with salt but still need to write salt-sls-code. So, we would rather go the other way, removing reusing state names completely. |
I created #57150 and let the community decide which way to go. :-) |
Also run in to this with |
Another use case where this might become handy:
|
Yep, I was trying to use file.keyvalue to update one of the config files of a service and file.append (which is in another format) to update another. Not possible :( |
@NotAProfessionalDeveloper although there aren't many "hard and fast" rules for organizing your SLS scripts, the situation you have described might be more easily handled by two different State IDs:
Because these are two different files, the Salt standard would be to handle them as separate "steps" in your SLS file. This issue (#35592) was opened to address situations in which the changes enforced by a particular State would be considered one single operation on your local machine (for example, prepending and appending text to one file via a text-editor). Hypothetically, changes such as prepend+append could be managed by two states: |
Still, editing both files is part of the deployment of the same service: install the package, configure, start the service. |
For the use case you describe, you should be using separate salt states with
This is the way Salt is expected to be used per the official documentation. The reason for this has to do, at least in part, with the completion of States and how they are confirmed; if you group all of those steps together, and any one part of them fails (such as the starting of the service), then the entire state is marked as failed when in fact maybe just the network connection was down when starting a networked service, etc etc. |
That's actually a very good reason not to do it. Also from a long-term user's perspective, I would recommend to avoid shared state ids altogether. They look nice in the beginning but later on it's easier when you setup grows. |
So, I'm going to close this. there are some very big reasons this has not been considered yet. first the way states actually work in the lower end data this actually can't work.
the above gets rendered down to this internally
if you know anything about python you know you can't have 2 labels with the same key in a python dict. and if we tried merging them to get around this we end up with options without knowing which item goes to with function. to change the way this functions is a huge change. and would take a complete rewrite of the way states work. we just don't have the staff for a rewrite for only this functionality. I'm going to close this ticket with the above information. the information about using 1 function per state id is a better work around and makes more sense in the overall state definition. |
Hello, Thanks for your proposition, but what about:
Could this be a good "deal" ? |
That won't work. the entire system is built around lists. to switch to a dict would require rewriting the entire state system. which would also break backwards compatibility. |
Hello, Okay thank you ! Thanks for maintaining saltstack ! |
It would be great if one could do the following:
Right now, we circumvent the error by introducting another state such as:
The text was updated successfully, but these errors were encountered: