You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined multiple pillar environment in order to be able to write more generic states. That way important config data of a state can be easily replaced by the config values of another pillar environment.
The problem is that only the values of the last defined enviroment in the pillar top.sls are available indepedent of the passed environemt in state.sls call. Is this a bug or did I get something wrong?
State: - cmd
Name: echo "This is a dev pillar value"
Function: run
Result: True
Comment: Command "echo "This is a dev pillar value"" run
Changes: pid: 2892
retcode: 0
stderr:
stdout: This is a dev pillar value
Since you have a match of a * for every environment, every system is being matched. This is also because the env value is passed only to state environments and not pillar environments
So that means it is intended behaviour? Maybe I misunderstood that whole concept of environments. To be honest I used enviroments more like a kind of vehicle for the solution I am aiming at. Basically, I'm looking for an option to provide Salt a dynamic render context.
That way I could define a generic state with a default value which can be overwritten with a dynamically injected pillar value. Since there is no option to pass such data dynamically to my state I tried to define those data structures in a static way in the form of an environment.
My concrete problem: I have already defined several states to setup my technology stack on a server. Now I have to setup that same stack with a slightly different set of configuration data (like username, checkout paths, web root etc.). I could duplicate all states and change the particular data but that is neither DRY nor does it scale if you have to do that more than 2 oder 3 times.
Yes, merging the environments is the intended behavior, the top file allows for the environments to be specified on the master. Settign dynamic values to states is done with pillar but I think you are just seeing it from the wrong direction. When setting up environments you need to specify which minions realize which environments:
base:
'*base*':
- data
dev:
'*dev*'
- data
This is assuming that you have divided up environments based on minion id, but grains or other target systems can also be used.
Finally in your last command in your last comment here I am confused, are you assuming that -P users:user2 only applies the user2 key in users? -P passes in extra data to the pillar, it does not have anything to do with matching existing data
Hi Thomas, sorry I was not very clear about my use of environments. I have only used them because Salt is lacking an option to pass in a dynamic render context. That's why I tried to realize that with environments. I thought of pillar environments as separarated "containers" that hold my data. But now I know that was wrong. So environments do not make sense as a solution for this problem.
In my last post I tried to describe the approach of a dynamic render context (without the use of environments). As I already said in my last post. I would like to write states that are as generic (a.k.a DRY) as possible and use them with different sets of data. In my case I have to setup the same specific technology stack on multiple servers as well as to setup that technology stack multiple times with slightly different configuration data on a single machine (e.g. one development environment per user on one machine).
At the moment there is only one way for me to do that. Replicate my state tree multiple times (with all disadvantages of such a non-DRY approach). With a dynamic render context I only would have to define another data structure to reuse my states.
The example of my last post describes exactly that. You define a generic state, a data structure (config data) and with the imaginary option -P (-p would probably be smarter because capitalized options seems to be used only to define an alternative way to target minions) you could pass in the root of the pillar data which is used by Salt as a render context. The state uses the data structure git:user, git:pass and git:rev and the -P option tells which node inside my pillar holds that data structure.
I hope this time the actual approach got more clear.
So you just want to pass in the data that gives you specific groups of values from pillar on the command line? How much have you looking into targets? Basically you should have a grain that matches specific machines and then match specific data via said grain in the pillar, then you get what you are looking for
If this is still an issue, could you create a new issue that distills the exact problems you're having or features you want? I think we've wandered a bit from the original issue, so it's hard to see at a glance what is needed.
Okay. Currently I'm busy with other tasks. But as soon as I have time to work out the details of the problem and an approach to solve it I will create a new issue.
Activity
thatch45 commentedon Apr 5, 2013
Since you have a match of a * for every environment, every system is being matched. This is also because the env value is passed only to state environments and not pillar environments
shintonik commentedon Apr 8, 2013
So that means it is intended behaviour? Maybe I misunderstood that whole concept of environments. To be honest I used enviroments more like a kind of vehicle for the solution I am aiming at. Basically, I'm looking for an option to provide Salt a dynamic render context.
That way I could define a generic state with a default value which can be overwritten with a dynamically injected pillar value. Since there is no option to pass such data dynamically to my state I tried to define those data structures in a static way in the form of an environment.
My concrete problem: I have already defined several states to setup my technology stack on a server. Now I have to setup that same stack with a slightly different set of configuration data (like username, checkout paths, web root etc.). I could duplicate all states and change the particular data but that is neither DRY nor does it scale if you have to do that more than 2 oder 3 times.
The following example describes my approach:
Pillar data
Generic git checkout state
Salt call with the option to pass the pillar root as an argument
salt * state.sls git.initial_checkouts -P users:user2thatch45 commentedon Apr 8, 2013
Yes, merging the environments is the intended behavior, the top file allows for the environments to be specified on the master. Settign dynamic values to states is done with pillar but I think you are just seeing it from the wrong direction. When setting up environments you need to specify which minions realize which environments:
This is assuming that you have divided up environments based on minion id, but grains or other target systems can also be used.
Finally in your last command in your last comment here I am confused, are you assuming that -P users:user2 only applies the user2 key in users? -P passes in extra data to the pillar, it does not have anything to do with matching existing data
shintonik commentedon Apr 9, 2013
Hi Thomas, sorry I was not very clear about my use of environments. I have only used them because Salt is lacking an option to pass in a dynamic render context. That's why I tried to realize that with environments. I thought of pillar environments as separarated "containers" that hold my data. But now I know that was wrong. So environments do not make sense as a solution for this problem.
In my last post I tried to describe the approach of a dynamic render context (without the use of environments). As I already said in my last post. I would like to write states that are as generic (a.k.a DRY) as possible and use them with different sets of data. In my case I have to setup the same specific technology stack on multiple servers as well as to setup that technology stack multiple times with slightly different configuration data on a single machine (e.g. one development environment per user on one machine).
At the moment there is only one way for me to do that. Replicate my state tree multiple times (with all disadvantages of such a non-DRY approach). With a dynamic render context I only would have to define another data structure to reuse my states.
The example of my last post describes exactly that. You define a generic state, a data structure (config data) and with the imaginary option -P (-p would probably be smarter because capitalized options seems to be used only to define an alternative way to target minions) you could pass in the root of the pillar data which is used by Salt as a render context. The state uses the data structure git:user, git:pass and git:rev and the -P option tells which node inside my pillar holds that data structure.
I hope this time the actual approach got more clear.
thatch45 commentedon Apr 10, 2013
So you just want to pass in the data that gives you specific groups of values from pillar on the command line? How much have you looking into targets? Basically you should have a grain that matches specific machines and then match specific data via said grain in the pillar, then you get what you are looking for
basepi commentedon May 28, 2013
@shintonik Did you get this resolved using grains as @thatch45 mentioned?
I'm going to close this one, as the original issue is expected behavior.
shintonik commentedon May 29, 2013
@basepi It was never really an issue. But rather a missing feature of the state system. Actually it has nothing to do with targets or grains.
I further described and discussed the problem/idea in the mailing list. Maybe a future version of Salt will come up with a solution.
basepi commentedon May 29, 2013
If this is still an issue, could you create a new issue that distills the exact problems you're having or features you want? I think we've wandered a bit from the original issue, so it's hard to see at a glance what is needed.
shintonik commentedon May 31, 2013
Okay. Currently I'm busy with other tasks. But as soon as I have time to work out the details of the problem and an approach to solve it I will create a new issue.