SlideShare a Scribd company logo
salt-stack
Jose Ignacio Galarza
@igalarzab
Index
Why it’s so cool?
How to use it?
Developing for salt-stack
python
+
devops
salt-stack
infrastructure
management
Salt stack
master
not a polling model,

PUSHING
instructions

send
to
the minions telling them what to do
PUB/SUB system on 4505
REP system on 4506
awesome diagram
master

SUB

minion

PUB

minion

REP

minion
MessagePack to
serialize the messages
everything is

encrypted
it uses first public
authentication

keys

for

master needs to know public keys of
the minions
then, it uses

AES for communication
* (symmetric, faster)
how to accept minion keys?
$ salt-key	

Unaccepted Keys:	

minion_1	

!

$ salt-key -a minion_1
let’s go!
$	

salt ‘*’ test.ping
!
!
!

minion_1:	

True
minions
controlled machines
receive instructions
via
PUB/SUB ZeroMQ
masterless
configuration
* (salt-call)
modules
they provide the

functionality
S3
pip

apt

ssh
iptables

pam

nginx
apache

aliases
mysql

mount
file
upstart

quota
execute them with the cli!
$ salt ‘*’ cmd.run ‘ls /’	

...
$ salt ‘*’ state.highstate	

...
states
manage or
configure in your
hosts

what to
salt-stack states are just
DATA
* usually in YAML
they usually map to module
functions
understanding states
!
!
!
!
!
!
!
!
!

/etc/init/nginx.conf:
file:
- managed
- template: jinja
- user: root
- require:
- pkg: nginx
nginx:	

  pkg.installed:	

    - name: nginx	

  file:	

    - managed	

    - name: /etc/init/nginx.conf	

    - source: salt://nginx.conf	

    - require:	

      - pkg: nginx	

service:	

    - running	

    - enable: True	

- watch:	

      - file: /etc/nginx/nginx.conf
there are a lot of directives
require

watch

extend

include
returners
save the
minion output
where to
mongo
stdout
redis
SQL DB
renderers
language of the state
configuration
YAML
python
JSON
...
grains
configuration of the
machine
* read-only data
** populated at the beginning
using grains...
{% if grains['os'] == 'RedHat' %}	

httpd:	

pkg:	

- installed	

{% elif grains['os'] == 'Debian' %}	

apache2:	

pkg:	

- installed	

{% endif %}
list the grains
$ salt ‘*’ grains.ls	

...

you can use them everywhere
dev:	

‘os:Debian’:	

- match: grain	

- python_server
pillar
think of pillar as a

variable container
it’s data,
just as same as the states
create a pillar of salt...
{% if grains['os'] == 'RedHat' %}	

apache: httpd	

git: git	

{% elif grains['os'] == 'Debian' %}	

apache: apache2	

git: git-core	

{% endif %}
and use it!
apache:	

pkg:	

- installed	

- name: {{ pillar['apache'] }}
only salt-stack?
salt-bootstrap
salt-cloud
salt-vagrant
halite
developing for
salt-stack
developing
modules
it’s like developing a normal
python module!
just create a file inside the _modules dir
every callable is
exported*
* (with some exceptions)
creating a module (for the pip-tools package)
import re!
!
import salt.utils!
from salt.utils.decorators import memoize!
!
REVIEW_RE = re.compile(‘([wd_-]+)==([d.]+) is available (you have ([d.]+))’)!
!
!
@memoize!
def _detect_install():!
return salt.utils.which('pip-review')!
!
!
def __virtual__():!
return 'piputils' if _detect_install() else False!
creating a module (for the pip-tools package)
!
def review(autoinstall=False):!
command_ret = __salt__['cmd.run'](!
'pip-review {0}'.format('-a' if autoinstall else '')!
)!
!
packages = command_ret.split('n')!
updates = {}!
!
for package in packages:!
match = REVIEW_RE.match(package)!
if match:!
name, old_v, new_v = match.groups()!
updates[name] = (old_v, new_v)!
!
return updates!
syncing the modules
$ salt-call saltutil.sync_modules	

...

and use it!
$ salt-call piptools.review	

machine:	

----------	

Jinja2:	

- 2.7.1	

- 2.6
useful variables like:

__salt__
__grains__
__outputter__
developing
states
it’s (also) like developing a
normal python module!
just create a file inside the _states dir
every callable is
exported*
* (with some exceptions)
the renderer structure

maps directly
to the state python module
creating a state (for the pip-tools package)
def keep_updated(name, min_version=None, max_version=None):!
updatable_packages = __salt__['piptools.review']()!
pkg_info = updatable_packages.get(name, None)!
!

ret = {!
'name': name,!
'result': pkg_info is not None,!
}!
creating a state (for the pip-tools package)
!
if package_info:!
ret['comment'] = 'Update {0} from {2} to {1}'.format(!
name, *pkg_info!
)!
ret['changes'] = {!
      
  name: {!
'old': package_info[1],!
'new': package_info[0]!
}!
}!
else:!
ret['comment'] = 'Inexistent package {0}'.format(name)!
!
if __opts__['test']:!
ret['result'] = None!
    else:!
pass # Perform the update!
!
return ret!
mapping the file
!

