CHEF IN THE CLOUD AND ON THE GROUND



Similar documents
1 Keystone OpenStack Identity Service

IBM Cloud Manager with OpenStack

rackspace.com/cloud/private

Continuous Delivery for Alfresco Solutions. Satisfied customers and happy developers with!! Continuous Delivery!

Chef Patterns at Bloomberg Scale HADOOP INFRASTRUCTURE TEAM. Freenode: #chef-bach

Platform as a Service and Container Clouds

Opsview in the Cloud. Monitoring with Amazon Web Services. Opsview Technical Overview

Chef Integration. Chef Integration. with IDERA s Uptime Cloud Monitor. Simple, Smart, Seamless May 10, 2013 IDERA

Jenkins and Chef Infrastructure CI and Application Deployment

NCTA Cloud Operations

Simple and powerful site deployment with capistrano

Our Puppet Story. Martin Schütte. May

Installing an open source version of MateCat

Managing Multi-Tiered Applications with AWS OpsWorks

Zend Server Amazon AMI Quick Start Guide

Advantages and Disadvantages of Application Network Marketing Systems

Deploy XenApp 7.5 and 7.6 and XenDesktop 7.5 and 7.6 with Amazon VPC

The Puppet Show Managing Servers with Puppet

Building a big IaaS cloud with Apache CloudStack

Cloud-init. Marc Skinner - Principal Solutions Architect Michael Heldebrant - Solutions Architect Red Hat

ArcGIS for Server in the Amazon Cloud. Michele Lundeen Esri

ArcGIS 10.3 Server on Amazon Web Services

İşbaran Akçayır

Drupal CMS for marketing sites

Ansible. Configuration management tool and ad hoc solution. Marcel Nijenhof

How To Set Up Wiremock In Anhtml.Com On A Testnet On A Linux Server On A Microsoft Powerbook 2.5 (Powerbook) On A Powerbook 1.5 On A Macbook 2 (Powerbooks)

Timofey Turenko. Kirill Krinkin St-Petersburg Electrotechnical University

SOA Software API Gateway Appliance 7.1.x Administration Guide

Virtualization and Cloud: Orchestration, Automation, and Security Gaps

CDH installation & Application Test Report

Git - Working with Remote Repositories

Chapter 9 PUBLIC CLOUD LABORATORY. Sucha Smanchat, PhD. Faculty of Information Technology. King Mongkut s University of Technology North Bangkok

Building a Private Cloud Cloud Infrastructure Using Opensource

Git Fusion Guide August 2015 Update

Servers. Servers. NAT Public Subnet: /20. Internet Gateway. VPC Gateway VPC: /16

How Bigtop Leveraged Docker for Build Automation and One-Click Hadoop Provisioning

Using Dedicated Servers from the game

Continuous Delivery on AWS. Version 1.0 DO NOT DISTRIBUTE

ALERT installation setup

Our Puppet Story Patterns and Learnings

GeoCloud Project Report GEOSS Clearinghouse

Single Node Hadoop Cluster Setup

Integrating SAP BusinessObjects with Hadoop. Using a multi-node Hadoop Cluster

Online Backup Guide for the Amazon Cloud: How to Setup your Online Backup Service using Vembu StoreGrid Backup Virtual Appliance on the Amazon Cloud

Amazon Elastic Beanstalk

Smartphone Pentest Framework v0.1. User Guide

Installation of PHP, MariaDB, and Apache

Deep Dive: Infrastructure as Code

SUSE Cloud Installation: Best Practices Using an Existing SMT and KVM Environment

Ruby on Rails (Ruby 1.9.2, Rails 3.1.1) Installation

Cloud.com CloudStack Community Edition 2.1 Beta Installation Guide

DevOoops Increase awareness around DevOps infra security. Gianluca

