service delivery assembly line with vagrant, packer, and ansible

54
Building a Service Delivery Assembly Line with Vagrant, Packer, and Ansible @ichristo ichristoff[email protected]

Upload: isaac-christoffersen

Post on 06-May-2015

2.237 views

Category:

Technology


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Building(a(Service(Delivery(Assembly(Line(with(Vagrant,(

Packer,(and(Ansible( ((((

@ichristo([email protected](

Page 2: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

My new app is going to be the next big thing!

Page 3: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

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!

Page 4: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Service Delivery : Provisioning the right set of resources required to support a set of activities in a timely manner

Page 5: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Service Delivery : Provisioning the right set of resources required to support a set of activities in a timely manner yesterday

Page 6: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 7: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Week$1$ Week$2$ Week$3$ Week$4$ Week$6$ Week$6$ Week$7$ Week$8$

Page 8: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 9: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 10: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 11: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 12: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 13: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Assembly line : a manufacturing process in which work moves from station to station until a final product is produced

Page 14: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Order

Assemble

Ship Get0Rich

Page 15: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

But what about quality? Can we scale to meet demand?

Page 16: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 17: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Code Smell: A symptom in the source code that could indicate potential problems or weakness in the overall design

Page 18: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Example Code Smells: Duplicate Code Long Methods Large, Multi-line Classes Long Class Parameter Lists

Page 19: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Infrastructure Smell: A symptom in the system architecture that could indicate potential problems or fragility in the overall system

Page 20: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Infrastructure Smells: Gold Images Teetering Stacks Configuration Drift Infrastructure Atrophy

Page 21: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

SMELL :: GOLD IMAGE

Page 22: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

PRESCRIPTION :: Use Packer

Page 23: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Automatically create machine images for multiple platforms from a single blueprint

Page 24: Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Page 25: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

AWS: AMI VMware: VMX + disks VirtualBox: OVF + disks DigitalOcean: Snapshots and many more …

http://www.packer.io/docs/templates/builders.html

Page 26: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Wait? Didn’t you say that ”gold” images were bad.

Page 27: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Packer brings all the benefits of ”gold” images without the baggage.

Page 28: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

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

Page 29: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

EXAMPLE CentOS Image in both AWS &

Digital Ocean

Page 30: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

{ "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}}" }, …

Page 31: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

… { "type" : "digitalocean", "api_key" : "{{user `do_api_key`}}", "client_id" : "{{user `do_client_id`}}", "image_id" : "562354", "snapshot_name" : "centos-baseline {{timestamp}}" }

] … }

Page 32: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

$ 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'

Page 33: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

SMELL :: Teetering Stacks

Page 34: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

+

PRESCRIPTION

Page 35: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Mature, stable, proven. Development since Jan 2010. Used by thousands of companies.

Page 36: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Deploy to Multiple Providers

AWS, DigitalOcean, HP Cloud, Joyent, KVM, libvirt, lxc, OpenStack, Rackspace, Vmware, VirtualBox

vagrant up --provider=foo

Page 37: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

•  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

Page 38: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

www.vagrantbox.es

Page 39: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

Leverage Your own Packer Images

•  Base Image as starting point. •  Integrates with multiple

“provisioners” – Puppet, Chef, Ansible, Bash

Page 40: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

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

Page 41: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

EXAMPLE Multiple CentOS Images

created in AWS from base AMI

Page 42: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

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

Page 43: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

$ 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

Page 44: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

SMELL :: Configuration Drift

Page 45: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

PRESCRIPTION

Page 46: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

•  Configuration Management tool like Puppet, Chef, CFEngine

•  Quick to get started •  Builds on familiar tools •  Run commands over SSH. No

additional agents required

Page 47: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

EXAMPLE Configure NTP on Multiple

CentOS AWS Images

Page 48: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

… 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

Page 49: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

$ 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

Page 50: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

EXAMPLE Provision a CentOS LAMP

Stack in AWS

Page 51: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

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 …

Page 52: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

- 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

Page 53: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

$ 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

Page 54: Service Delivery Assembly Line with Vagrant, Packer, and Ansible

vagrantup.com packer.io ansible.com

Thank you