• Save
Oliver leech   cloudstack
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Oliver leech cloudstack

  • 1,819 views
Uploaded on

The CloudStack European User group met on Thursday 11th for our quarterly meeting. ...

The CloudStack European User group met on Thursday 11th for our quarterly meeting.
Oliver Leech (Platform Architect at Tata Communications) demonstrated using puppet to deploy applications within a CloudStack environment.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,819
On Slideshare
1,408
From Embeds
411
Number of Embeds
5

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 411

http://www.shapeblue.com 344
http://shapeblue.com 56
http://www.responsivelaboratory.com 9
http://feedspot.com 1
http://www.feedspot.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. @oliverleachAutomating application deployments using Puppet and CloudStackCloudstack European User Group11th April 2013 – London
  • 2. Automating application deployments using Puppet and CloudStack• Getting Cloudstack to deploy CloudstackToday’s gimmick• Incomplete code examples coming up
  • 3. Automating application deployments using puppet and CloudStack• A script to create a deployment mechanism. I’m using Python for thisdemo• Using the Cloudstack API to provision compute resources• Writing Puppet manifests to deploy and configure your applicationsInvolves:• Preconfigured puppet master and a puppet agent template in Cloudstack• Specifying userdata in deployVirtualMachine API to classifypuppet nodesHow:
  • 4. Automating application deployments using puppet and CloudStackHigh level process flow summary:Acquire a public IP address and capture detailsDeploy the puppet master and capture detailsDeploy the puppet nodes and classify the node roleConfigure a static NAT with firewall rules
  • 5. Automating application deployments using puppet and CloudStackHow to query the Cloudstack async job for deployment detailsWait for job tofinish & reviewjob response
  • 6. Automating application deployments using puppet and CloudStackdef associateip(self, zone_id):associateip = cs_api.request(dict({command:associateIpAddress, zoneid: zone_id}))....for key, value in associateip.iteritems():if key == jobid : asyncjob = value....def asyncresults(self, *args)....status=0while status==0:qryasyncjob = cs_api.request(dict({command:queryAsyncJobResult, jobid:asyncjob}))....for key, value in qryasyncjob.iteritems():if key == jobstatus : status = valuetime.sleep(5)Deploy resource using the CS API then get and query the asnyc jobid
  • 7. Automating application deployments using puppet and CloudStackWait for job to finish & review job responseassociateip_qryjob = associateip_qryjob.queryasyncjobresultresponse.jobresult.ipaddressfor key, value in associateip_qryjob.items():print key, ‘=‘, value# returns the following values...networkid = 8e67fa8a-aa68-4d8d-9de5-1979840bb53dphysicalnetworkid = b37ed19d-f997-421c-9da7-f90e985992e4account = puppetdomainid = b351cbc3-6d41-4266-8715-96b4e55177f2issourcenat = Falseisstaticnat = Falsetags = []associatednetworkname = puppet networkdomain = AA000001zoneid = 6fdd9a36-2187-419d-99ad-8b3ecd47082fstate = Allocatedassociatednetworkid = b598215e-ac3d-4fd6-8c83-b4191c6b2e5cforvirtualnetwork = Trueallocated = 2012-04-01T18:30:00+0100issystem = Falseipaddress = 195.125.133.14id = 76e15bad-cd08-4012-bcbd-4bffe08096eazonename = Cloud1-Zone1
  • 8. Automating application deployments using puppet and CloudStackassociateip_qryjob = associateip_qryjob.queryasyncjobresultresponse.jobresult.ipaddressfor key, value in associateip_qryjob.items():if key == id: Cloudstack_Cmds.snat_ipid = valueif key == ipaddress : Cloudstack_Cmds.snat_ipaddress = valueNow what can I do?Take job response values & store as variables e.g., (Cloudstack_Cmds.snat_ipid)and use as part of the userdata in deployVirtualMachine
  • 9. Automating application deployments using puppet and CloudStackHow to deploy the VMs with the userdata parameterimport base64....puppet_node = puppet-agentnode_role = csm_server, nfs_servertemplate_id = puppet_agentfor value in node_role:if value == csm_server: getvmid = Trueuserdata = (puppet_master_ip=%snrole=%snsnat_ipaddress=%sn % (Cloudstack_Cmds.pm_ipaddress, value, Cloudstack_Cmds.snat_ipaddress))api_cmd.deployvm(getvmid, command = deployVirtualMachine, serviceofferingid = so_id, templateid = template_id, zoneid = zone_id, networkids = network_id, puppet_node = puppet_node, userdata = base64.b64encode(userdata))
  • 10. Automating application deployments using puppet and CloudStackWhat does this translate to on the puppet node?By querying the domain router for the userdata, I can turnthe values in to a puppet fact which can be used to classifymy puppet nodes[root@2e57b8ae-a226-42e2-ac2b-72401ece4259 ~]# facter |grep role|snat|puppetrole => csm_serversnat_ipaddress => 195.125.133.14puppet_master_ip => 10.1.1.188[root@7a9e0e74-7884-4999-8b24-f7168f76edbc facter]# curlhttp://10.1.1.1/latest/user-datapuppet_master_ip=10.1.1.188role=csm_serversnat_ipaddress = 195.125.133.14....lines.each do |line|if line =~ /^(.+)=(.+)$/var = $1; val = $2Facter.add(var) dosetcode { val }....CSM server
  • 11. Automating application deployments using puppet and CloudStackHow to apply puppet manifests to these nodesclass cs_vms {$mysql_password = (‘<mysql_password_goes_here>)....case $role {csm_server: {class { cloudstack :mysql_password => [ $mysql_password ],require => Class[ mysql::server ],}include apacheclass { selinux : mode => permissive }class { mysql::server :mysql_password => [ $mysql_password ],}class { iptables :require => Class[ cloudstack ],}....
  • 12. Automating application deployments using puppet and CloudStackA quick look at the Cloudstack puppet moduleclass cloudstack ($mysql_password) {yumrepo { cloudstack:baseurl => "http://cloudstack.apt-get.eu/rhel/4.0/",descr => "Cloudstack 4.0.1 yum repo",enabled => 1,gpgcheck => 0,}package { "cloud-client":ensure => "installed",require => Yumrepo["cloudstack"],}exec { "cloud-setup" :command => "/usr/bin/cloud-setup-databases cloud:cloud@localhost --deploy-as=root:${mysql_password} && /bin/sleep 3 && /usr/bin/cloud-setup-management",creates => /var/lib/mysql/cloud,require => Package["cloud-client"],}service { "cloud-management":ensure => "running",enable => "true",require => Exec["cloud-setup"],}}
  • 13. Automating application deployments using puppet and CloudStackWhat did I use the snat_ipaddress for?....NameVirtualHost *:80<VirtualHost *:80>ServerName < snat_ipaddress >DocumentRoot /var/www/html/Redirect permanent / https://<snat_ipaddress>/client</VirtualHost>Listen 443NameVirtualHost *:443<VirtualHost *:443>SSLEngine OnSSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateKeyFile /etc/pki/tls/private/localhost.keyRewriteEngine OnProxyRequests OnProxyVia On<Proxy *>Order deny,allowDeny from allAllow from all</Proxy>Redirect permanent / /clientProxyPass /client http://localhost:8080/clientProxyPassReverse /client http://localhost:8080/client</VirtualHost>....NameVirtualHost *:80<VirtualHost *:80>ServerName 195.125.133.14DocumentRoot /var/www/html/Redirect permanent / https://195.125.133.14/client</VirtualHost>Listen 443NameVirtualHost *:443<VirtualHost *:443>SSLEngine OnSSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateKeyFile /etc/pki/tls/private/localhost.keyRewriteEngine OnProxyRequests OnProxyVia On<Proxy *>Order deny,allowDeny from allAllow from all</Proxy>Redirect permanent / /clientProxyPass /client http://localhost:8080/clientProxyPassReverse /client http://localhost:8080/client</VirtualHost>
  • 14. Automating application deployments using puppet and CloudStack
  • 15. Automating application deployments using puppet and CloudStackThat’s a gimmick! How about some real use case examples?
  • 16. Automating application deployments using puppet and CloudStackThank you