Jinja2:
pip_package:
- keep_updated
- min_version: 1.0

#
#
#
#

maps
maps
maps
maps

to
to
to
to

"name" argument	
pip_package state	
keep_updated funct	
min_version arg
and that’s all!
http://twitter.com/igalarzab
http://github.com/igalarzab
questions?
thank you!

More Related Content

PPTX
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
ODP
Linuxday.at - Lightning Talk
PPT
Apache
DOCX
Lamp configuration u buntu 10.04
PDF
톰캣 #04-환경설정
PDF
Nagios nrpe
PDF
Software-defined Datacenter Maintenance - No More Sleepless Nights and Long W...
PDF
Conhecendo o Vagrant
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Linuxday.at - Lightning Talk
Apache
Lamp configuration u buntu 10.04
톰캣 #04-환경설정
Nagios nrpe
Software-defined Datacenter Maintenance - No More Sleepless Nights and Long W...
Conhecendo o Vagrant

What's hot (20)

PDF
NSClient Workshop: 04 Protocols
KEY
/etc/rc.d配下とかのリーディング勉強会
PDF
Intelligent infrastructure with SaltStack
KEY
Ruby 1.9 And Rails 3.0
PDF
Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...
PDF
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
ODP
Elastic search
PDF
PPTX
Oracle RDBMS Workshop (Part1)
PDF
OSCamp #4 on Foreman | Salted Foreman by Bernhard Suttner
PDF
DNF Failed To Open Cache
PPT
Newgenlib Installation on Ubuntu 12.04
PDF
Services: Web Webmail Proxy
PDF
Spider Setup with AWS/sandbox
PDF
Fun with Ruby and Cocoa
PDF
Sweetening Systems Management with Salt
ODP
Monitoring at/with SUSE 2015
PDF
RAFT Consensus Algorithm
PDF
Open erp on ubuntu
NSClient Workshop: 04 Protocols
/etc/rc.d配下とかのリーディング勉強会
Intelligent infrastructure with SaltStack
Ruby 1.9 And Rails 3.0
Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Elastic search
Oracle RDBMS Workshop (Part1)
OSCamp #4 on Foreman | Salted Foreman by Bernhard Suttner
DNF Failed To Open Cache
Newgenlib Installation on Ubuntu 12.04
Services: Web Webmail Proxy
Spider Setup with AWS/sandbox
Fun with Ruby and Cocoa
Sweetening Systems Management with Salt
Monitoring at/with SUSE 2015
RAFT Consensus Algorithm
Open erp on ubuntu
Ad

Similar to Salt stack (20)

PDF
Introduction to Systems Management with SaltStack
PDF
Understanding salt modular sub-systems and customization
PDF
Salt Stack - Subhankar Sengupta
ODP
Configuration Management and Salt
PDF
A user's perspective on SaltStack and other configuration management tools
PPTX
Writing Custom Saltstack Execution Modules
PDF
Introduction to SaltStack (An Event-Based Configuration Management)
PDF
OpenWest 2014-05-10 Where's the Waldo, SaltStack Proxy Minions
PDF
Saltstack for Ansible users
PDF
Event driven architecture with SaltStack
PDF
Saltcheck: a tool in the salt toolbox
PDF
SaltStack
PDF
SaltStack – (Not) just another Automation & Remote Execution Tool
PDF
Why SaltStack ?
PDF
Configuration management and orchestration with Salt
PDF
Introduction to SaltStack
PPTX
SaltStack Configuration Management
PPTX
Salty OPS – Saltstack Introduction
PPTX
SaltStack Advanced Concepts
PDF
Real-time Cloud Management with SaltStack
Introduction to Systems Management with SaltStack
Understanding salt modular sub-systems and customization
Salt Stack - Subhankar Sengupta
Configuration Management and Salt
A user's perspective on SaltStack and other configuration management tools
Writing Custom Saltstack Execution Modules
Introduction to SaltStack (An Event-Based Configuration Management)
OpenWest 2014-05-10 Where's the Waldo, SaltStack Proxy Minions
Saltstack for Ansible users
Event driven architecture with SaltStack
Saltcheck: a tool in the salt toolbox
SaltStack
SaltStack – (Not) just another Automation & Remote Execution Tool
Why SaltStack ?
Configuration management and orchestration with Salt
Introduction to SaltStack
SaltStack Configuration Management
Salty OPS – Saltstack Introduction
SaltStack Advanced Concepts
Real-time Cloud Management with SaltStack
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Mushroom cultivation and it's methods.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
August Patch Tuesday
PDF
Approach and Philosophy of On baking technology
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
1. Introduction to Computer Programming.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
WOOl fibre morphology and structure.pdf for textiles
NewMind AI Weekly Chronicles - August'25-Week II
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Tartificialntelligence_presentation.pptx
DP Operators-handbook-extract for the Mautical Institute
Mushroom cultivation and it's methods.pdf
Enhancing emotion recognition model for a student engagement use case through...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
SOPHOS-XG Firewall Administrator PPT.pptx
Hindi spoken digit analysis for native and non-native speakers
August Patch Tuesday
Approach and Philosophy of On baking technology
Web App vs Mobile App What Should You Build First.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
1. Introduction to Computer Programming.pptx

Salt stack