Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started with Salt

Getting Started with Salt

DjangoCon US 2013

Avatar for Peter Baumgartner

Peter Baumgartner

September 03, 2013
Tweet

More Decks by Peter Baumgartner

Other Decks in Technology

Transcript

  1. “SaltStack delivers a dynamic infrastructure communication bus used for orchestration,

    remote execution, configuration management and much more.”
  2. Deploy your code Run one-off scripts Critical package updates System

    monitoring/alerting https://github.com/lincolnloop/salmon Remote Execution Examples
  3. Chef: knife, recipe, cookbook Puppet: terminus, metaparameters Ansible: playbook, inventory

    Salt might be the worst offender... Everything is Terrible
  4. # apt-get install salt-minion # echo "salt 10.10.1.1" >> /etc/hosts

    # salt-key -a minion.lincolnloop.com Accept the minion key on the master Point minion to the master Minion
  5. # salt 'myserver.lincolnloop.com' state.highstate # salt-call state.highstate ...or pull from

    the minion Push from the master Highstate ...or master-less # salt-call state.highstate --local
  6. [INFO ] Executing state pkg.installed for nginx [INFO ] Executing

    command "dpkg-query --showformat='${Status} ${Package} $ {Version}\n' -W" in directory '/' [INFO ] Executing command 'grep-available -F Provides -s Package,Provides -e "^.+$"' in directory '/' [INFO ] Executing command 'apt-get -q update' in directory '/' [INFO ] Executing command 'apt-get -q -y -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-confdef install nginx' in directory '/' [INFO ] Executing command "dpkg-query --showformat='${Status} ${Package} $ {Version}\n' -W" in directory '/' [INFO ] Executing command 'grep-available -F Provides -s Package,Provides -e "^.+$"' in directory '/' [INFO ] Installed Packages: libgeoip1 changed from absent to 1.4.8+dfsg-2 nginx changed from absent to 1.1.19-1 libxml2 changed from absent to 2.7.8.dfsg-5.1ubuntu4 nginx-common changed from absent to 1.1.19-1 libfreetype6 changed from absent to 2.4.8-1ubuntu2 nginx-full changed from absent to 1.1.19-1 xml-core changed from absent to 0.13 geoip-database changed from absent to 20111220-1 libxslt1.1 changed from absent to 1.1.26-8ubuntu1 libjpeg-turbo8 changed from absent to 1.1.90+svn733-0ubuntu4 libgd2-noxpm changed from absent to 2.0.36~rc1~dfsg-6ubuntu2 sgml-base changed from absent to 1.26+nmu1ubuntu1 libjpeg8 changed from absent to 8c-2ubuntu7 ,,,
  7. [INFO ] Loading fresh modules for state activity local: ----------

    State: - pkg Name: nginx Function: installed Result: True Comment: The following packages were installed/updated: nginx. Changes: libgeoip1: { new : 1.4.8+dfsg-2 old : } nginx: { new : 1.1.19-1 old : } libxml2: { new : 2.7.8.dfsg-5.1ubuntu4 old : } nginx-common: { new : 1.1.19-1 old : } libfreetype6: { new : 2.4.8-1ubuntu2 old : } nginx-full: { new : 1.1.19-1 old : } ...
  8. pete: user.present: - shell: /bin/bash - home: /home/pete - groups:

    - sudo ssh_auth.present: - user: pete - source: salt://pete.pub - require: - user: pete Add an SSH Key
  9. Over 50 built-in pip, virtualenv mysql, postgres services, files, cron

    ...or build your own (in Python) Built-in States
  10. base: '*': - default '*.lincolnloop.com': - lincoln_loop 'os:Ubuntu': - match:

    grain - pkgs.ubuntu /srv/pillar/top.sls Advanced Pillar Top File
  11. /etc/redis.conf: file.managed: - template: jinja - source: salt://packages/redis_server/redis.conf.jinja - defaults:

    maxmemory: {{ pillar.get('redis_maxmemory', '64mb') }} Using Pillars in Files
  12. daemonize yes pidfile /var/run/redis.pid port 6379 bind 127.0.0.1 maxmemory {{

    maxmemory }} ... /srv/salt/redis_server/redis.conf.jinja Using Pillars in Files