• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Puppet and AWS: Getting the best of both worlds
 

Puppet and AWS: Getting the best of both worlds

on

  • 7,735 views

"Puppet and AWS: Getting the best of both worlds" by Mike Ryan of Epitech.nl at Puppet Camp Amsterdam 2013.

"Puppet and AWS: Getting the best of both worlds" by Mike Ryan of Epitech.nl at Puppet Camp Amsterdam 2013.

Statistics

Views

Total Views
7,735
Views on SlideShare
7,691
Embed Views
44

Actions

Likes
11
Downloads
43
Comments
0

5 Embeds 44

http://nicolson-dev-mgmt-01 38
http://nicolson-dev-mgmt-01.hon.net 2
http://puppetlabs.com 2
http://10.1.1.10 1
https://puppetlabs.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

Puppet and AWS: Getting the best of both worlds Puppet and AWS: Getting the best of both worlds Presentation Transcript

  • Puppet and AWS Getting The Best of Both Worlds Mike Ryan - Epitech.nl - mike@epitech.nlSunday, April 14, 13
  • • What is AWS? • How does Puppet work in AWS? • CloudFormation • PaaS replacement? • Vagrant -> EC2 • Using Puppet to build AMIs • Some workarounds to common problems • QuestionsSunday, April 14, 13
  • Hello, I’m Mike • Londoner in Amsterdam • Sysadmin with a passion for automation • Epitech.nl - sysadmin as a serviceSunday, April 14, 13
  • Amazon Web Services • EC2 • Amazon Machine Images • User DataSunday, April 14, 13
  • EC2 - Auto ScalingSunday, April 14, 13
  • CloudFormation{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "EC2 instance", "Resources" : { "MyEC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : "ami-79fd7eee", "KeyName" : "my-ssh-key", } } }}Sunday, April 14, 13
  • "Enabled" : "true", "Logging" : { "Bucket" : "webapplication.s3.amazonaws.com", "Prefix" : "webapp-logging/" } } } }, "asgMyAutoScalingGroup": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "AvailabilityZones": [ "us-east-1b", "us-east-1c" ], "Cooldown": "300", "DesiredCapacity": "1", "MaxSize": "1", "MinSize": "1", "LaunchConfigurationName": { "Ref": "lcMyLC" }, "LoadBalancerNames": [ { "Ref": "elbMyLB" } ] } }, "s3webapplication": { "Type": "AWS::S3::Bucket" }, "sgwebappsecuritygroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "for web app", "SecurityGroupIngress": [ {Sunday, April 14, 13
  • Bootstrapping an Infrastructure www.infrastructures.orgSunday, April 14, 13
  • CloudFormation or PuppetSunday, April 14, 13
  • Files, Services and Packages with cfn-init"Metadata": { "AWS::CloudFormation::Init": { "config": { "sources" : { "/etc/puppet" : "http://example.com/puppet.tar.gz" }, "packages": { "yum": { "puppet-server": [], }, }, "services": { "sysvinit": { "puppetmaster": { "ensureRunning": "true", "enabled": "true" } }Sunday, April 14, 13
  • Run a script at launch time with User Data{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "EC2 instance", "Resources" : { "PuppetMasterInstance": { "Type": "AWS::EC2::Instance", "Metadata": { }, "Properties": { "UserData": { "Fn::Base64": { "Fn::Join": [ "", [ "#!/bin/bashn", "/opt/aws/bin/cfn-init --region ", "n", "/usr/bin/puppet apply site.pp, "n" ] ] } } }Sunday, April 14, 13
  • cfn-create-stack $ cfn-create-stack puppetmaster --template-file=puppetmaster.jsonhttp://aws.amazon.com/developertools/2555753788650372 http://aws.amazon.com/cli/Sunday, April 14, 13
  • CloudFormation + Puppet + Deploy scripts = PaaSSunday, April 14, 13
  • Autoscale = autosignSunday, April 14, 13
  • The Hostname Issuemike@ip-10-32-34-116:~$ hostname -fip-10-32-34-116.eu-west-1.compute.internalSunday, April 14, 13
  • User Data - Web ConsoleSunday, April 14, 13
  • User Data in CloudFormation }, "UserData": { "Fn::Base64": { "Fn::Join": [ "", [ “{”role”: ”web”, ”, “”env”: ”staging”} ” ] ] } } {“role”: “web”, “env”: “staging”}Sunday, April 14, 13
  • include stdlib node default {   $userdata = parsejson($ec2_userdata) $role = userdata[‘role’] $environment = userdata[‘env’] case $role { ‘web’: { include nginx } ‘db’: { include postgresql } } }Sunday, April 14, 13
  • Vagrant -> EC2Sunday, April 14, 13
  • Vagrant -> EC2 WorkflowSunday, April 14, 13
  • User Data and Vagrant Vagrant::Config.run do |config| config.vm.provision :puppet do |puppet| puppet.manifests_path = "../puppet/manifests" puppet.module_path = "../puppet/modules" puppet.manifest_file = "site.pp" puppet.options = "--verbose --debug" puppet.facter = { :ec2_userdata => { :role => "database", :env => "local_dev", }.to_json, :vagrant => "true" } end endSunday, April 14, 13
  • DecouplingSunday, April 14, 13
  • Broken Puppet master = no autoscalingSunday, April 14, 13
  • /etc/rc.local #!/bin/bash /usr/local/bin/update.sh /usr/bin/puppet apply site.ppSunday, April 14, 13
  • But you lose... • Puppet Dashboard • Exported resources • Stored configs • Shared modulesSunday, April 14, 13
  • Role-based Puppet runsSunday, April 14, 13
  • EC2 TagsSunday, April 14, 13
  • env.roledefs = { web: [www1, www2, www3], db: [db1, db2] } @roles(db) def restart_db(): sudo(/etc/init.d/postgresql restart) @roles(‘web’) def restart_web(): sudo(/etc/init.d/nginx restart) $fab restart_web restart_dbSunday, April 14, 13
  • env.roledefs = { web: [www1, www2, www3], db: [db1, db1] } @roles(db, ‘web’) def run_puppet(): sudo(puppet apply site.pp) $fab run_puppet #run puppet everywhere $fab run_puppet --roles db # role-specificSunday, April 14, 13
  • env.roledefs = configure_roles() @roles(db, ‘web’) def run_puppet(): sudo(puppet apply site.pp) $fab run_puppet #run puppet everywhere $fab run_puppet --roles db # role-specificSunday, April 14, 13
  • def configure_roles():  tags = EC2TagManager(AWS_KEY, AWS_SECRET,    regions=[eu-west-1])  roles = {} for role in [‘db’, ‘web’]: roles[role] = tags.get_instances(role=role) return roles https://github.com/mikery/fabric-ec2Sunday, April 14, 13
  • Questions? Mike Ryan - Epitech.nl - mike@epitech.nlSunday, April 14, 13