50
APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io CONGA Martin Wehner, pro!vision GmbH

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

APACHE SLING & FRIENDS TECH MEETUPBERLIN, 25-27 SEPTEMBER 2017

Automate AEM Deployment with Ansible and wcm.io CONGAMartin Wehner, pro!vision GmbH

Page 2: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

About the Speaker

2

▪ R&D engineer at pro!vision▪ AEM since CQ 3.x

https://www.pro-vision.de

Martin Wehner

Page 3: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

3

The Challenges

Page 4: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Challenges

4

▪ Systems take too long to setup▪ Teams struggle maintaining their systems▪ Ops resources are scarce▪ “Hardcore” ops don’t know AEM▪ Nobody knows why a system is configured

the way it is

Page 5: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Goals

5

▪ Make it easy:▪ For teams to maintain internal & customer systems▪ To recreate systems quickly and reliably

▪ Just update the CONGA config and have it deployed automatically

▪ You shouldn’t need to touch the automation at all▪ Plug the deployment hole in CONGA

Page 6: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

6

CONGA

Page 7: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

What is CONGA?

7

▪ Configuration generator▪ Many AEM/OSGi specific features▪ Separation of configuration & environment▪ Maven integration▪ Extensible with plugins▪ Comes with generic set of AEM roles

Page 8: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Meta Model

8

Page 9: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Simplified CONGA Model

9

Environment

QSCONGA Definitions

Roledefinitions

File templates

Environment

PROD

QS ConfigurationApache

AEM

Tomcat

PROD Configuration

+

+ =

=Apache

AEM

Tomcat

Apache

AEMTomcat

Tomcat TomcatAEM

Apache

Apache

Apache

AEM

Tomcat

Page 10: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Output Options

10

▪ Plain text files e.g. properties, scripts, dispatcher & HTTPd config

▪ JSON files▪ XML files

Page 11: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Output Options

11

▪ OSGi configuration snippets▪ Sling provisioning model▪ AEM content package, e.g.

▪ OSGi configurations▪ Translator languages nodes▪ Community SRP config▪ Sling mappings▪ System users▪ etc.

Page 12: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Role File Definition

12

- file: wcm-io-samples-aem-cms-config.provisioningdir: packagestemplate: wcm-io-samples-aem-cms-config.provisioning.hbspostProcessors:- aem-contentpackage-osgiconfigpostProcessorOptions:contentPackage:

name: wcm-io-samples-aem-cms-configrootPath: /apps/wcm-io-samples-aem-cms-config/configfilters:- filter: /apps/wcm-io-samples-aem-cms-config

Page 13: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Environment

13

nodes:

- node: aem-authorroles:- role: aem-cmsvariants:- aem-author

config:jvm.heapspace.max: 2048mquickstart.rootPath: /opt/adobe/aemquickstart.port: 4502

Page 14: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

But..

14

“CONGA is not a deployment automation tool”

“CONGA only generates files. Further distribution of these files (e.g. copy to server, deploy via HTTP etc.) is not part of the tool.”

Page 15: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

15

Ansible

Page 16: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

What is Ansible?

16

▪ “Automation for Everyone”▪ More approachable than Puppet & Chef▪ Python▪ Agentless▪ Pushes tasks via SSH▪ Huge ecosystem of modules & roles

Page 17: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Ansible Sample

17

---- hosts: webservers

roles:- common- aem

- tasks:- copy:

src: startdest: "{{ aem_home }}/crx-quickstart/bin"

Page 18: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

So to sum it up..

18

▪ CONGA is great at generating AEM artifacts but doesn’t do anything else

▪ Ansible is great a deploying stuff but doesn’t know about AEM

Page 19: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

19

Integration+

Page 20: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

The Approach

20

▪ No duplication of configuration between CONGA and Ansible

▪ Make the CONGA configuration model available to Ansible (and other automation tools)

▪ CONGA generates model YAML▪ For each CONGA role, create a matching Ansible

roles that “knows” how to deploy it

Page 21: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

The Approach

21

▪ Role should handle all possible configurations▪ The Ansible role has to ensures that:

▪ The service to be configured is installed▪ All implicit dependencies are available

▪ It should be possible to use 3rd party roles

Page 22: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Best of Both Worlds

22

CONGA AEM

Templating

Ansible Simplicity & Ecosystem

Pre-made Generic

Roles

(Almost) Free

Automation

Page 23: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

23

Implementation

Page 24: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Facts in Ansible

24

- name: Create cache root directory.file:path: "{{ conga_config.dispatcher.cacheRootPath }}"state: directory

- name: Enable Apache modules required by CONGA role.apache2_module:name: "{{ item }}"state: present

with_items: "{{ conga_config.httpd.modules }}"

- name: Setup SSL if required by CONGA variant.include: setup_ssl.ymlwhen: conga_variant == "ssl" or conga_variant == "no-ssl+ssl"

Page 25: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

CONGA Facts in Ansible

25

- name: Create cache root directory.file:path: "{{ conga_config.dispatcher.cacheRootPath }}"state: directory

- name: Enable Apache modules required by CONGA role.apache2_module:name: "{{ item }}"state: present

with_items: "{{ conga_config.httpd.modules }}"

