Dynamic haproxy config in SaltStack

February 4, 2015   

If you are anything like me, you like to over utilize haproxy. Salt stack has a nice feature for files that allow you to add to them in different state files.

Say you want to have a stock haproxy config but sick and tired of having to maintain 5 different versions of a haproxy config.

So our basic formula layout looks like this

- packages/haproxy.sls
- web/init.sls

The haproxy.sls stores our basic haproxy install, template and makes sure the service is running

The web/init.sls is what we might apply to our app servers that want access to mysql and kafka.

So pretty much you have have as many of the file.accumulated states as you wish as long as they all have the same name unless you want to have multiple loops in your template. As long as you include the packages/haproxy.sls file in any other state file this will work.

comments powered by Disqus