master chef class: learn how to quickly cook delightful cq/aem infrastructures

74
Master Chef class hps://github.com/francoisledro/connectcon-chef-repo hp://www.slideshare.net/francoisledro/master-chef-class-learn-how-to-quickly-cook-delightful-cqaem-infrastructures Francois Le Dro– Nicolas Peltier Let’s cook delightful AEM infrastructures

Upload: francois-le-droff

Post on 27-Aug-2014

639 views

Category:

Software


6 download

DESCRIPTION

ConnectCon 2014 presentation Francois and Nicolas share their latest experiment coding AEM 6 infrastructure with Chef. Learn how to start from bare metal - virtual, physical or cloud - servers and turn them, in matter of minutes, into a production ready AEM 6 infrastructure. Think author and publish farms, optional SSL, dispatcher, and clustering with MongoDB) Meanwhile you’ll be given a comprehensive overview of Chef resources and techniques enabling you to accelerate, scale, simplify and secure your development and release workflow.

TRANSCRIPT

Page 1: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Master Chef class

https://github.com/francoisledroff/connectcon-chef-repo

http://www.slideshare.net/francoisledroff/master-chef-class-learn-how-to-quickly-cook-delightful-cqaem-infrastructures

Francois Le Droff – Nicolas Peltier

Let’s cook delightful AEM infrastructures

/master-chef-class-learn-how-to-quickly-cook-delightful-cqaem-infrastructures

Page 2: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

@francoisledroff

Page 3: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

@npeltier

Page 4: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Agenda

•!What •!How •!Why

Page 5: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

What ?

Page 6: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

“ An automation platform that transforms

infrastructure into code ”

Page 7: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Infrastructure ? noun \ˈin-frə-ˌstrək-chər

[1] A Collection of –!Resources:

•! Network nodes •! File systems, files, folders, symbolic links, disk mounts •! Users, groups •! Packages, software •! Configurations

–!Acting in concert –!To offer a service

–! [1] Introduction to Chef

Page 8: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Infrastructure as Code?

•! Does not only replace your shell scripts •! Does allow:

–! to build your infra from a set of bare metal servers (called Nodes) Even on heterogeneous OS and Architecture

–! to abstract the convergence of your infrastructure (your Nodes) through code

–! to make this (Nodes) convergence idempotent

State A --> State B (ex: install)

Chef Client finished, 147/153 resources updated

State B --> State B (ex: check)

Chef Client finished, 0/153 resources updated

State C --> State B (ex: back to normal)

Chef Client finished, 48/153 resources updated

Page 9: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

•! Created in 2009, Edited by Opscode/Chef

•! Apache License

•! On-top-of/in Ruby

•! Very active community

•! http://community.opscode.com

•! #learnChef

•! https://learnchef.opscode.com/

Chef ?

p://community.opscode.com

Page 10: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

What does Chef code look like ?

•!Recipes •!Attributes •!Resources

•!Cookbooks

Page 11: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Recipes

Fundamental configuration element •! Authored in Ruby •! Queries , defines attributes •! Manipulates Resources •! Manipulates LW Resources •! Leverages Libraries & Templates

•! Stored in Cookbooks –! Default Attributes –! Recipes –! LW Resource Providers –! Libraries –! Templates

recipes

cookbooks

Page 12: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

•! aem-cookbook/recipes/default.rb case node['platform_family']

when 'rhel' log 'this platform family is supported' do level :info

end else log 'this platform family is not supported' do

level :warn

end end

•! aem-cookbook/attributes/node.rb default['aem']['mode'] = 'publish'

default['aem']['port'] = '4503'

default['aem']['url'] = 'http://localhost:'+ node['aem']['port']

default['aem']['mode'] = 'publish'

default['aem']['port'] = '4503'

default['aem']['url'] = 'http://localhost:'+ node['aemaem']['port']

aem-cookbook/recipes/default.rbcase node['platform_family']

when 'rhel' log 'this platform family is supported' do level :info

end else log 'this platform family is not supported' do

level :warn

end end

Attributes attributes