- name: Setup SSL if required by CONGA variant.include: setup_ssl.ymlwhen: conga_variant == "ssl" or conga_variant == "no-ssl+ssl"

Page 26: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Basic Steps

26

Compile CONGA configuration

Fetch configuration repository

Run CONGA Maven plugin

Apply Ansible Roles

Resolve CONGA context

Parse CONGA model

Inject CONGA facts into Ansible context

Page 27: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Hosts Interaction

27

Control HostNexus

Repos

RPM/APT

CONGAArtifacts

AEM Packages

AEM 1

AEM 2

Apache

ConfigureOS, Java & AEM

ConfigureOS & Apache

InstallAEM Packages

GitHub Ansible Roles

Config Repo

Page 28: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Basic Integration Playbook

28

- hosts: localhostroles:- { role: conga-maven,

conga_maven_git_repo: "https://github.com/wcm-io/wcm-io-samples.git" }

- hosts: aem

pre_tasks:- conga_facts:

conga_role_mapping: aem-cms

roles:- { role: aem-cms, aem_home: "{{ conga_config.quickstart.rootPath }}" }- conga-aem-cms

Page 29: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Basic Integration Playbook

29

- hosts: localhostroles:- { role: conga-maven,

conga_maven_git_repo: "https://github.com/wcm-io/wcm-io-samples.git" }

- hosts: aem

pre_tasks:- conga_facts:

conga_role_mapping: aem-cms

roles:- { role: aem-cms, aem_home: "{{ conga_config.quickstart.rootPath }}" }- conga-aem-cms- conga-your-project

Page 30: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

30

Main Ansible Roles

Page 31: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

conga-facts

31

▪ Centerpiece of the integration▪ Resolves the current CONGA context▪ Parses CONGA configuration model▪ Supplies the proper configuration values as

Ansible facts▪ Both an action plugin and a role

Page 32: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

conga-maven

32

▪ Gets configuration from Git▪ Runs Maven plugin to generate configuration▪ Not required, you can also use a pre-

compiled configuration

Page 33: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

conga-files

33

▪ Deploys generated configuration files to target host

▪ Meant to be included or used as dependency of higher-level roles

▪ Options to filter the list of files and mangle the paths

Page 34: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

conga-aem-package

34

▪ Deploys AEM packages to target host▪ Uses wcm.io Content Package Maven Plugin

internally▪ Restarts AEM as required

Page 35: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

aem-cms

35

▪ Installs AEM from:▪ Local JAR▪ Nexus▪ Distribution Package

▪ Ensures Java is installed▪ Creates user, group and AEM service as required▪ Decoupled from CONGA

Page 36: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

aem-dispatcher

36

▪ Installs dispatcher module from:▪ Local Tarball▪ Distribution Package

▪ Ensures Apache is installed▪ Configures SSL dependencies and SELinux

as required

Page 37: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Other roles

37

+ various internal application and support roles

Role Purpose

aem-service Controls AEM startup and shutdown

conga-aem-cms Deploys CONGA role aem-cmsconga-aem-dispatcher-(common) Deploys CONGA roles aem-dispatcher-*

Page 38: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

38

Implementation Challenges

Page 39: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Integration Challenges

39

▪ The only unit of reusability in Ansible is the role▪ Ansibles internal execution model is pretty static▪ The current execution context is difficult to obtain▪ Not always a clear-cut separation of concerns

between CONGA and Ansible

Page 40: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

AEM Challenges

40

▪ AEM has too many knobs to fiddle to expose them all in monolithic automation unit

▪ Requires an interdependent set of roles, each controlling an aspect of the system

▪ Startup & Cluster Orchestration

Page 41: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

41

Current State

Page 42: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Status

42

▪ Published on GitHub▪ Controls deployment of adaptTo() and

pro!vision corporate websites▪ Integrated in CI▪ Used in multiple customer projects

Page 43: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Distribution Support

43

▪ Works on:▪ CentOS/RHEL▪ Ubuntu▪ Debian

▪ Doesn’t do Windows▪ Additional distributions added as required

Page 44: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

44

Next Steps

Page 45: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Improvements

45

▪ Tighter inventory integration▪ Crypto/Ansible Vault support for CONGA▪ Generalize AEM/Dispatcher roles▪ Refactor CONGA roles▪ Publish on Ansible Galaxy

Page 46: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Resources

46

https://www.ansible.com/http://devops.wcm.io/conga/https://github.com/wcm-io-devopshttps://github.com/adaptto/2017-automate-aem-deployment-ansible-conga

Page 47: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

47

Thank You

Page 48: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Advantages

48

▪ Describe your setup completely in CONGA▪ Reuse the pre-made generic Ansible roles▪ Combines:

▪ CONGA AEM templating power▪ Ansible simplicity & ecosystem

Page 49: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

Basic Flow

49

Generate CONGA

configuration

Clone/update configuration

repository

Run CONGA Maven plugin

Apply Ansible Roles

Parse CONGA model

Resolve CONGA context (node, role, variant)

Inject CONGA facts into

Ansible context

Page 50: APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 … · 2019. 9. 1. · APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Automate AEM Deployment with Ansible and wcm.io

50

Demo