Service Delivery Assembly Line with Vagrant, Packer, and Ansible

4,142 views
3,743 views

Published on

Leverage Packer, Vagrant, and Ansible as part of a service delivery pipeline. Streamline your continuous delivery process while also targeting multiple cloud providers.

Published in: Technology

Service Delivery Assembly Line with Vagrant, Packer, and Ansible

  1. 1. Building(a(Service(Delivery( Assembly(Line(with(Vagrant,( Packer,(and(Ansible( ( ( ( ( @ichristo( ichristoffersen@vizuri.com(
  2. 2. My new app is going to be the next big thing!
  3. 3. Linux, IaaS, AWS, Rackspace, VMWare, oVirt, Spacewalk, Cobbler, Puppet, Ansible, Chef, Kickstart, Seed Linux Administrators SAN Engineers Network Engineers DevOps ITOps Service Level Agreements Budgets Staffing Guidance Procurement Process Authority to Operate Auditing & Compliance Infrastructure My new app is going to be the next big thing!
  4. 4. Service Delivery : Provisioning the right set of resources required to support a set of activities in a timely manner
  5. 5. Service Delivery : Provisioning the right set of resources required to support a set of activities in a timely manner yesterday
  6. 6. Week$1$ Week$2$ Week$3$ Week$4$ Week$6$ Week$6$ Week$7$ Week$8$
  7. 7. Assembly line : a manufacturing process in which work moves from station to station until a final product is produced
  8. 8. Order Assemble Ship Get0Rich
  9. 9. But what about quality? Can we scale to meet demand?
  10. 10. Code Smell: A symptom in the source code that could indicate potential problems or weakness in the overall design
  11. 11. Example Code Smells: Duplicate Code Long Methods Large, Multi-line Classes Long Class Parameter Lists
  12. 12. Infrastructure Smell: A symptom in the system architecture that could indicate potential problems or fragility in the overall system
  13. 13. Infrastructure Smells: Gold Images Teetering Stacks Configuration Drift Infrastructure Atrophy
  14. 14. SMELL :: GOLD IMAGE
  15. 15. PRESCRIPTION :: Use Packer
  16. 16. Automatically create machine images for multiple platforms from a single blueprint
  17. 17. AWS: AMI VMware: VMX + disks VirtualBox: OVF + disks DigitalOcean: Snapshots and many more … http://www.packer.io/docs/templates/builders.html
  18. 18. Wait? Didn’t you say that ”gold” images were bad.
  19. 19. Packer brings all the benefits of ”gold” images without the baggage.
  20. 20. Automation No human interaction. Great for Continuous Integration / Deployment Standardization Use Puppet, Chef, Ansible, Bash to configure the image Repeatability Template goes into version control Image creation knowledge is now in code Anyone can build / rebuild the base images
  21. 21. EXAMPLE CentOS Image in both AWS & Digital Ocean
  22. 22. { "builders": [ { "type" : "amazon-ebs", "access_key" : "{{user `aws_access_key`}}", "secret_key" : "{{user `aws_secret_key`}}", "region" : "us-east-1", "source_ami" : "ami-8997afe0", "security_group_id" : "sg-8f7e24e4", "instance_type" : "t1.micro", "ssh_username" : "ec2-user", "ssh_timeout" : "5m", "ami_name" : "centos-baseline {{timestamp}}" }, …
  23. 23. … { "type" : "digitalocean", "api_key" : "{{user `do_api_key`}}", "client_id" : "{{user `do_client_id`}}", "image_id" : "562354", "snapshot_name" : "centos-baseline {{timestamp}}" } ] … }
  24. 24. $ packer validate base-image.json Template validated successfully. $ packer build base-image.json amazon-ebs output will be in this color. digitalocean output will be in this color. … ==> amazon-ebs: Deleting temporary keypair... Build 'amazon-ebs' finished. ==> digitalocean: Destroying droplet... ==> digitalocean: Deleting temporary ssh key... Build 'digitalocean' finished. ==> Builds finished. The artifacts of successful builds are: --> digitalocean: A snapshot was created: 'centos-baseline 1396457723' in region 'New York 1'
  25. 25. SMELL :: Teetering Stacks
  26. 26. + PRESCRIPTION
  27. 27. Mature, stable, proven. Development since Jan 2010. Used by thousands of companies.
  28. 28. Deploy to Multiple Providers AWS, DigitalOcean, HP Cloud, Joyent, KVM, libvirt, lxc, OpenStack, Rackspace, Vmware, VirtualBox vagrant up --provider=foo
  29. 29. •  Simplifies the provisioning process for servers. •  Easier to have an instance per systems component. •  Copy files to new images. (i.e. Keys, Scripts, RPMs) Workflow
  30. 30. www.vagrantbox.es
  31. 31. Leverage Your own Packer Images •  Base Image as starting point. •  Integrates with multiple “provisioners” – Puppet, Chef, Ansible, Bash
  32. 32. Automation No human interaction. Great for Continuous Delivery Standardization Can also use Puppet, Chef, Ansible, Bash Use Packer images as base images Repeatability Template goes into version control Image creation knowledge is now in code Anyone can build / rebuild the environment
  33. 33. EXAMPLE Multiple CentOS Images created in AWS from base AMI
  34. 34. Vagrant.configure("2") do |config| config.vm.box = "dummy" config.vm.box_url = "https://github.com/mitchellh/ vagrant-aws/raw/master/dummy.box" config.vm.provider :aws do |aws, override| aws.access_key_id = "YOUR KEY" aws.secret_access_key = "YOUR SECRET KEY" aws.keypair_name = "KEYPAIR NAME” aws.ami = ”ami-9baa9cf2” override.ssh.username = "ec2-user" override.ssh.forward_agent = true override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY" end end Vagrantfile
  35. 35. $ vagrant up --provider=aws Use `vagrant plugin` commands to manage plugins. This warning will be removed in the next version of Vagrant. Bringing machine 'test-broker' up with 'aws' provider... Bringing machine 'test-node-01' up with 'aws' provider... Bringing machine 'test-node-02' up with 'aws' provider… Running Vagrant
  36. 36. SMELL :: Configuration Drift
  37. 37. PRESCRIPTION
  38. 38. •  Configuration Management tool like Puppet, Chef, CFEngine •  Quick to get started •  Builds on familiar tools •  Run commands over SSH. No additional agents required
  39. 39. EXAMPLE Configure NTP on Multiple CentOS AWS Images
  40. 40. … config.vm.provision :ansible do |ansible| ansible.sudo = true ansible.playbook = "provisioning/ansible/playbook.yml” ansible.verbose = true end - hosts: all tasks: - name: ensure ntpd is at the latest version yum: pkg=ntp state=latest notify: - restart ntpd handlers: - name: restart ntpd service: name=ntpd state=restarted
  41. 41. $ vagrant provision Use `vagrant plugin` commands to manage plugins. This warning will be removed in the next version of Vagrant. Bringing machine 'test-broker' up with 'aws' provider... Bringing machine 'test-node-01' up with 'aws' provider... Bringing machine 'test-node-02' up with 'aws' provider... WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.1 Installing a LAMP Stack on CentOS
  42. 42. EXAMPLE Provision a CentOS LAMP Stack in AWS
  43. 43. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| boxes.each do |box| config.vm.define box[:name], primary: box[:primary] do |config| config.vm.box = "aws-centos" config.vm.box_url = https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box … config.vm.provision :shell, :privileged => false, :inline => "sudo yum -y install screen" config.vm.provision :ansible do |ansible| ansible.sudo = true ansible.playbook = "provisioning/ansible/playbook- lamp.yml" ansible.verbose = true end …
  44. 44. - name : Install LAMP Stack user: ec2-user hosts: all tasks: - name: Install mysql yum: name=mysql-server state=latest - name: install httpd yum: name=httpd - name: Install php for mysql yum: name=$item with_items: - php - php-mysql - mysql-server
  45. 45. $ vagrant up --provider=aws Use `vagrant plugin` commands to manage plugins. This warning will be removed in the next version of Vagrant. Bringing machine 'test-broker' up with 'aws' provider... Bringing machine 'test-node-01' up with 'aws' provider... Bringing machine 'test-node-02' up with 'aws' provider... WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.1 $ vagrant provision
  46. 46. vagrantup.com packer.io ansible.com Thank you

×