Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CloudInit Introduction


Published on

CloudInit introduction,
Use case on Amazon AWS EC2

Published in: Technology
  • Login to see the comments

CloudInit Introduction

  1. 1. Xebia Workshop CloudInit Xebia: OpenCSI: Bertrand Dechoux Bruno Bonfils Charles Blonde Cyrille Le Clerc Emmanuel Servent Eric BriandSaturday, August 13, 11
  2. 2. Introduction  Goal: bootstrap a cloud instance  How: give a file as parameter for the first instance start ▶ Retrievedfrom ▶ May be a multipart file  Ubuntu project, exist for RPM based systems 2Saturday, August 13, 11
  3. 3. Some recipes examples Set the hostname Import SSH keys Declare apt mirror Install packages Execute commands Execute scripts Bootstrap Puppet / Chef Detailed sample : 3Saturday, August 13, 11
  4. 4. Advices CloudInit is not very well documented, use the source, good luck! Choose to use existing recipes or write your own 4Saturday, August 13, 11
  5. 5. cloud-config: the key CloudInit script #cloud-config timezone: Europe/Paris packages: - puppet - java-1.6.0-openjdk - tomcat6 - tomcat6-webapps runcmd: - [service, tomcat6, start] - [chkconfig, tomcat6, on] Declarative YAML based configuration 5Saturday, August 13, 11
  6. 6. My own shell script #!/usr/bin/env bash instanceId=$(curl fqdn="$" sed -i.bak "s/HOSTNAME=.*/HOSTNAME=${fqdn}/" /etc/sysconfig/network hostname ${fqdn} echo " $id $fqdn" >> /etc/hosts # Now bootstrap puppet puppetd --no-daemonize --onetime -v 6Saturday, August 13, 11
  7. 7. My own shell script #!/usr/bin/env python ... # INJECT DATABASE URL IN CATALINA.PROPERTIES f = open(catalinaBase + /conf/, ab) f.write(nn# BEGIN OF ADDED BY CLOUD-INIT #n) f.write(jdbc.url=jdbc:mysql://my-db-host:3306/petclinicn) f.write(jdbc.username=petclinicn) f.write(jdbc.password=petclinicn) f.write(nn# END OF ADDED BY CLOUD-INIT #n) f.close() # DOWNLOAD AND DEPLOY WAR url = http://my-nexus/fr/xebia/.../1.0.2/petclinic-1.0.2.war URLopener().retrieve(url, catalinaBase + /webapps/petclinic.war) print(Downloaded + url + to + filename) Inject database config in Tomcat Deploy war 7Saturday, August 13, 11
  8. 8. CloudInit resources cloud-init/trunk 8Saturday, August 13, 11
  9. 9. The Workshop“Discover Java Infra as Code with Amazon AWS” JavaInfrastructureAsCodeWithAmazonAwsWorkshop 9Saturday, August 13, 11