saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.1k stars 5.47k forks source link

Multiple environments support documentation #6102

Closed ruimarinho closed 11 years ago

ruimarinho commented 11 years ago

As a new user to Salt, I have found the top file documentation to be a little confusing in terms of multiple environments best practices. I am submitting this issue in the spirit of improving documentation (if necessary).

Given this setup:

file_roots:
  base:
    - /srv/salt/base
  dev:
    - /srv/salt/dev
  qa:
    - /srv/salt/qa
  prod:
    - /srv/salt/prod

As far as I understood, a single top.sls file is generated from aggregating each file root. This means that each file root should include its own top.sls file. As such, the following files are expected:

base:
  '*':
    - global
dev:
  'webserver*dev*':
    - webserver
  'db*dev*':
    - db
qa:
  'webserver*qa*':
    - webserver
  'db*qa*':
    - db
prod:
  'webserver*prod*':
    - webserver
  'db*prod*':
    - db

Initially I thought this content should be placed inside a single top.sls under /srv/salt, but since it's not listed as a file root in this setup, it makes sense that Salt does not pick it up. Is this assumption correct?

Additionally, it would be very helpful to have a tree output next to each example. If anyone can contribute that, I would be truly thankful.

s0undt3ch commented 11 years ago

Please welcome this fellow Portuguese into the community.

There's 2 of us now!!!

Pedro Algarvio @ phone

----- Reply message ----- De: "Rui Marinho" notifications@github.com Para: "saltstack/salt" salt@noreply.github.com Assunto: [salt] Multiple environments support documentation (#6102) Data: qui, Jul 11, 2013 17:33 As a new user to Salt, I have found the top file documentation to be a little confusing in terms of multiple environments best practices. I am submitting this issue in the spirit of improving documentation (if necessary).

Given this setup:

file_roots: base:

As far as I understood, a single top.sls file is generated from aggregating each file root. This means that each file root should include its own top.sls file. As such, the following files are expected:

/srv/salt/base/top.sls base: '*':

/srv/salt/dev/top.sls dev: 'webserverdev':

/srv/salt/qa/top.sls qa: 'webserverqa':

/srv/salt/prod/top.sls prod: 'webserverprod':

Initially I thought this content should be placed inside a single top.sls under /srv/salt, but since it's not listed as a file root in this setup, it makes sense that Salt does not pick it up. Is this assumption correct?

Additionally, it would be very helpful to have a tree output next to each example. If anyone can contribute that, I would be truly thankful.

— Reply to this email directly or view it on GitHub.

basepi commented 11 years ago

You're right -- Salt will not look outside of your environments/file_roots for top.sls files. You're also right that Salt will aggregate a single top.sls file from all the definitions in all defined environments. So you can either do a single top.sls file in your base environment, or pepper them throughout as you've shown above.

You're right, the documentation should be improved a bit. =)

ruimarinho commented 11 years ago

@s0undt3ch I knew there had to be another fellow Portuguese on such praised community, eheh ;)

@basepi thanks for the feedback! It felt a little weird to place different environment globbings on the same top.sls file under base, that's why I opted for the separated locations. What is your opinion about configurations that add fall backs to different environments? I've found an interesting example gist here.

basepi commented 11 years ago

@ruimarinho I'm not sure I've ever seen that done, but I think it looks awesome! Basically when you reference a file in a state (or a state-file in a top.sls), it will just look through the defined roots for the environment in order. So just like @SEJeff says in that example, if you put a new version of a file in the dev directory, the dev environment will prioritize it over the production version in the base environment. Super useful. =)

s0undt3ch commented 11 years ago

@ruimarinho We're everywhere!

terminalmage commented 11 years ago

Done in #6331, closing.

joshelson commented 9 years ago

I know it's possibly bad form to comment on closed issues, but it doesn't look like one of the main points of this post has been addressed in documentation on the top file.

The documentation is still quite unclear that the top.sls needs to exist in all directories where multiple root definitions are employed. It would help to explicitly state that there needs to be a top.sls for each root, rather than the way the documentation reads today that implies you can still have one single top level file one level above the multiple root definition that will traverse subdirectories.

Trivial once understood, but for someone just learning, it's definitely a bit of as challenge.

rallytime commented 9 years ago

@joshelson It's not bad form and thank you for contributing your concerns here. However, since this issue is so old and has a more broad concern than your comment, would you mind opening a new issue explaining your thoughts? You have some great points here and we don't want to lose track of them. I think a more targeted issue would serve well.