Configuration Management
~ S. Meena
July 16, 2014 1StackExpress.com© 2013-14 | Controlled document for use
by authorized person ONLY.
Configuration management
• Creating and maintaining consistency
• Installing, updating, reporting
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
2
What is it?
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
3
We need a new way to work
Infrastructure needs to be
â—ŹRepeatable
â—ŹTestable
â—ŹScalable
â—ŹFlexible:
â—ŹWork on web architectures and cloud computing
Why we need it?
DevOps?
1. Agile Development Practices applied to
infrastructure
2. New tooling to automate infrastructure
3. Testing, testing, testing
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
4
Who does it?
DevOps (continued)
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
5
Development
•Team focus
•IDE/workbench
•Agile methodology
•Source control
Who are they?
DevOps (continued)
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
6
Operations
•Individual focus
•Scripts Based
•No methodology
•No Source control
Operations as Code
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
7
Simple Application
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
8
Source: https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
Separate Database
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
9
Source: https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
Load balancer
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
10
Source: https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
HTTP Accelerator (Caching Reverse
Proxy)
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
11
Source: https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
Master-Slave Database Replication
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
12
Source: https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
Combining the Concepts
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
13
Source: https://www.digitalocean.com/community/tutorials/5-common-server-setups-for-
your-web-application
Nodes
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
14
Lb.srv.01
cache.srv.01
cache.srv.02
app.srv.01
app.srv.02
db.srv.01
db.srv.02
Nodes ~ Roles
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
15
loadbalancer
memcached
memcached
webserver
webserver
dbMaster
dbSlave
Recipes
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
16
Loadbalancer
(HAProxy) Memcached
(memcached)
memcached
Webserver
(Apache)
webserver
dbMaster
(mysql)
dbSlave
• Apache2
• Mysql
• Haproxy
• memcached
Infrastructure as code
• Automate the creation and maintenance of
servers (to the farthest extent possible)
– Build from source control
– Utilize open source tools
– Ensure testability
• A practice popularized by the DevOps
movement.
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
17
Challenges
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
18
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
19
Configuration Synchronization
Server-A Server - B
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
20
Configuration Drift
Server-A Server - B Server - B
Manual Change
No Manual Changes
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
21
You can’t
touch this
How Servers Should be?
• Immutable Servers: a server that once
deployed, is never modified, merely replaced
with a new updated instance.
• PhoenixServer: A server should be like a
phoenix, regularly rising from the ashes
• SnowflakeServer: server that is difficult to
reproduce.
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
22
Immutable servers
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
23
http://martinfowler.com/bliki/ImmutableServer.html
Phoenix Server
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
24
• It avoids configuration drift and
hence protecting server from
becoming SnowflakeServer
• use software that automatically
re-syncs servers with a known
baseline
Properties of CM Tools
• DECLARATIVE LANGUAGE
• KNOWN STATE
• IDEMPOTENCE
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
25
DECLARATIVE LANGUAGE
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
26
Package
File1
File2
Service
KNOWN STATE
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
27
File1
packa
ge
service
File2
File1
Server-A Server - B
converge
Code run
IDEMPOTENCE
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
28
Server-A Server - B
Architecture
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
29
Standalone
• Runs locally
• Requires that a cookbook (and any of its
dependencies) be on the same physical disk as
the node
• Eg. Chef-solo, ansible
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
30
Client-server
• A client/server architecture.
• The server has a reference configuration.
• The client queries the server.
• The client makes change in order to match
the reference configuration.
• Eg. Chef-server, ansible-tower
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
31
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
32
1. REQ: “Can you give my configuration model ?“
2. ACK: “Ok, for you, that's it.”
3. “I make the necessary in order to fulfil it.”
4. (optional) “Thank you, I'm ok, no error” or
“I had a problem”.
Benefit of this approach
• Centralized management
• Mass deployment
• Automated management
• Configuration customization
• Abstraction Layer
• Idempotence
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
33
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
34
Tools
CM Usage Flow
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
35
Chef is..
â—ŹA library for Configuration Management
â—ŹA Configuration Management System
â—ŹA Systems Integration Platform
â—ŹAn API for your entire infrastructure
â—ŹOpen-source!
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
36
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
37
Chef’s Architecture
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
38
Vagrant
$> vagrant box add
$> vagrant init
$> vagrant up
$> vagrant ssh
$> vagrant provision
$> vagrant suspend
$> vagrant destroy
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
39
Dependency management
Tools:
Berkshelf
librarian-chef
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
40
Unit testing
chefspec
(ruby gem)
https://github.com/acrmp/chefspec
Test a cookbook
fast and from
anywhere
spec/default_spec.rb
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
41
Continuous testing
guard
(ruby gem)
https://github.com/guard/guard
When a local file
changes, then
run unit tests.
Guardfile
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
42
Integration Testing
test kitchen
(ruby gem)
https://github.com/opscode/test-kitchen
Run and test
cookbook in
Vagrant or LXC
container.
.kitchen.yml
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
43
Static Analysis
foodcritic
(ruby gem)
http://acrmp.github.io/foodcritic/
Style guide and
find defects in
cookbook source
code.
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
44
Continuous integration
Jenkins
(Java app)
When a change
is checked in,
then run tests
and deploy to
Chef Server.
References
• Images:
– https://www.digitalocean.com/community/tutorials/5-common-server-
setups-for-your-web-application
• Slideshare
– Infrastructure as Code (BBWorld/DevCon13) by Mike McGarr
– Automated infrastructure is on the menu by jtimberman
– Configuration manager presentation by jeyg
– Infrastructure as Code - ABUG Session by Patrick Debois
July 16, 2014
StackExpress.com© 2013-14 | Controlled
document for use by authorized person
ONLY.
45

