Provisioning Old Sys Admin Style Manual conf by hand QA test it and (sometimes) breaks it Writing all the doc to create the env again Forgot something? Fix it QA breaks it again Forgot something? Fix it QA breaks it again … 2 Why you need it
Provisisioning It saves time and money Reproducible environment Auto documented Easy scalable Easy to create Dev env like a Prod env Sharing a git repo is sharing the whole env One man can manage 100 servers (1/1200 at Google) 3 Why you need it
Provisioning Rules Use a strong naming convention (type-zone-provider-#-prod) Divide your servers by type Find common rules to all server Keep everything as generic as possible Prepare for multi zone and multi provider Small states 4 What you need
Saltastack Saltstack history The author: Thomas S. Hatch What needed to be fix: the slowness The solution: ØMQ ! Fast, modular, async Dependencies need to be specified explicitly 5 The revolution
Saltstack Targeting minion servers salt 'web[1-5]' test.ping salt ‘*-prod' test.ping base: 'web1-(prod|devel)': - match: pcre - nginx ! nodegroups: group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com' group2: 'G@os:Debian and foo.domain.com’ ! salt -N group1 test.ping ! G is globbing, L list of minions, S subnet, etc. 12 Targeting
Saltstack Runners and cli You can define your own commands or run common ones ! salt -L foo.bar.baz,quo.qux cmd.run ‘pgrep foo’ salt -G 'os:Ubuntu' test.ping salt '*' cmd.run 'echo "Hello: $FIRST_NAME"' env='{FIRST_NAME: "Joe"}' 13 Runners
Fabric Fabric Set of python libraries to run command remotely ! Parallel execution Remote terminal output Interactive remote shell Plain python 15 From bash to fabric
Fabric Fabric CLI ! $ fab -l ! Install and configure saltstack minion in a new fresh server! fab -H [email protected] install_salt! ! Available commands:! ! install_salt Usage install_salt:master=‘master.salt.hostname',name='...! ! ! Live Demo! 17 Option
Fabric Bash + Fabric + Salt = Power KISS: Use bash for script Use fabric for complex script with external software interaction, and for deploy Use Salt to provision ! Play with them, some example: Jenkins uses Fabric to deploy (legacy code) Jenkins uses Salt to deploy (new code) to staging 18 Bash + Fabric
Continous delivery The github workflow Develop locally (Vagrant) Solve the issue or implement a feature in a new branch Make a pull request Social review (we are humans, right?) Test it Merge if passes all the steps Deploy to staging automatically 19 Workflow
Continous delivery Con. delivery != Con. Deployment Use continuous deployment for staging env Use manual deploy for production env Monitor it Revert if everything is on fire Correlate deploy with metrics Use datadog, now, really! Demo! 20 Manual deploy?