Page 13: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Recipes : Resources & LW Resources

•! aem-cookbook/recipes/default.rb

remote_file node['aem']['quickstart_jar'] do source node['aem']['repo_url']

owner node['aem']['user']

group node['aem']['group']

checksum '3043859473'

action :create_if_missing

notifies :restart, 'service[aem]', :delayed

end or

artifact_file node['aem']['quickstart_jar'] do location 'com.day.cq:cq5:jar:5.5.0.20120220'

nexus_configuration nexus_configuration_object

owner node['aem']['user']

group node['aem']['group']

notifies :restart, 'service[aem]', :delayed

end

artifact_file node['aem']['quickstart_jar'] do location 'com.day.cq:cq5:jar:5.5.0.20120220'

nexus_configuration nexus_configuration_object

owner node['aem']['user']

group node['aem']['group']

notifies :restart, 'service[aem]', :delayed

end

remote_file node['aem']['quickstart_jar'] do source node['aem']['repo_url']

owner node['aem']['user']

group node['aem']['group']

checksum '3043859473'

action :create_if_missing

notifies :restart, 'service[aem]', :delayed

end

recipes

Page 14: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Recipes : AEM LW Resources •! tacit-aem-cookbook/recipes/author.rb

node[:aem][:author][:deploy_pkgs].each do |pkg| aem_package pkg[:name] do version pkg[:version]

aem_instance ‘author’

package_url pkg[:url]

update pkg[:update]

user node[:aem][:author][:admin_user]

password node[:aem][:author][:admin_password]

port node[:aem][:author][:port]

group_id pkg[:group_id]

recursive pkg[:recursive]

properties_file pkg[:properties_file]

version_pattern pkg[:version_pattern]

action pkg[:action]

end end

node[:aem][:author][:deploy_pkgs].each do |pkg| aem_package pkg[:name] do version pkg[:version]

aem_instance ‘author’

package_url pkg[:url]

update pkg[:update]

user node[:aem][:author][:admin_user]

password node[:aem][:author][:admin_password]

port node[:aem][:author][:port]

group_id pkg[:group_id]

recursive pkg[:recursive]

properties_file pkg[:properties_file]

version_pattern pkg[:version_pattern]

action pkg[:action]

end end

recipes

Page 15: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

–! aem-cookbook/recipes/start.rb

ruby_block 'block_until_cq_operational' do block do Chef::Log.info 'Waiting until CQ is listening on port '+node['aem']['port']

until CQHelper.service_listening?(node['aem']['port']) sleep 1

Chef::Log.info('.')

end

Chef::Log.info 'Waiting until the CQ default page is responding'

test_url = URI.parse(node['aem']['url'])

until CQHelper.endpoint_responding?(test_url) sleep 1

Chef::Log.info('.')

end

end action :nothing

end

Recipes: Libraries recipes

© 2014 Adobe Systems Incorporated. © 2014 Adobe Systems Incorporated.

ruby_block 'block_until_cq_operational' do block do Chef::Log.info 'Waiting until CQ is listening on port '+node['aem']['port']

until CQHelper.service_listening?(node['aem']['port']) sleep 1

Chef::Log.info('.')

end

Chef::Log.info 'Waiting until the CQ default page isresponding'

test_url = URI.parse(node['aem']['url'])

until CQHelper.endpoint_responding?(test_url) sleep 1

Chef::Log.info('.')

end

end action :nothing

end

Page 16: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Cookbook patterns [1]

•! Library cookbooks: –! https://github.com/RiotGames/artifact-cookbook –! https://github.com/francoisledroff/chef-vault-util

•! Application cookbooks –! https://github.com/tacitknowledge/aem-cookbook –! https://github.com/francoisledroff/aem-cookbook –! https://github.com/onehealth-cookbooks/apache2 –! https://github.com/socrata-cookbooks/java –! https://github.com/hw-cookbooks/haproxy –! https://github.com/stevendanna/logrotate –! https://github.com/opscode-cookbooks/chef-splunk

•! Organization specific

–! Wrapper cookbooks –! Base cookbooks –! Environment cookbooks