How To Install Storegrid Server On Linux On A Microsoft Ubuntu 7.5 (Amd64) Or Ubuntu (Amd86) (Amd77) (Orchestra) (For Ubuntu) (Permanent) (Powerpoint

Comsol Multiphysics. Running COMSOL on the Amazon Cloud. VERSION 4.3b

Deployment of Private, Hybrid & Public Clouds with OpenNebula

Product Manual. MDM On Premise Installation Version 8.1. Last Updated: 06/07/15

CycleServer Grid Engine Support Install Guide. version 1.25

Log Analyzer Reference

OS Installation: CentOS 5.8

Source Code Management for Continuous Integration and Deployment. Version 1.0 DO NOT DISTRIBUTE

Implementing Microsoft Windows Server Failover Clustering (WSFC) and SQL Server 2012 AlwaysOn Availability Groups in the AWS Cloud

Mobile Device Management Version 8. Last updated:

Upgrading a Single Node Cisco UCS Director Express, page 2. Supported Upgrade Paths to Cisco UCS Director Express for Big Data, Release 2.

OpenShift on you own cloud. Troy Dawson OpenShift Engineer, Red Hat November 1, 2013

Postgres on OpenStack

Alfresco Enterprise on AWS: Reference Architecture

RingStor User Manual. Version 2.1 Last Update on September 17th, RingStor, Inc. 197 Route 18 South, Ste 3000 East Brunswick, NJ

Best Practices for Python in the Cloud: Lessons

Continuous Integration using Docker & Jenkins

Introduction to Cloud Computing

System Administration Training Guide. S100 Installation and Site Management

Secure your Docker images

depl Documentation Release depl contributors

IceWarp Server. Log Analyzer. Version 10

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

OnCommand Performance Manager 1.1

CTERA Agent for Linux

EZcast technical documentation

CommandCenter Secure Gateway

Backup and Recovery of SAP Systems on Windows / SQL Server

DevShop. Drupal Infrastructure in a Box. Jon Pugh CEO, Founder ThinkDrop Consulting Brooklyn NY

Tools and Integration

Configuration Worksheets for Oracle WebCenter Ensemble 10.3

Automated Configuration of Open Stack Instances at Boot Time

Parallels Plesk Automation

Getting Started with the CLI and APIs using Cisco Openstack Private Cloud

ABRAHAM ARCHITECTURE OF A CLOUD SERVICE USING PYTHON TECHNOLOGIES

VMware Identity Manager Connector Installation and Configuration

D5.4.4 Integrated SemaGrow Stack API components

How To Backup In Cisco Uk Central And Cisco Cusd (Cisco) Cusm (Custodian) (Cusd) (Uk) (Usd).Com) (Ucs) (Cyse

salsadpi: a dynamic provisioning interface for IaaS cloud

Configuring an Alternative Database for SAS Web Infrastructure Platform Services

Alert Notification of Critical Results (ANCR) Public Domain Deployment Instructions

Cloud Computing For Bioinformatics. EC2 and AMIs

Chef for OpenStack. Matt Ray Southern California Linux Expo February 22, 2014

Quick Start Guide for VMware and Windows 7

Every Silver Lining Has a Vault in the Cloud

Tcl and Cloud Computing Automation

Transcription:

CHEF IN THE CLOUD AND ON THE GROUND Michael T. Nygard Relevance michael.nygard@thinkrelevance.com @mtnygard

Infrastructure As Code

Infrastructure As Code Chef

Infrastructure As Code Chef Development Models

Infrastructure As Code Chef Development Models Deployment Models

Infrastructure As Code

Infrastructure As Code Problems beget solutions. Solutions become the next problems.

What if we could version control our servers and network, the? way we do with code

Infrastructure as Code

Infrastructure as Code

Infrastructure as Code Desired state

Infrastructure as Code Desired state Transformations to achieve it

Infrastructure as Code Desired state Transformations to achieve it As text files

Infrastructure as Code Desired state Transformations to achieve it As text files In version control

Infrastructure as Code Desired state Transformations to achieve it As text files In version control Testable and reproducible

Chef Basics Cookbook Cookbook metadata 1..* * * * * Recipe Attribute Template Resource Provider Library * * Resource Ruby Source

Chef Basics

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Chef Basics Cookbook Recipe Attribute Template Library Resource Provider Container for semantically related recipes and their support files. Resource definitions, written as Ruby code Parameter used in recipes, can be supplied by cookbook defaults, the node, or the role ERB file that gets expanded onto the target host, used by resources in recipes Extra Ruby code, can create classes, resources, implement actions, etc. Lightweight Ruby DSL for creating new resources.

Cookbook: Git git metadata.json metadata.rb README.rdoc recipes default.rb server.rb templates default sv-git-daemon-log-run.erb sv-git-daemon-run.erb

metadata.rb maintainer "Opscode, Inc." maintainer_email "cookbooks@opscode.com" license "Apache 2.0" description "Installs git and/or set " long_description IO.read(File.join( File.dirname( FILE ), 'README.rdoc')) version "0.9.0" recipe "git", "Installs git" recipe "git::server", "Sets up a runit_service for git daemon" cont

metadata.rb %w{ ubuntu debian arch}.each do os end supports os %w{ runit }.each do cb end depends cb

recipes/default.rb case node[:platform] when "debian", "ubuntu" package "git-core" else package "git" end

include_recipe "git" recipes/server.rb directory "/srv/git" do owner "root" group "root" mode 0755 end cont

recipes/server.rb case node[:platform] when "debian", "ubuntu" include_recipe "runit" runit_service "git-daemon" else log "Platform requires setting up " log "Hint: /usr/bin/git daemon --export " end

Cookbook: MySQL mysql attributes server.rb libraries database.rb helpers.rb metadata.json metadata.rb providers database.rb README.md recipes client.rb default.rb server_ec2.rb server.rb resources database.rb templates default debian.cnf.erb grants.sql.erb my.cnf.erb mysql-server.seed.erb port_mysql.erb

templates/default/debian.cnf.erb [client] host = localhost user = debian-sys-maint password = <%= node['mysql']['server_debian_password'] %> socket = <%= node['mysql']['socket'] %> [mysql_upgrade] host = localhost user = debian-sys-maint password = <%= node['mysql']['server_debian_password'] %> socket = <%= node['mysql']['socket'] %> basedir = /usr

resources/database.rb actions :flush_tables_with_read_lock, :unflush_tables, :create_db, :query attribute :host, :kind_of => String attribute :username, :kind_of => String attribute :password, :kind_of => String attribute :database, :kind_of => String attribute :sql, :kind_of => String attribute :exists, :default => false

Using the Custom Resource # In cookbooks/stratego/recipes/default.rb include_recipe "mysql::client" mysql_database "reporting database" do host "db01prod" username "root" password node[:mysql][:server_root_password] database "reporting_production" action :create_db end

providers/database.rb include Opscode::Mysql::Database action :create_db do unless exists? begin Chef::Log.info "mysql_database: Creating databa " db.query("create database #{new_resource.database}") new_resource.updated_by_last_action(true) ensure db.close end end end

How do cookbooks get applied to servers?

Runlist Executes On Node Runlist Recipe or Role includes includes Recipe Role declares overrides Resource uses Attribute

Example Runlist (from a role file) name "dev_env_bamboo" description "Continuous Integration server" run_list "recipe[aws]", "recipe[xfs]", "recipe[bamboo]", "recipe[bamboo::crowd_authentication]", "recipe[bamboo::ebs_volume]", "recipe[build_dependencies]", "recipe[maven]", "recipe[maven3]", "recipe[bamboo::post_maven_bamboo]", "recipe[bamboo::start]", "recipe[iptables::ci_instance]"

Bamboo has a one time, setup wizard in the admin GUI.? How do you automate that

Recreate the results, not the process.

Recreate the results, not the process.

Recreate the results, not the process. 1. Install once by hand, stop before setup wizard.

Recreate the results, not the process. 1. Install once by hand, stop before setup wizard. 2. Make a tarball.

Recreate the results, not the process. 1. Install once by hand, stop before setup wizard. 2. Make a tarball. 3. Go through setup wizard.

Recreate the results, not the process. 1. Install once by hand, stop before setup wizard. 2. Make a tarball. 3. Go through setup wizard. 4. Compare resulting files with snapshot.

Recreate the results, not the process. 1. Install once by hand, stop before setup wizard. 2. Make a tarball. 3. Go through setup wizard. 4. Compare resulting files with snapshot. 5. Build a template to replicate the outcome.

Where do you keep installation binaries?

Control, integrity, efficiency

Control, integrity, efficiency

Control, integrity, efficiency 1. Your VCS may hate binaries.

Control, integrity, efficiency 1. Your VCS may hate binaries. 2. S3 worked for us. Private maven repo also works well.

Control, integrity, efficiency 1. Your VCS may hate binaries. 2. S3 worked for us. Private maven repo also works well. 3. Vendor download might also work, but beware slipstreaming.

Remote file resource remote_file "crowd" do path "/tmp/crowd.tar.gz" source "http://downloads.atlassian.com/ / atlassian-crowd-2.3.3.tar.gz" checksum "dcc486625e96925 " end

Have a sandbox!

Where do I find cookbooks?

Many available on github cookbooks.opscode.com

Download at the Shell $ knife cookbook site download postgresql Downloading postgresql from the cookbooks site Cookbook saved: /Users/mtnygard/cookbooks/postgresql $ tar xvzf postgresql-0.11.1.tar.gz x postgresql/ x postgresql/attributes/ x postgresql/metadata.json x postgresql/metadata.rb x postgresql/readme.rdoc x postgresql/recipes/ x postgresql/templates/ x postgresql/templates/default/ x postgresql/templates/default/debian.pg_hba.conf.erb

One other cool knife trick $ gem install knife-ec2 Fetching: excon-0.6.6.gem (100%) Successfully installed knife-ec2-0.5.10 6 gems installed $ knife ec2 server create 'role[webserver]' \ -I ami-7000f019 -f m1.small Instance ID: i-9e7ef1fe Flavor: m1.small Image: ami-7000f019 Region: us-east-1 Availability Zone: us-east-1c Security Groups: default SSH Key: relevance_aws Waiting for server...

Throughout Development Cycle Local Development

Throughout Development Cycle Local Development Single App (solo)

Throughout Development Cycle Local Development Single App (solo) Server Based Rollout

Local Development

Vagrant

Vagrant Builds virtual machines from a text file and some Chef cookbooks.

Vagrant Project rstudio-spike Vagrantfile README.md Gemfile cookbooks apt rstudio

Vagrantfile Vagrant::Config.run do config config.vm.box = "lucid64" config.vm.box_url = "http://files.vagrantup.com/lucid64.box" config.vm.forward_port "http", 8787, 8787 config.vm.provision :chef_solo do chef chef.cookbooks_path = "cookbooks" chef.add_recipe "rstudio" chef.add_recipe "mysql::server" chef.json.merge!({ :mysql => {:server_root_password => "foo" } }) end end

Vagrant Project rstudio-spike Vagrantfile Vagrantfile README.md Gemfile cookbooks apt rstudio

Benefits

Benefits Version control dev environment

Benefits Version control dev environment Share configs across team

Benefits Version control dev environment Share configs across team Recreate project or client setup

Benefits Version control dev environment Share configs across team Recreate project or client setup Keep host environment clean

Base Box

Base Box OS Image + Vagrant configs

Download Base Boxes

Make Base Boxes

Some Recommendations

Know your image; build your own base boxes.

Avoid multiple Chef and Vagrant copies. Use RVM with.rvmrc in your Vagrant directory.

Reuse cookbooks between vagrant boxes and real deployments.

Share the project directory with the VM.

Solo Deployment

Chef Solo

Chef Solo Runs cookbooks, with attributes, on a node.

chef-solo $ sudo chef-solo -c solo.rb -j node.json INFO: *** Chef 0.10.4 *** INFO: Setting the run_list to ["recipe[rstudio]"] from JSON INFO: Run List is [recipe[rstudio]] INFO: Run List expands to [rstudio] INFO: Starting Chef Run for lucid64.hsd1.ca.comcast.net. INFO: Processing package[r-base] action install (rstudio::default line 18) -- many lines of output -- INFO: Processing dpkg_package[rstudio-server] action install (rstudio::default line 46) INFO: dpkg_package[rstudio-server] installed version 0.94.84 INFO: Chef Run complete in 238.033898 seconds INFO: Running report handlers INFO: Report handlers complete

solo.rb file_cache_path "/var/chef-solo" cookbook_path ["/var/chef/cookbooks", "/var/chef/site-cookbooks"]

node.json { } "mysql": { "server_root_password": "foo" }, "run_list": ["recipe[rstudio]"]

Benefits

Benefits Self-contained bundle

Benefits Self-contained bundle Can run from tarball at URL

Benefits Self-contained bundle Can run from tarball at URL Easy setup; no extra infrastructure

Some Recommendations

Rubyists: deliver cookbooks with capistrano, use chef-solo to execute.

Everyone: start with chef-solo before you deal with chef server.

Make a shared repository for cookbooks.

Use attributes to factor out environment and tuning.

Use roles to set parameters for an environment.

Factoring Roles Node 1 Role Node Role 1..* Compose Role Runlist for role includes other roles Use for applications Mix in Role Runlist for role includes other roles Use for environments

Example: Factoring Roles { } "run_list": ["role[rstudio-server]", "role[qa]"] mysql::server «recipe» mysql::default «recipe» node.json «runlist» rstudio-server «role» rstudio «recipe» apt «recipe» qa «role»

Separate off-the-shelf cookbooks from locally maintained cookbooks

Example: Isolating Local Cookbooks project-root README.md cookbooks site-cookbooks vagrant Vagrantfile

Example: Local Cookbooks With Overrides cookbooks apache2 templates default site-cookbooks apache2 templates default default-site.erb

Use overrides sparingly. It s implementation inheritance.

Server-Based Deployment

Chef Server

Chef Server Client-server polling Searchable via API Authenticated and encrypted Centralized management

Chef Server Chef poll Client cookbook upload recipes roles attributes Operator Chef Server

Server Based Search API access to Lucene search Nodes, roles, or data bags Can be used from recipes on clients

Example: Automatic Nagios Config 1. Search for nodes in the environment 2. Generate Nagios config files with information about nodes.

Step 1: Chef Server Assigns Recipe nagios::server node1 Chef Server

Step 1: Chef Server Assigns Recipe nagios::server poll node1 Chef Server

Step 1: Chef Server Assigns Recipe nagios::server poll node1 recipes Chef Server

Step 2: Client Downloads Cookbooks node1 Chef Server

Step 2: Client Downloads Cookbooks get cookbooks node1 Chef Server

Step 2: Client Downloads Cookbooks get cookbooks node1 cookbooks Chef Server

Step 3: Client Executes Recipe sysadmins = search(:users, 'groups:sysadmin') nodes = search(:node, "hostname:[* TO *] AND role:#{node[:app_environment]}") members = Array.new sysadmins.each do s members << s['id'] end

Step 3a: Client Searches Nodes node1 Chef Server

Step 3a: Client Searches Nodes search node1 Chef Server

Step 3a: Client Searches Nodes search lucene search node1 Chef Server

Step 3a: Client Searches Nodes search lucene search node1 list of nodes Chef Server

Step 3b: Client Applies Templates nagios_conf "hosts" do end variables :nodes => nodes

Step 3b: Client Applies Templates <% @nodes.each do n -%> define host { use server address <%= n['ipaddress'] %> host_name <%= n['hostname'] %> hostgroups <%= n.run_list.roles.to_a.join(",") %> } <% end -%>

Data Bags JSON data Held on server Access via API

Example: Database Credentials begin bamboo_app = Chef::DataBagItem.load(:apps, :bamboo) Chef::Log.info("Loaded apps[#{bamboo_app['id']}]") rescue Chef::Log.fatal("Could not find #{:bamboo} ") raise end

Search & data bags require Chef Server. Breaks Vagrant and Chef Solo.!

Encrypted Data Bags https://jtimberman.posterous.com/64227128

Chef Server in EC2

Challenges No long-lived identity Must use EBS for server Authentication of new nodes

Example: EC2 + ELB + AS Elastic load balancer app1 app2 extra instances Autoscale Group ami with chef client db chef-server

Recent News: CloudFormation + Chef EC2 Host CloudFormation

Recent News: CloudFormation + Chef EC2 Host 1. create virtual machine CloudFormation

Recent News: CloudFormation + Chef EC2 Host 1. create virtual machine 2. yum install gcc, ruby, rubygems gem install chef CloudFormation

Recent News: CloudFormation + Chef EC2 Host 1. create virtual machine 2. yum install gcc, ruby, rubygems gem install chef 3. deposit solo.rb & node.json files CloudFormation

Recent News: CloudFormation + Chef EC2 Host 1. create virtual machine 2. yum install gcc, ruby, rubygems gem install chef 3. deposit solo.rb & node.json files 4. run chef-solo with a URL target CloudFormation

Recent News: CloudFormation + Chef EC2 Host 1. create virtual machine 2. yum install gcc, ruby, rubygems gem install chef 3. deposit solo.rb & node.json files 4. run chef-solo with a URL target CloudFormation 5. chef-solo fetches cookbooks & executes recipes

Chef in Private Clouds

Chef + OpenStack: Automation 2 Ways 1. Build the platform itself 2. Build nodes in the platform

Other Options Hosted Chef: Chef Server as a Service www.opscode.com

Other Options Hosted Chef: Chef Server as a Service Private Chef: Like Hosted Chef, as an appliance behind your firewall www.opscode.com

Resources Chef http://wiki.opscode.com Vagrant http://www.vagrantup.com/ CloudFormation http://bit.ly/mpffjg

CHEF IN THE CLOUD AND ON THE GROUND Michael T. Nygard Relevance, Inc. michael.nygard@thinkrelevance.com @mtnygard 2011 Michael T. Nygard, All Rights Reserved.