service delivery assembly line with vagrant, packer, and ansible

Post on 06-May-2015

2.237 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

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

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

Packer,(and(Ansible( ((((

@ichristo(ichristoffersen@vizuri.com(

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

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!

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

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

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

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

Order

Assemble

Ship Get0Rich

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

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

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

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

Infrastructure Smells: Gold Images Teetering Stacks Configuration Drift Infrastructure Atrophy

SMELL :: GOLD IMAGE

PRESCRIPTION :: Use Packer

Automatically create machine images for multiple platforms from a single blueprint

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

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

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

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

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

EXAMPLE CentOS Image in both AWS &

Digital Ocean

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

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

] … }

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

SMELL :: Teetering Stacks

+

PRESCRIPTION

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

Deploy to Multiple Providers

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

vagrant up --provider=foo

•  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

www.vagrantbox.es

Leverage Your own Packer Images

•  Base Image as starting point. •  Integrates with multiple

“provisioners” – Puppet, Chef, Ansible, Bash

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

EXAMPLE Multiple CentOS Images

created in AWS from base AMI

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

$ 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

SMELL :: Configuration Drift

PRESCRIPTION

•  Configuration Management tool like Puppet, Chef, CFEngine

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

additional agents required

EXAMPLE Configure NTP on Multiple

CentOS AWS Images

… 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

$ 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

EXAMPLE Provision a CentOS LAMP

Stack in AWS

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 …

- 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

$ 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

vagrantup.com packer.io ansible.com

Thank you

top related