[1] http://blog.vialstudios.com/the-environment-cookbook-pattern/

Library cookbooks: ps://github.com/RiotGames/artifact-cookbookps://github.com/francoisledro

cookbooks

Page 17: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

I got it

Page 18: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Wait a quick overview

Page 19: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef-server nodes

Page 20: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git

Chef-server nodes

ssh

env.

roles attributes

recipes

cookbooks

Page 21: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git

Chef-server nodes

RSA key Auth

ssh

knife

env.

roles attributes

recipes

Chef-DK

data bags

cookbooks RSA Keys

Page 22: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git

Chef-server nodes

RSA key Auth

ssh

knife

env.

roles attributes

recipes

Chef-DK

data bags

cookbooks RSA Keys

Search API

cookbooks org

data bags

attributes

env.

recipes

node object run-list

roles Web UI

versions

Page 23: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git

Chef-server nodes

RSA key Auth

ssh

RSA key Auth

knife

env.

roles attributes

recipes

Chef-DK

data bags

cookbooks RSA Keys

Search API

cookbooks org

data bags

attributes

env.

recipes

node object run-list

roles Web UI

versions

chef-clients

RSA Key

Page 24: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Search API knife

workstation

env.

roles attributes

cookbooks

recipes

Git

org

Chef-DK

github

Nexus

opscode rubygem

data bags

attributes

env.

data bags

cookbooks recipes

Chef-server nodes

RSA key Auth

ssh

https

yymaven redhat

RSA Keys

node object run-list

roles Web UI

versions

RSA key Auth

chef-clients

RSA Key

Page 25: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

How ?

Page 26: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Use case 0 : one AEM Author

author

Page 27: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Use case 0 : Chef Automation

–! Install the jdk –! Download the jar –! Install it as a service

–! A few aem cookbooks on github

•! https://github.com/francoisledroff/aem-cookbook •! https://github.com/tacitknowledge/aem-cookbook •! https://github.com/manosriglis/chef-aem •! https://github.com/QVCItalia/chef-aem

Page 28: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

OSS from opscode and elsewhere Chef, Ruby, rvm, bundler

knife

workstation

Chef-DK

opscode

$ curl –L https://www.opscode.com/chef/install.sh | sudo bash $ curl -sSL https://get.rvm.io | bash -s stable –-ruby=1.9.3 $ gem install bundler http://www.getchef.com/downloads/chef-dk

Page 29: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git ssh

A Chef repo in Git Every Chef automated infra needs a Chef Repository

github

$ git clone https://github.com/opscode/chef-repo.git

Made available for you at https://github.com/francoisledroff/connectcon-chef-repo

Page 30: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

node

Get Few Machines/Nodes to deploy your code/infra to

workstation

ssh

~/workspace/github/connectcon-chef-repo on ! master! $ vagrant plugin install vagrant-berkshelf --plugin-version 2.0.1 $ cat Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "CentOS-6.4-x86_64" config.vm.hostname = "connectcon-francois" config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box" config.berkshelf.enabled = true End $ vagrant up $ vagrant ssh Welcome to your Vagrant-built virtual machine. [vagrant@connectcon-francois ~]$

Page 31: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

A Chef Server comes in 3 flavors

•! On premise OS Chef Server

•! On premise Enterprise Chef

•! Hosted Enterprise Chef server

•! Local Alternatives: •! Chef-zero •! Chef-solo

Chef-server

Page 32: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

A Chef Org top-level entity for role-based access

org

Chef-server

https (ldap) Auth

Web UI

ps (ldap) Auth ps (ldap) Auth

https://chef.corp.adobe.com/organizations

Page 33: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

workstation

Git

ssh

A few private keys to associate your new chef repo with your chef server user and org

~/workspace/github/connectcon-chef-repo on ! master! $ ll .chef total 24 connectcon-validator.pem knife.rb ledroff.pem

org Chef-server Web UI

https

(lda

p) A

uth

RSA Keys

Page 34: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Bootstrap your nodes

knife

workstation Chef-server

RSA

key

Auth

node

org

RSA Keys

chef-clients

RSA Key

RSA

key

Auth

~/workspace/github/connectcon-chef-repo on ! master! $ knife bootstrap <your-node-fqdn> --sudo -x <your-sudoer>

Page 35: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef-server nodes

RSA key Auth

Search API attributes node object run-list chef-clients

Node Objects

Page 36: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Start Coding: Manage your Ruby dependencies

•! Use Bundler for RubyGem

~/workspace/github/connectcon-chef-repo on ! master! $ cat Gemfile source 'https://rubygems.org’ gem 'chef', '~> 11.10.0’ gem 'berkshelf', '~> 3.1.3‘ $ bundle install

Page 37: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Start Coding: Manage your Chef dependencies

•! A few aem cookbooks on github •! https://github.com/francoisledroff/aem-cookbook •! https://github.com/tacitknowledge/aem-cookbook

•! Use Berkshelf

$ cat Berksfile source "https://api.berkshelf.com” cookbook 'ntp', '~> 1.5.4' cookbook 'chef-client', '~> 3.2.0’ cookbook 'artifact', git: 'https://github.com/francoisledroff/artifact-cookbook.git', tag: '1.11.4’ cookbook 'aem', git: 'https://github.com/francoisledroff/aem-cookbook

Page 38: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Upload your cookbooks chef-client and ntp declared in your chef server org

knife

workstation org

Chef-DK

Chef-server

https

RSA

key

Aut

h

RSA Keys cookbooks

~/workspace/github/connectcon-chef-repo on ! master! $ berks install $ berks upload

cookbooks

Page 39: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Run-list

run_list "recipe[chef-client::default]", "recipe[chef-client::delete_validation]", "recipe[ntp]", "recipe[openssl::upgrade]"

Page 40: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Role

Base

name ”base” Description ”connecton base server role” run_list "recipe[chef-client::default]",

"recipe[chef-client::delete_validation]", "recipe[ntp]", "recipe[openssl::upgrade]"

Page 41: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Typical Roles connectcon-chef-repo/roles/

name ”publish” Description ”connecton aem publish server role” run_list ”role[base]”,”recipe[aem::publish]”

Mongo Author

Publish

Dispatcher

HA/LB

name "lb_dispatcher" description "connectcon roles for lb" run_list ”role[base]”,”recipe[haproxy::app_lb]” override_attributes('haproxy' => {'app_server_role' => ’dispatcher’})

Base

name ”base” Description ”connecton base server role” run_list "recipe[chef-client::default]",

"recipe[chef-client::delete_validation]", "recipe[ntp]", "recipe[openssl::upgrade]"

Page 42: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Apply Run-List to Nodes attributes

https://chef.corp.adobe.com/organizations

~/workspace/github/connectcon-chef-repo on ! master! $ knife node list $ knife node edit one.node.fqdn

Page 43: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef-client run [root@ot1slu010 ~]# sudo chef-client Starting Chef Client, version 11.12.8 resolving cookbooks for run list: ["chef-client::delete_validation", "ntp", “aem::author", “aem::start”]

* remote_file[/apps/publish/aem-author-4502.jar] action create_if_missing (up to date)

* file[/apps/publish/license.properties] action create (up to date) * cookbook_file[/apps/author/serverctl] action create (up to date) * execute[java] action run (skipped due to not_if) * service[aem] action enable (up to date)

Recipe: aaem::start * ruby_block[block_until_cq_operational] action nothing (skipped due to action :nothing)

* log[ensure_cq_is_running] action write Recipe: aaem::default * service[aem] action start - start service service[aem]

Recipe: aaem::start * ruby_block[block_until_cq_operational] action create - execute the ruby block block_until_cq_operational

Running handlers: Running handlers complete Chef Client finished, 2/27 resources updated in 9.770664 seconds

Page 44: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

So we have an Author : Use Case 0

Author Author

{ "name": ”<author-connectcon-fqdn>", "chef_environment": "dev”, "run_list": [ "role[author]" ] }

$ knife node edit author-connectcon-fqdn

Page 45: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Let’s add a publish : Use Case 1

{ "name": ”<publish-connectcon-fqdn>", "chef_environment": "dev”, "run_list": [ "role[publish]" ] }

$ knife node edit publish-connectcon-fqdn

Publish

Author

Page 46: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

And there is magic: Chef search API

•! tacit-aem-cookbook/providers/replicator.rb

https://github.com/tacitknowledge/aem-cookbook

hosts = [] search(:node, %Q(role:"#{role}"

AND aem_cluster_name:"#{cluster_name}")) do |n| log "Found host: #{n[:fqdn]}" hosts << { :ipaddress => n[:ipaddress],

… :name => n[:fqdn] } end … hosts.each do |h| … end

Page 47: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Replication configuration happens

#{role}:”publish” #{cluster_name}:”dev”

Author

Publish

Page 48: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Aem-Replicator API

aem_replicator "replicate_to_publish_servers" do local_user node[:aem][:author][:admin_user]

local_password node[:aem][:author][:admin_password]

local_port node[:aem][:author][:port]

remote_hosts node[:aem][:author][:replication_hosts]

dynamic_cluster node[:aem][:author][:find_replication_hosts_dynamically]

cluster_name node[:aem][:cluster_name]

cluster_role node[:aem][:publish][:cluster_role]

type :publish

action :add

end

•! tacit-aem-cookbook/recipes/author.rb

https://github.com/tacitknowledge/aem-cookbook

Page 49: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

What about Secret Management ?

aem_replicator "replicate_to_publish_servers" do local_user node[:aem][:author][:admin_user]

local_password node[:aem][:author][:admin_password] local_port node[:aem][:author][:port]

remote_hosts node[:aem][:author][:replication_hosts]

dynamic_cluster node[:aem][:author][:find_replication_hosts_dynamically]

cluster_name node[:aem][:cluster_name]

cluster_role node[:aem][:publish][:cluster_role]

type :publish

action :add

end

•! tacit-aem-cookbook/recipes/author.rb

https://github.com/tacitknowledge/aem-cookbook

Page 50: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Git

UX/Dev/QA/Ops

dev dev-stable prod ps

Chef-server

https RSA private key Auth

chef-client chef-client

chef-client chef-client

https RSA private key Auth •! Chef encrypted data bags

•! Encrypted for •! admin users •! whitelisted nodes

•! Managed by chef-vault ruby gem

•! Git Back up •! Encrypted obviously

Encrypted Data Bags with Chef-vault

Page 51: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef-Vault in Action:

include_recipe 'chef-vault-util::default'

item = chef_vault_item(node['aem']['vault_accounts'], node['aem']['vault_accounts_cq_admin_item']) cq_admin_username = item[node['aem']['vault_accounts_username_property']]

cq_admin_password = item[node['aem']['vault_accounts_password_property']]

log 'the secret accounts credential was fetched from a chef-vault enabled encrypted data_bag for username '+ cq_admin_username do level :info

end

•! francois-aem-cookbook/recipes/secure.rb

https://github.com/francoisledroff/aem-cookbook https://github.com/francoisledroff/chef-vault-util

$ knife vault update accounts prod_cq_admin -J accounts/prod_cq_admin.json -A "ledroff," --mode client -S "role:aem_server environment:prod"

Page 52: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Let’s add a Dispatcher : Use Case 2

Dispatcher

Author

Publish

Dispatcher Dispatcher

{ "name": ”<dispatcher-connectcon-fqdn>", "chef_environment": "dev”, "run_list": [ "role[dispatcher]" ] }

$ knife node edit dispatcher-connectcon-fqdn

Another Search Publish

Another Search

Page 53: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Let’s Add a Load Balancer : Use Case 3

HA/LB

Dispatcher

{ "name": ”<lb-connectcon-fqdn>", "chef_environment": "dev”, "run_list": [ "role[lb_dispatcher]" ] }

$ knife node edit lb-connectcon-fqdn

Author

Publish

Author

Publish Publish Publish

Dispatcher Dispatcher Dispatcher

Another Search

}

Dispatcher Dispatcher Dispatcher Dispatcher

Another Search

Page 54: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

•! myapp-cookbook/recipes/log.rb logrotate_app 'aem' do cookbook 'logrotate'

path node['myapp']['log_dir']

frequency node['myapp']['logrotate']['frequency']

rotate node['myapp']['logrotate']['rotate']

end include_recipe 'it-splunkforwarder::default’

•! myapp-cookbook/attributes/log.rb

default.splunkforwarder.inputs = [ {"input_path" =>

"#{node['aem']['log_dir']}/error.log",

… ]

default.splunkforwarder.inputs = [ {"input_path" =>

"#{node['aem']['log_dir']}/error.log",

… ]

Let’s add log monitoring: Use Case 4

myapp /recipes/log.rblogrotate_app 'aem' do

cookbook 'logrotate'

path node['myapp']['log_dir']

frequency node['myapp']['logrotate']['frequency']

rotate node['myapp']['logrotate']['rotate']

end include_recipe 'it-splunkforwarder::default’

Dispatcher

Author

Publish

Author

Publish Publish Publish

Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher

Publish

Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher Dispatcher

Publish Publish

Dispatcher Dispatcher Dispatcher Dispatcher

Publish

Dispatcher Dispatcher Dispatcher Dispatcher

Add the above in the base role Add the above in the base role

Page 55: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Let’s cluster things!

Page 56: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

AEM Production Infrastructure

LB/HA

Dispatcher

Publish

Author

MongoDB servers

Dispatcher

!" 3rd parties (your legacy, your cloud)

Page 57: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

you got it ?

Page 58: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Search API knife

workstation

env.

roles attributes

cookbooks

recipes

Git

org

Chef-DK

github

Nexus

opscode rubygem

data bags

attributes

env.

data bags

cookbooks recipes

Chef-server nodes

RSA key Auth

ssh

https

yymaven redhat

RSA Keys

node object run-list

roles Web UI

versions

RSA key Auth

chef-clients

RSA Key

Page 59: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

#LearnChef

Learn Stuff Automate IT infrastructure and application delivery

Learn Chef

Slide inspired by Spice up your recipe By Seth Vargo

Page 60: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

What Stuff ? •! Git Stuff •! Ruby stuff •! VM / Container stuff •! Cloud stuff •! Network stuff •! *nix tools and stuff •! OS Stuff

–! package management –! services

•! Chef Community Stuff •! Build and packaging stuff •! Continuous Delivery stuff •! Monitoring stuff •! Analytics stuff •! Messaging stuff •! Security Stuff

Page 61: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Why ?

Page 62: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Devops?

“ You built it You run it! ”

Page 63: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef, Devops ? No silver bullet.

https://twitter.com/DEVOPS_BORAT/status/52857016670105600

Page 64: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Chef, Devops ? No silver bullet.

https://twitter.com/mindweather/status/458653460234502144

Page 65: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Why ? “Accelerate, Simplify, Scale”

•! Breaking down the wall of confusion

•! As infra is code, it becomes: –! Testable –! Versionable –! Disposable –! Reproducible

•! “If it’s not in the source control system, it does not exist” @bdelacretaz

Page 66: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

https://ww

w.flickr.com

/photos/francoisledroff/6107220850/in/set-72157626126325552

Page 67: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

https://www.flickr.com/photos/blmoregon/7883684692

Page 68: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

AEM Production Infrastructure

LB/HA

Dispatcher

Publish

Author

MongoDB servers

Dispatcher

!" 3rd parties (your legacy, your cloud)

Page 69: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

One more publish?

LB/HA

Dispatcher

Publish

Author

!" MongoDB servers

Dispatcher

!" 3rd parties (cloud stuff)

Page 70: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

This needs to be configured

LB/HA

Dispatcher

Publish

Author

MongoDB servers

Dispatcher

!" 3rd parties (cloud stuff)

Page 71: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

A more complex production

Page 72: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Next scale of complexity…

Page 73: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.

Let’s Share the love

Page 74: Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures

© 2014 Adobe Systems Incorporated. All Rights Reserved.