Share
Embed
Transcript
65 slides
-
http://www.flickr.com/photos/mister-e/196496149 •Started working with PHP in 2002 •Currently work as
a Systems Engineer at Comic Relief About @jeremyquinton Friday, 4 October 13 -
Homebrew Package Manager on Linux APT, YUM ETC Some Solutions
for dev environments Friday, 4 October 13 -
PHP MySQL EcoSystem Linux/Windows/Mac Apache PHP has over 150 extensions
+ Friday, 4 October 13 -
Modern PHP Application Example PHP 5.4 Apache Varnish Couch DB
Gearman Linux VLAPCG != LAMP Friday, 4 October 13 -
“Keep development, staging, and production as similar as possible” -
http://12factor.net/ Text Dev/Prod Parity Concept Friday, 4 October 13 -
Past and Present problems •Not straightforward. • Uniqueness. • Switching
between projects is difficult. • Local dev environments differ from production. Friday, 4 October 13 -
“Every so often, you encounter software that immediately strikes you
with its combination of clarity, simplicity, power, and usefulness.” - Jeff Sussna Ingineering.IT in the foreward of Vagrant up and running by Mitchell Hashimoto Friday, 4 October 13 -
What is the Vagrant Concept? “A tool to transparently manage
all the complex parts of modern development within a virtual environment without affecting the everyday workflow of the developer too much.” - http://www.vagrantup.com Friday, 4 October 13 -
$ vagrant Usage: vagrant [-v] [-h] command [<args>] -v, --version
Print the version and exit. -h, --help Print this help. Available subcommands: box destroy halt help init package plugin provision reload resume ssh ssh-config status suspend up For help on any individual command run `vagrant COMMAND -h` Vagrant is a command line tool Friday, 4 October 13 -
Vagrant Workflow • When you done with the dev environment
vagrant destroy [vn-name] • To access the virtual machine via ssh vagrant ssh • When you finished work for the day vagrant halt vagrant up • Once Configured one command to bring up you vagrant dev environment Friday, 4 October 13 -
Lets build a vagrant environment •Download Virtual Box http://download.virtualbox.org/virtualbox •Download
Vagrant Installer http://downloads.vagrantup.com Friday, 4 October 13 -
Generate a VagrantFile $ vagrant init precise64 Box name http://files.vagrantup.com/precise64.box
Box Friday, 4 October 13 -
Generated VagrantFile Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url =
"http://files.vagrantup.com/precise64.box" end Box name Box location $ vagrant up Friday, 4 October 13 -
Box Files •Every Vagrant development environment needs a box file
to build off. •Box files are specific to the type of provider. http://docs.vagrantup.com/v2/boxes.html $ vagrant box add name url Friday, 4 October 13 -
Four methods to create a box file •Download a box
file from http://www.vagrantbox.es •Using the instructions off - (not recommended) http://docs-v1.vagrantup.com/v1/docs/base_boxes.html •VeeWee https://github.com/jedi4ever/veewee •Packer http://www.packer.io/docs/builders/virtualbox.html In a future version of vagrant packer will be integrated. Friday, 4 October 13 -
Generated VagrantFile Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url =
"http://files.vagrantup.com/precise64.box" end $ vagrant init precise64 http://files.vagrantup.com/precise64.box $ vagrant up Friday, 4 October 13 -
Provisioning your vagrant machine •Need a configuration management tool. •Main
benefits are ease of use, repeatability, automation and improving parity between development and production. Friday, 4 October 13 -
Chef Puppet Puppet and Chef Puppet Apply Stand Alone Chef
Client Client Server model Chef Solo Stand Alone Puppet Agent Client Server model Friday, 4 October 13 -
Puppet and Chef Stand Alone Stand Alone •Built by Puppetlabs.
•Written in ruby you describe the system as a set of resources using a resource abstraction language. Puppet Puppet Apply •Built by Opscode. •Written in ruby uses a domain specific language (DSL). Chef Chef Solo Friday, 4 October 13 -
•In your Chef(cookbooks and recipes) or Puppet (modules and manifests)
•What software is installed. •How the software is configured. •What services are running. Chef Solo Puppet Apply Friday, 4 October 13 -
$ tree cookbooks |- php |- attributes |- default.rb |-
providers |- pear.rb ........ |- recipes |- default.rb |- package.rb |- source.rb |- resources |- pear.rb ........ |- templates |- centos |- php.ini.erb ............... https://github.com/opscode-cookbooks/php Higher level chef concepts Chef Solo - autonomy of a cookbook Friday, 4 October 13 -
Chef Solo - autonomy of a cookbook https://github.com/opscode-cookbooks/php default['php']['install_method'] =
'package' default['php']['directives'] = {} case node["platform_family"] when "rhel", "fedora" default['php']['conf_dir'] = '/etc' default['php']['ext_conf_dir'] = '/etc/php.d' ....... default['php']['packages'] = ['php', 'php- devel', 'php-cli', 'php-pear'] when "debian" ....................... end $ tree cookbooks |- php |- attributes |- default.rb Friday, 4 October 13 -
https://github.com/opscode-cookbooks/php $ tree cookbooks |- php |- recipes |- default.rb
|- package.rb |- source.rb Chef Solo - autonomy of a cookbook include_recipe "php::#{node['php']['install_method']}" Every cookbook needs a default recipe default.rb node['php']['packages'].each do |pkg| package pkg do action :install end end template "#{node['php']['conf_dir']}/php.ini" do source "php.ini.erb" owner "root" group "root" mode "0644" variables(:directives => node['php']['directives']) end Ruby code and chef dsl package.rb Friday, 4 October 13 -
Chef Solo - adding to Vagrant $ tree |------ VagrantFile
|------ cookbooks |------------- PHP |------------- Apache |------------- MongoDB |------------- Memcache |------ roles |------------- local.json Friday, 4 October 13 -
{ "chef_type": "role", "default_attributes": {}, "json_class": "Chef::Role", "name": "local", "override_attributes":
{ "php": { "directives": { "memory_limit": "256M", "post_max_size": "50M", "short_open_tag": "On", "upload_max_filesize": "50M" } } }, "run_list": [ "recipe[php]", "recipe[php::some_recipe]", "recipe[mongodb]", "recipe[apache]", "recipe[memcache]", ] } Chef Solo - adding a Role Friday, 4 October 13 -
show a role and Vagrant.configure("2") do |config| config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provision "chef_solo" do |chef| chef.cookbooks_path = ["cookbooks"] chef.roles_path = "roles" chef.add_role("local") end end Chef Solo - Update VagrantFile Friday, 4 October 13 -
$ vagrant up $ vagrant up --no-provision (stops the provisioner
running automatically) $ vagrant provision Lets provision the box Friday, 4 October 13 -
https://github.com/puppetlabs/puppetlabs-apache class apache::params { Puppet Apply - autonomy of a
module $ tree modules |- apache |- Modulefile |- files |- lib |- manifests |- init.pp |- params.pp |- service.pp ....................... |- spec .................. |- templates |- tests Higher level puppet concepts Friday, 4 October 13 -
https://github.com/puppetlabs/puppetlabs-apache class apache { package { 'httpd': ensure => installed,
name => $apache::params::apache_name, notify => Class['Apache::Service'], } ..... class apache::params { class apache::params { if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { ........ $apache_name = 'httpd' } elsif $::osfamily == 'Debian' { $apache_name = 'httpd' } ............ } Puppet Apply - autonomy of a module $ tree modules |- apache |- Modulefile |- files |- lib |- manifests |- init.pp |- params.pp |- service.pp ....................... |- spec .................. |- templates Friday, 4 October 13 -
Puppet Apply https://github.com/puppetlabs/puppetlabs-apache class apache { group { $group: ensure
=> present, require => Package['httpd'] } ......... $ tree modules |- apache |- Modulefile |- files |- lib |- manifests |- init.pp |- params.pp |- service.pp ....................... |- spec .................. |- templates user { $user: ensure => present, gid => $group, require => Package['httpd'], } file { "/etc/httpd/conf/httpd.conf" : ensure => file, content => template(apache/httpd.conf.erb), notify => Class['Apache::Service'], } Friday, 4 October 13 -
Puppet Apply - Adding to Vagrant $ tree |------ VagrantFile
|------ manifests |--- default.pp |------ modules |---- Apache |---- concat |---- stdlib class { 'apache': } apache::vhost { 'awesome.dev': docroot => '/var/www/', port => '80', } http://docs.puppetlabs.com/puppet_core_types_cheatsheet.pdf http://docs.puppetlabs.com/module_cheat_sheet.pdf Friday, 4 October 13 -
Updated VagrantFile with provisioners Vagrant.configure("2") do |config| config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provision :puppet do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "default.pp" puppet.modules = "modules" end end Friday, 4 October 13 -
Leverage the puppet and chef communities •Stand on the shoulders
of giants. •Hundreds of pre written cookbooks and modules. https://forge.puppetlabs.com https://github.com/puppetlabs https://github.com/opscode-cookbooks Friday, 4 October 13 -
Vagrant Functionality •Configuration •Boxes •Provisioning •Networking •Synced Folders •Multi Machine
•Providers •Plugins Vagrant.configure("2") do |config| config.vm.synced_folder ".", "/vagrant", nfs: true end Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.50.4" end Friday, 4 October 13 -
Vagrant Functionality •Configuration •Boxes •Provisioning •Networking •Synced Folders •Multi Machine
•Providers •Plugins Vagrant.configure("2") do |config| config.vm.synced_folder ".", "/vagrant", nfs: true end Friday, 4 October 13 -
Multi Machine Vagrant Vagrant.configure("2") do |config| config.vm.define "web" do |web|
web.vm.box = "apache" end config.vm.define "db" do |db| db.vm.box = "mysql" end end Friday, 4 October 13 -
March 2010 First Version of Vagrant released March 2012 Vagrant
1.0, the first stable version, was released in March 2012, exactly two years after the original version of Vagrant. March 2013 Vagrant 1.1 released. Virtualbox decoupled from the core. New plugin system. New providers AWS and VMWARE. November 2012 Mitchell Hashimoto forms Hashicorp. Present Vagrant Timeline Development Environments no longer suck Friday, 4 October 13 -
http://www.flickr.com/photos/kewl/7006904747 Vagrant Plugin System •Most of the core of Vagrant
is implemented using plugins. - http://docs.vagrantup.com/v2/plugins/index.html Friday, 4 October 13 -
Text $ vagrant plugin install vagrant-vmware-fusion $ vagrant plugin license
vagrant-vmware-fusion license.lic Vagrant Vmware Provider •There are costs associated with using this plugin Friday, 4 October 13 -
•Every new provider needs a new box format http://docs.vagrantup.com/v2/vmware/ boxes.html
$ vagrant box add Text precise64 Box name http://files.vagrantup.com/precise64_vmware.box Box location Vagrant Vmware Provider Friday, 4 October 13 -
Text Text $ vagrant box list precise64 (virtualbox) precise64 (vmware_fusion)
Vagrant Vmware Provider Friday, 4 October 13 -
$ vagrant up --provider=vmware_fusion $ vagrant up --provider=virtualbox Vagrant Vmware
Provider Friday, 4 October 13 -
$ vagrant plugin install vagrant-aws https://github.com/mitchellh/vagrant-aws $ vagrant box add
dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box Amazon Ec2 Provider Friday, 4 October 13 -
Text https://github.com/mitchellh/vagrant-aws Vagrant.configure("2") do |config| config.vm.box = "dummy" 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-7747d01e" override.ssh.username = "ubuntu" override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY" end end Amazon Ec2 Provider Friday, 4 October 13 -
Text Other Plugins https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins Provider - virtualisation Virtual Box Provisioner
Vmware Amazon Ec2 Rackspace Digital Ocean HP cloud platform Joynet KVM LibVirt LXC Managed-servers Openstack Salty Sprinkle Fabric Ventriloquist Puppet Chef Ansible Shell Friday, 4 October 13 -
Sources http://www.vagrantup.com/ Text http://shop.oreilly.com/product/0636920026358.do Vagrant: Up and Running by Mitchell
Hashimoto http://docs.puppetlabs.com/learning/index.html http://docs.opscode.com Friday, 4 October 13