Cloud meets Fog & Puppet
A Story of Version Controlled Infrastructure



   Habeeb Rahman | apigee | @habi_pk | pk.habi@gmail.com
About:apigee

        We love APIs
Developers => API <= Enterprises
           Usergrid
Take 1
Third-party web
  tool and ...
….Following Manual Tasks
ShareImages   CreateInstancesOnebyOne
InstallPackages         InstallLicense
CreateEBSVolumes      OpenPorts
AttachEIP   GenerateServerConfig
Apply Patches GenerateNagiosConfig
                  +
              a Few Misc
Take 2
Cloud meets puppet and ...
  (aws console, git, puppet)
….Following Manual Tasks
ShareImages   CreateInstancesOnebyOne
InstallPackages         InstallLicense
CreateEBSVolumes      OpenPorts
AttachEIP   GenerateServerConfig
ApplyPatches GenerateNagiosConfig
                  +
              a Few Misc
Take 3
  Cloud meets Fog and …
(puppet cloud provisioner, fog, ruby)
….Following Manual Tasks
ShareImages   CreateInstancesOnebyOne
InstallPackages         InstallLicense
CreateEBSVolumes      OpenPorts
AttachEIP   GenerateServerConfig
ApplyPatches GenerateNagiosConfig
                  +
              a Few Misc
Customer in a 'yaml' file...
Git version controls Puppet
Configurations & Cloud Deployments
     (Yes! Version Controlled Infrastructure)
Git hooks
Pre-update => puppet syntax checks
(puppet parser, puppet lint)

Post-update => sync with regional puppet masters
Puppet
Git branches => Puppet environments

Single puppet master => Test Dev Production

manifests and files/data => Separate git repo

Puppet masters per AWS regions

Hiera: a pluggable hierarchical data store
Why Fog?
Cross service compatibility
(multitude of services=> Storage, Compute, DNS…)



Avoid vendor lock-in
(Vendor independent=>EC2, Rackspace, Slicehost, Linode…)



Power of Ruby
gem install fog
require ‘fog’
~/.fog
Fog quick starter kit

Look at the test suites (thanks to TDD)
https://github.com/fog/fog/blob/master/tests/aws/requests/compute/instance_tests.rb
Fog command line

[root@zebra ~]$ less ~/.fog
[root@zebra ~]$ fog testaws
 Welcome to fog interactive!
 :testaws provides AWS
>>
ec2 = Fog::Compute.new(
  provider:              "AWS",
  aws_access_key_id:     "KEY",
  aws_secret_access_key: "SECRET"
)

rsc = Fog::Compute.new(
  provider:           "Rackspace",
  rackspace_api_key: "KEY",
  rackspace_username: "SECRET"
)

ec2.servers.create(
  flavor_id: "c1.medium",
  image_id: "ami-6936fb00", # Ubuntu 10.04 LTS
  key_name: "mykeyname",
  groups:    ["default"],
)

rsc.servers.create(
  flavor_id: 5, # 4GB Memory
  image_id: 49, # Ubuntu 10.04 LTS
  name:      'my_server_name'
)
Open Source Fog alternatives
        libcloud (Python)
          jclouds (Java)
        deltacloud (Ruby)
Why Ruby?
“Ruby is designed for programmer
      productivity and fun”
     Matsumoto(creator of the ruby language)
'everything-ruby' by Ajey Gore
http://confreaks.com/videos/921-rubyconfindia2012-everything-ruby
irb is your friend
             (ruby interactive shell)


root@zebra:~/$ irb
1.9.3-p125 :001 >


             irb alternative = > pry (gem install pry)
The Layers of Abstraction...
Fog => Cloud abstraction
Puppet => OS abstraction
Notes to self >>
Start small...
...and iterate reiterate &
        re reiterate
Select right tools
(Plenty of tools => Puppet/Chef/Cfengine/Ansible
     but what is good for you/team/culture?)
Design your SaaS but make sure it's
            'ops' ready
  (from the day you start the design)
http://puppetlabs.com/
http://fog.io
http://git-scm.com/
http://ansible.github.com/

Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure