This document discusses using Chef to automate the deployment and management of Dynatrace across an organization's network. It describes how the Ontario Teachers' Pension Plan Board uses Dynatrace to monitor applications and is starting to use Chef to automate their environments, including Dynatrace. It outlines challenges such as needing manual intervention for Dynatrace installations, which can be addressed using tools like Expect. It also discusses approaches like using a cookbook topology with base and wrapper cookbooks to define primitives and extend functionality from non-production to production environments.
Infrastructure Automation How to Use Chef For DevOps Success
1. 1 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
Infrastructure Automation:
How to Use Chef For DevOps Success
Tweet your thoughts & questions using #APMLive
2. 2 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
Cooking Up Dynatrace
Piyush Chugh
Advisory Technical Systems Analyst
Ontario Teachers’ Pension Plan Board
3. 3 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• With $140.8 billion in assets as of December 31, 2013, the
Ontario Teachers' Pension Plan is the largest single-profession
pension plan in Canada.
• An independent organization, it invests the pension fund's
assets and administers the pensions of 307,000 active and
retired teachers in Ontario.
About Ontario Teachers’ Pension Plan Board
http://www.otpp.com/
4. 4 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Name: Piyush Chugh
• Title: Advisory Technical Systems Analyst
• Helpful Description: Full Stack Hacker*, Devops person
About Piyush
* Hacker in a tinkering sense of the word,
and NOT in an intruding sense
5. 5 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Overview
• Implementation + Challenges
• Questions
The Plan
7. 7 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Primarily a Java shop
• IBM WebSphere
• Tomcat
• Scope
• Test Centre: ~20 agents
• Production: ~50 agents
Dynatrace at Teachers’
8. 8 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Focus on identifying application
problems early
• Testing out special sensors before
they are deployed in production
• Monitoring and Analysis in
Production
• Custom dashboards
• Detailed alerting
• User Experience Management
(UEM)
Dynatrace at Teachers’
9. 9 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• We use Dynatrace to monitor and analyze our business
applications
• We are starting to use chef to automate all our environments
• Dynatrace is another environment for us to manage
• Impetus: We needed to upgrade from 5.5 to 6.0
What does Chef have to do with Dynatrace?
11. 11 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Automation Platform
• Chef automates
• how applications are configured,
• deployed, and
• managed across your network
• At scale
What is Chef?
https://docs.chef.io/
12. 12 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Simple concepts
• achieving desired state
• centralized modeling of IT infrastructure
• building blocks
What is Chef?
https://docs.chef.io/
13. 13 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Create a username for tomcat
Basic Chef Recipe Example
user ‘tomcat’ do
comment ‘Tomcat User’
gid ‘apps’
shell ‘/bin/false’
action :create
end
14. 14 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Make a directory and download a tarball there
Basic Chef Recipe Example
directory ‘/usr/incoming’ do
group ‘apps’
end
remote_file ‘/usr/incoming/tomcat_latest.tgz’ do
source ‘http://xyz.com/tomcat_rc2.tgz’
owner ‘tomcat’
end
16. 16 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
General Pattern (pseudo-code)
Download jar files
if not dynatrace.is_installed then
dynatrace.install
else
if not dynatrace.is_latest_version then
dynatrace.upgrade
dynatrace.migrate
end
end
17. 17 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• We pre-download the jar files from Dynatrace servers and store
them in a local repository
• Some useful options for repositories
• Artifactory [http://www.jfrog.com/artifactory/]
• Sonatype Nexus [http://www.sonatype.org/nexus/]
• Apache Archiva [https://archiva.apache.org]
• Simple File server with an http server
• Chef recipes refer to this location and downloads binaries
Dynatrace Binaries
18. 18 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Recipe invokes the standard command:
Installation
java –jar <path_to_jar>
Except! There is manual intervention required!!
19. 19 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Expect is a program that "talks" to other interactive programs
according to a script.
Installation: Enter ‘expect’
http://expect.sourceforge.net/
20. 20 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
spawn java -jar <%= @artifact_path %>
<% unless @type == 'dtserver' %>
expect "Enter 32 or 64:" send "64n“
<% end %>
expect "Do you want to install to this directory? (Y/N)“
send "Nn“
expect "Please set the new installation directory/path:“
send "<%= @version_dir %>n“
expect "Do you want to install to this directory? (Y/N)“
send "Yn“
expect "Installation finished successfully"
21. 21 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Templating syntax used by Chef and ruby
• Squid rockets are resolved at run time
Squid Rocket <%=
spawn java -jar <%= @artifact_path %>
spawn java -jar /incoming/dynatrace-6.0.0.jar
22. 22 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• “Russian Nesting Doll” Model
• Base Cookbook
• Defines primitives
• Exposes attributes
• Wrapper Cookbook
• Overrides
• Extends
Cookbook Topology
https://docs.chef.io/lwrp.html
23. 23 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• Defines new primitives for ease of use
Cookbook Topology
dtserver ‘prod-6.0’ do
deploy_dir ‘/usr/local/dt/6.0’
java_max_perm ‘256M’
action [:install, :migrate]
end
24. 24 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• We use the scaling capability of Chef to deploy latest agent
binaries to various machines
What about the agents?
execute 'untar-agent' do
not_if "[ -d #{node.otpp_dynatrace.agent_home} ]“
command "tar xzf #{tarball}“
cwd node.otpp_dynatrace.agent_location
end
• And use middleware layer cookbooks to hook them together
25. 25 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #APMLive
• The base and wrapper pattern allows us to work on to support
deployment pipeline
• Basic pattern:
• Single Base Cookbook
• Non-Production wrapper
• Production wrapper
From drawing board to Production
Base
Dev
Chef
Primitives
Prod