SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
November 12, 2014 | Las Vegas, NV 
Thomas Lobinger and Jonathan Weiss, Amazon Web Services
OpsWorksBackend 
OpsWorksAgent 
Amazon EC2, Amazon EBS, EIP, 
Amazon VPC, Elastic Load Balancing…. Auto-Scaling, Auto-Healing…. 
On-instance execution viaChef client/zero 
Command 
JSON 
CommandLog+Status
Chef Client 
& 
Chef Server
AWS OpsWorks recipes 
Yourcustomrecipes
search(:node, “name:web1”) 
search(:node, “name:web*”)
appserver = search(:node, "role:php-app").first 
Chef::Log.info(”Private IP: #{appserver[:private_ip]}")
appserver = search(:node, "role:php-app").first 
Chef::Log.info(”Private IP: #{appserver[:private_ip]}")
{ 
"opsworks": { 
"data_bags": { 
"bag_name1": { 
"item_name1: { 
"key1" : “value1”, 
"key2" : “value2”, 
... 
} 
}, 
"bag_name2": { 
"item_name1": { 
"key1" : “value1”, 
"key2" : “value2”, 
... 
} 
}, 
... 
} 
} 
}
{ 
"opsworks": { 
"data_bags": { 
"myapp": { 
"mysql": { 
"username": "default-user", 
"password": "default-pass" 
} 
} 
} 
} 
} 
mything= data_bag_item("myapp", "mysql") 
Chef::Log.info("username: #{mything['username']}")
user= ENV[“payment_provider_user“] 
password= ENV[“payment_provider_password“] 
PaymentGateway.new(user, password)
Change cookbook 
Push change 
Stop an instance 
Update cookbooks 
Start an instance 
Trigger event or runlist 
Check logs
list_commands 
get_json 
run_command 
show_log
list 
# list event history (up to 10 events) 
# opsworks-agent-cli list 
2014-11-06T10:26:58setup 
2014-11-06T10:55:13configure2014-11-06T14:59:05execute_recipes 
2014-11-07T18:25:53deploy 
2014-11-07T18:34:11configure 
2014-11-08T10:05:23configure 
2014-11-08T14:43:43configure
get 
# show JSON events (latest or by type/timestamp) 
# opsworks-agent-cli get 
{ 
"ssh_users": { 
"2066": { 
"name": "thomas", 
"public_key": "ssh-rsa AAAAB3NzaC1...", 
"sudoer": true 
...
# list current agent folder and cookbooks 
# ls/opt/aws/opsworks/current 
cookbooks# OpsWorks cookbooks 
berkshelf-cookbooks# CookbooksfromBerkshelf 
site-cookbooks# Yourcookbooks 
merged-cookbooks# Resultingcookbooksforrun 
...
run 
# run last setup event (changed cookbooks, same JSON) 
# opsworks-agent-cli run setup 
# or select specific date 
# opsworks-agent-cli run 2014-11-08T14:43:43 
[2014-11-12 13:06:41] INFO [opsworks-agent(17817)]:About to re-run 'setup' from 2014-11-08T14:43:43 
Waiting for process 17817 
... 
Finished Chef run with exitcode 0
# change recipe 
# cd /opt/aws/opsworks/current/site-cookbooks 
# vim mycookbooks/recipes/default.rb 
# confirm success 
# opsworks-agent-cli run setup 
# commit back to your git repo 
# git commit -am “can develop on instance“ 
# git push
Destroy 
Create 
Converge 
Setup 
Verify 
Destroy
.kitchen.yml 
driver: 
name: opsworks 
stack_id: vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz 
provisioner: 
name: shell 
busser: 
ruby_bindir: /opt/aws/opsworks/local/bin
.kitchen.yml 
platforms: 
-name: Amazon Linux 2014.09 
-name: Ubuntu 12.04 LTS 
-name: Ubuntu 14.04 LTS 
suites: 
-name: default 
run_list: 
-recipe[demo::default]
# destroy, create, setup, converge, verify, destroy 
kitchen test 
kitchen verify [NAME|REGEXP|all]# run all 'tests' 
kitchen verify ubuntu# only ubuntus 
kitchen verify client# only client tests 
kitchen verify -c NUMBER# concurrency 
# Talk by Fletcher Nichol http://youtu.be/YzlCHAbJ7KM
‣attributes 
‣recipes 
‣templates 
▾test 
‣integration 
.kitchen.yml 
metadata.rb
‣attributes 
‣recipes 
‣templates 
▾test 
▾integration 
‣default<--test suite name 
.kitchen.yml 
metadata.rb
‣attributes 
‣recipes 
‣templates 
▾test 
▾integration 
▾default<--test suite name 
‣bats<--test framework 
.kitchen.yml 
metadata.rb
‣attributes 
‣recipes 
‣templates 
▾test 
▾integration 
▾default<--test suite name 
▾bats<--test framework 
htop_installed.bats<--the actual test 
.kitchen.yml 
metadata.rb
Test file htop_installed.bats 
#!/usr/bin/env bats 
@test "htop binary is found in PATH"{ 
run which htop 
[ "$status"-eq 0 ] 
}
5 
commit 
StackonEC2
$./opsrun.rb92ca56ec-1672-4db0-8c6e-a8566e7db671 'echo $SHELL' 
ruby: warning: RUBY_HEAP_MIN_SLOTS isobsolete. UseRUBY_GC_HEAP_INIT_SLOTS instead. 
Abouttoruna scripton stack92ca56ec-1672-4db0-8c6e- a8566e7db671 on 2 online instances 
... 
... 
jenkins2: 
/bin/bash 
php-app1: 
/bin/bash 
$
http://bit.ly/awsevals

Weitere ähnliche Inhalte

Mehr von Amazon Web Services

Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 
Come costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSCome costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSAmazon Web Services
 
AWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei serverAWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei serverAmazon Web Services
 
Crea dashboard interattive con Amazon QuickSight
Crea dashboard interattive con Amazon QuickSightCrea dashboard interattive con Amazon QuickSight
Crea dashboard interattive con Amazon QuickSightAmazon Web Services
 
Costruisci modelli di Machine Learning con Amazon SageMaker Autopilot
Costruisci modelli di Machine Learning con Amazon SageMaker AutopilotCostruisci modelli di Machine Learning con Amazon SageMaker Autopilot
Costruisci modelli di Machine Learning con Amazon SageMaker AutopilotAmazon Web Services
 

Mehr von Amazon Web Services (20)

Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 
Come costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSCome costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWS
 
AWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei serverAWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei server
 
Crea dashboard interattive con Amazon QuickSight
Crea dashboard interattive con Amazon QuickSightCrea dashboard interattive con Amazon QuickSight
Crea dashboard interattive con Amazon QuickSight
 
Costruisci modelli di Machine Learning con Amazon SageMaker Autopilot
Costruisci modelli di Machine Learning con Amazon SageMaker AutopilotCostruisci modelli di Machine Learning con Amazon SageMaker Autopilot
Costruisci modelli di Machine Learning con Amazon SageMaker Autopilot
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

(APP301) AWS OpsWorks Under the Hood | AWS re:Invent 2014

  • 1. November 12, 2014 | Las Vegas, NV Thomas Lobinger and Jonathan Weiss, Amazon Web Services
  • 2.
  • 3.
  • 4.
  • 5. OpsWorksBackend OpsWorksAgent Amazon EC2, Amazon EBS, EIP, Amazon VPC, Elastic Load Balancing…. Auto-Scaling, Auto-Healing…. On-instance execution viaChef client/zero Command JSON CommandLog+Status
  • 6. Chef Client & Chef Server
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. AWS OpsWorks recipes Yourcustomrecipes
  • 16.
  • 17.
  • 19. appserver = search(:node, "role:php-app").first Chef::Log.info(”Private IP: #{appserver[:private_ip]}")
  • 20. appserver = search(:node, "role:php-app").first Chef::Log.info(”Private IP: #{appserver[:private_ip]}")
  • 21. { "opsworks": { "data_bags": { "bag_name1": { "item_name1: { "key1" : “value1”, "key2" : “value2”, ... } }, "bag_name2": { "item_name1": { "key1" : “value1”, "key2" : “value2”, ... } }, ... } } }
  • 22. { "opsworks": { "data_bags": { "myapp": { "mysql": { "username": "default-user", "password": "default-pass" } } } } } mything= data_bag_item("myapp", "mysql") Chef::Log.info("username: #{mything['username']}")
  • 23.
  • 24. user= ENV[“payment_provider_user“] password= ENV[“payment_provider_password“] PaymentGateway.new(user, password)
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. Change cookbook Push change Stop an instance Update cookbooks Start an instance Trigger event or runlist Check logs
  • 32.
  • 34. list # list event history (up to 10 events) # opsworks-agent-cli list 2014-11-06T10:26:58setup 2014-11-06T10:55:13configure2014-11-06T14:59:05execute_recipes 2014-11-07T18:25:53deploy 2014-11-07T18:34:11configure 2014-11-08T10:05:23configure 2014-11-08T14:43:43configure
  • 35. get # show JSON events (latest or by type/timestamp) # opsworks-agent-cli get { "ssh_users": { "2066": { "name": "thomas", "public_key": "ssh-rsa AAAAB3NzaC1...", "sudoer": true ...
  • 36. # list current agent folder and cookbooks # ls/opt/aws/opsworks/current cookbooks# OpsWorks cookbooks berkshelf-cookbooks# CookbooksfromBerkshelf site-cookbooks# Yourcookbooks merged-cookbooks# Resultingcookbooksforrun ...
  • 37. run # run last setup event (changed cookbooks, same JSON) # opsworks-agent-cli run setup # or select specific date # opsworks-agent-cli run 2014-11-08T14:43:43 [2014-11-12 13:06:41] INFO [opsworks-agent(17817)]:About to re-run 'setup' from 2014-11-08T14:43:43 Waiting for process 17817 ... Finished Chef run with exitcode 0
  • 38. # change recipe # cd /opt/aws/opsworks/current/site-cookbooks # vim mycookbooks/recipes/default.rb # confirm success # opsworks-agent-cli run setup # commit back to your git repo # git commit -am “can develop on instance“ # git push
  • 39.
  • 40.
  • 41. Destroy Create Converge Setup Verify Destroy
  • 42. .kitchen.yml driver: name: opsworks stack_id: vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz provisioner: name: shell busser: ruby_bindir: /opt/aws/opsworks/local/bin
  • 43. .kitchen.yml platforms: -name: Amazon Linux 2014.09 -name: Ubuntu 12.04 LTS -name: Ubuntu 14.04 LTS suites: -name: default run_list: -recipe[demo::default]
  • 44. # destroy, create, setup, converge, verify, destroy kitchen test kitchen verify [NAME|REGEXP|all]# run all 'tests' kitchen verify ubuntu# only ubuntus kitchen verify client# only client tests kitchen verify -c NUMBER# concurrency # Talk by Fletcher Nichol http://youtu.be/YzlCHAbJ7KM
  • 45. ‣attributes ‣recipes ‣templates ▾test ‣integration .kitchen.yml metadata.rb
  • 46. ‣attributes ‣recipes ‣templates ▾test ▾integration ‣default<--test suite name .kitchen.yml metadata.rb
  • 47. ‣attributes ‣recipes ‣templates ▾test ▾integration ▾default<--test suite name ‣bats<--test framework .kitchen.yml metadata.rb
  • 48. ‣attributes ‣recipes ‣templates ▾test ▾integration ▾default<--test suite name ▾bats<--test framework htop_installed.bats<--the actual test .kitchen.yml metadata.rb
  • 49. Test file htop_installed.bats #!/usr/bin/env bats @test "htop binary is found in PATH"{ run which htop [ "$status"-eq 0 ] }
  • 50.
  • 51.
  • 52.
  • 54.
  • 55.
  • 56. $./opsrun.rb92ca56ec-1672-4db0-8c6e-a8566e7db671 'echo $SHELL' ruby: warning: RUBY_HEAP_MIN_SLOTS isobsolete. UseRUBY_GC_HEAP_INIT_SLOTS instead. Abouttoruna scripton stack92ca56ec-1672-4db0-8c6e- a8566e7db671 on 2 online instances ... ... jenkins2: /bin/bash php-app1: /bin/bash $
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.