The document summarizes the author's journey from using on-premise automation with shell scripting to using configuration management tools Chef and SaltStack. It outlines some of the challenges faced with shell scripting and Chef related to idempotence, cross-platform recipes, and lack of orchestration. The author found SaltStack improved on these areas with its use of states, pillars, grains, and modules which allowed for smarter formulas and automation of dynamic infrastructures on cloud providers. Examples are provided of using grains, pillars, peer communication, and Salt Mine to configure applications and services across minions in a declarative way.
4. 2010
AWS change my vision
Scalable infrastructures, automation, self-
provisioning
AWS was launched in 2006 and in 2007 180.000 developers had
signed up to use it
20. Salt foundations
States
Our system state
Pillars
Info from master to
minions
Grains
Info from minions to
master
Mines, Modules, Reactors, etc..
21. TOP.sls - What we have to do
base:
'*':
tools
'proxyeuaws*prod':
nginx
'webeuaws*prod':
webserver
webapp
'cacheeuaws*prod':
memcached
We need the top.slsfor states and pillars
24. Here is a pillar:
Jinja templates for your state files
Jinja templates for managed files
Pillars on the stage
app/init.sls
app:
path: /opt/app
branch: develop
remote: https://github.com/wdalmut/app.git
hostname: www.anhostname.tld
checkout_app:
git.latest:
name: {{ pillar['app']['remote'] }}
rev: {{ pillar['app']['branch'] }}
target: {{ pillar['app']['path'] }}
<VirtualHost *:80>
ServerName {{ pillar['app']['hostname'] }}
</VirtualHost>
25. Grains in your formulas
Super-smart recipes formulas
d
m {{ grains['mem_total'] * 3 / 4 }}
Memcached uses ¾ of available RAM
in your memcached config file memcached.conf
40. Manually scale-out
salt-cloud -Pp do-micro-ubuntu web-4 web-5 web-6
salt web-[4-6] state.highstate
salt proxy-* state.highstate
Thanks to mines we can add more resources and update proxies
adding more web servers
{% for srv, addrs in salt['mine.get'](
'role:web', 'network.ip_addrs', expr_form='grain').items() %}
server {{ srv }} {{ addrs[0] }}:80 check
{% endfor %}