5

My top.sls looks like this:

base:
  '*':
    - python
    - memcache
    - nbviewer
    - supervisor
    - firewall

I'm on SaltStack 0.17 and the python state doesn't get executed first. This results in later states failing.

Within the states themselves, they go in order but the top file doesn't.

What way should these states be organized?

Kyle Kelley
  • 13,804
  • 8
  • 49
  • 78
  • The top-file should be executed in the order it is defined by default starting in 0.17.0. If it's not, this is a bug and should be reported on Github. – Colton Myers Oct 14 '13 at 15:50
  • After setting up the salt environment again, this time using the dev branch of saltstack, I found the issue. The state for python and nbviewer both had a "packages:" section (conflicting IDs). This resulted in an error report on the dev branch but silent clobbering and failing on the latest release. – Kyle Kelley Oct 16 '13 at 13:43
  • This conflicting IDs problem you hit is *also* a bug, but it has been fixed, and that fix will be in the 0.17.1 release later today. =) – Colton Myers Oct 17 '13 at 16:56
  • Rad. It did at least show me what I had to fix in my own salt states and that each of those was an ID necessary to be unique across states. – Kyle Kelley Oct 17 '13 at 19:56
  • 2
    Weird, I think I just hit this in 0.17.5. Same symptoms: states executed out of the order defined in the top file, with no obvious error messages. Running again with `-l debug` showed "Detected conflicting IDs, SLS IDs need to be globally unique." - which wasn't reported the first time around. (The conflicting IDs were in my code.) – Steve Bennett Feb 15 '14 at 07:10
  • @SteveBennettㄹ how to find the salt version? `salt --version` shows `2016.2` – Avinash Raj Aug 07 '17 at 11:02

1 Answers1

1

The order shouldn't matter. Dependencies should be managed explicitly and SaltStack will take care of the rest. So if you needed python to install memcache (not true, but just an example), you could add this to memcache/init.sls:

 python:
   pkg:
     - installed
Chris
  • 11,819
  • 19
  • 91
  • 145
  • Sounds like I need to manage dependenices within each state file then, which means I can't have states rely on other states. My only issue here is that I want to install things like pip using the [get-pip](http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip) script, not the system packages. – Kyle Kelley Oct 13 '13 at 21:11
  • You can use the `include` syntax to include states from other sls files so you can require them explicitly. But really, with the new `state_auto_order` setting, you should be able to rely on auto ordering. As I mentioned above, those states executing out of order is a bug. – Colton Myers Oct 17 '13 at 16:58
  • But is it good practice to rely on ordering of states in top.sls? Doesn't it mean that the state files can no longer be run on their own (e.g. with `state.sls`), and can no longer be included multiple times in `top.sls` (because what comes before them may be different in each case)? – Peter Niederwieser Nov 27 '13 at 12:55