APPLICATION DEPLOYMENT USING ANSIBLECliffano Subagio | @cliffano | Sensis
/me> Continuous Integration/Deployment/Delivery> Most important lesson: Never ever write a deployment framework in Ant!
/project> Micro-services architecture> 15 applications> 2 data centers> 2 x 10 app servers> 2 x 3 db servers> Hundreds of deployments to date
ansible> Orchestration + automation engine> Application deployment> System provisioning
why ansible> Push via SSH> No agents on remote systems> Readable playbook> Tasks executed in order> Built-in + custom modules> Community growth
sample usageansible-playbook --inventory-file=hosts.ini --module-path=path/to/custom-modules --extra-vars=”ENV=test VERSION=1.2.3” --tags ci -u username --verbose app-playbook.yml
sample inventory file[foo-dev]devhost1.some.domain.com
[foo-test]testhost1.some.domain.comtesthost2.some.domain.com
[bar-test]testhost1.some.domain.com
sample playbook- hosts: foo-$ENV vars: BASE=/app/ tasks: - name: Send artifact file to remote system copy: src=foo-$VERSION.tar.gz dest=$BASE/builds tags: - ci
separation of concerns> Playbook defines how to deploy an app> Inventory file defines where to deploy those apps
artifacts
app1playbook.yml
app2playbook.yml
app3playbook.yml
app4playbook.yml
app5playbook.yml
app6playbook.yml
projectinventoryfilepackage.json
> Avoid monolithic deployment configuration
deployment flow
artifact-repoapp6-0.0.3.tar.gz
jenkins
deploy-server
devsource-repo
test
stage
prodrelease-repoproject-2.3.4.tar.gz
custom module> Usage: cleanbuilds dir=/app/foo/builds/ keep=5 > Keeps the last N builds> Controls disk usage> Written in python
gnu parallel> Improve deployment time> (echo app1 && echo app2) | parallel ansible-playbook ...> Grouping and ordering of stdout & stderr> Optimised to available CPU cores
what’s next
> Write more common Ansible modules> ControlMaster, 0mq> AnsibleWorks AWX
AWX
conclusions> Ansible really works (no pun intended)> Modules encourage reusability> I’m not writing a deployment framework> Collaboration between dev, devops, ops teams
questions + discussion
slide notes> http://www.ansibleworks.com/> http://www.ansibleworks.com/docs/modules.html> http://jpmens.net/2012/10/01/dramatically-speeding-up-ansible-runs/> http://www.gnu.org/software/parallel> http://ant.apache.org> http://jenkins-ci.org