Devops & Configuration management tools

  • 1.
    Configuration Management ~ S.Meena July 16, 2014 1StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY.
  • 2.
    Configuration management • Creatingand maintaining consistency • Installing, updating, reporting July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 2 What is it?
  • 3.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 3 We need a new way to work Infrastructure needs to be ●Repeatable ●Testable ●Scalable ●Flexible: ●Work on web architectures and cloud computing Why we need it?
  • 4.
    DevOps? 1. Agile DevelopmentPractices applied to infrastructure 2. New tooling to automate infrastructure 3. Testing, testing, testing July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 4 Who does it?
  • 5.
    DevOps (continued) July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 5 Development •Team focus •IDE/workbench •Agile methodology •Source control Who are they?
  • 6.
    DevOps (continued) July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 6 Operations •Individual focus •Scripts Based •No methodology •No Source control
  • 7.
    Operations as Code July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 7
  • 8.
    Simple Application July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 8 Source: https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application
  • 9.
    Separate Database July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 9 Source: https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application
  • 10.
    Load balancer July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 10 Source: https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application
  • 11.
    HTTP Accelerator (CachingReverse Proxy) July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 11 Source: https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application
  • 12.
    Master-Slave Database Replication July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 12 Source: https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application
  • 13.
    Combining the Concepts July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 13 Source: https://www.digitalocean.com/community/tutorials/5-common-server-setups-for- your-web-application
  • 14.
    Nodes July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 14 Lb.srv.01 cache.srv.01 cache.srv.02 app.srv.01 app.srv.02 db.srv.01 db.srv.02
  • 15.
    Nodes ~ Roles July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 15 loadbalancer memcached memcached webserver webserver dbMaster dbSlave
  • 16.
    Recipes July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 16 Loadbalancer (HAProxy) Memcached (memcached) memcached Webserver (Apache) webserver dbMaster (mysql) dbSlave • Apache2 • Mysql • Haproxy • memcached
  • 17.
    Infrastructure as code •Automate the creation and maintenance of servers (to the farthest extent possible) – Build from source control – Utilize open source tools – Ensure testability • A practice popularized by the DevOps movement. July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 17
  • 18.
    Challenges July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 18
  • 19.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 19 Configuration Synchronization Server-A Server - B
  • 20.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 20 Configuration Drift Server-A Server - B Server - B Manual Change
  • 21.
    No Manual Changes July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 21 You can’t touch this
  • 22.
    How Servers Shouldbe? • Immutable Servers: a server that once deployed, is never modified, merely replaced with a new updated instance. • PhoenixServer: A server should be like a phoenix, regularly rising from the ashes • SnowflakeServer: server that is difficult to reproduce. July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 22
  • 23.
    Immutable servers July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 23 http://martinfowler.com/bliki/ImmutableServer.html
  • 24.
    Phoenix Server July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 24 • It avoids configuration drift and hence protecting server from becoming SnowflakeServer • use software that automatically re-syncs servers with a known baseline
  • 25.
    Properties of CMTools • DECLARATIVE LANGUAGE • KNOWN STATE • IDEMPOTENCE July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 25
  • 26.
    DECLARATIVE LANGUAGE July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 26 Package File1 File2 Service
  • 27.
    KNOWN STATE July 16,2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 27 File1 packa ge service File2 File1 Server-A Server - B converge Code run
  • 28.
    IDEMPOTENCE July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 28 Server-A Server - B
  • 29.
    Architecture July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 29
  • 30.
    Standalone • Runs locally •Requires that a cookbook (and any of its dependencies) be on the same physical disk as the node • Eg. Chef-solo, ansible July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 30
  • 31.
    Client-server • A client/serverarchitecture. • The server has a reference configuration. • The client queries the server. • The client makes change in order to match the reference configuration. • Eg. Chef-server, ansible-tower July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 31
  • 32.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 32 1. REQ: “Can you give my configuration model ?“ 2. ACK: “Ok, for you, that's it.” 3. “I make the necessary in order to fulfil it.” 4. (optional) “Thank you, I'm ok, no error” or “I had a problem”.
  • 33.
    Benefit of thisapproach • Centralized management • Mass deployment • Automated management • Configuration customization • Abstraction Layer • Idempotence July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 33
  • 34.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 34 Tools
  • 35.
    CM Usage Flow July16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 35
  • 36.
    Chef is.. ●A libraryfor Configuration Management ●A Configuration Management System ●A Systems Integration Platform ●An API for your entire infrastructure ●Open-source! July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 36
  • 37.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 37 Chef’s Architecture
  • 38.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 38 Vagrant $> vagrant box add $> vagrant init $> vagrant up $> vagrant ssh $> vagrant provision $> vagrant suspend $> vagrant destroy
  • 39.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 39 Dependency management Tools: Berkshelf librarian-chef
  • 40.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 40 Unit testing chefspec (ruby gem) https://github.com/acrmp/chefspec Test a cookbook fast and from anywhere spec/default_spec.rb
  • 41.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 41 Continuous testing guard (ruby gem) https://github.com/guard/guard When a local file changes, then run unit tests. Guardfile
  • 42.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 42 Integration Testing test kitchen (ruby gem) https://github.com/opscode/test-kitchen Run and test cookbook in Vagrant or LXC container. .kitchen.yml
  • 43.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 43 Static Analysis foodcritic (ruby gem) http://acrmp.github.io/foodcritic/ Style guide and find defects in cookbook source code.
  • 44.
    July 16, 2014 StackExpress.com©2013-14 | Controlled document for use by authorized person ONLY. 44 Continuous integration Jenkins (Java app) When a change is checked in, then run tests and deploy to Chef Server.
  • 45.
    References • Images: – https://www.digitalocean.com/community/tutorials/5-common-server- setups-for-your-web-application •Slideshare – Infrastructure as Code (BBWorld/DevCon13) by Mike McGarr – Automated infrastructure is on the menu by jtimberman – Configuration manager presentation by jeyg – Infrastructure as Code - ABUG Session by Patrick Debois July 16, 2014 StackExpress.com© 2013-14 | Controlled document for use by authorized person ONLY. 45