Automated Deployments

Post on 12-Jun-2015

717 views 0 download

Tags:

description

Shows an excerpt of the PERFORM 2014 Conference's Hands-On Training on Automated Deployments. Tells the why and the how and differentiates between agent-based and agentless solutions, such as Chef, Puppet or Ansible. Goes into greater detail on the Ansible host automation tool.

Transcript of Automated Deployments

1 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Orlando, October 2014

Automated Deployments – Hands-On Martin Etmajer

martin.etmajer@dynatrace.comSenior Technology Strategist @

Dynatrace

2 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Insert headshot image here “Martin Etmajer

Senior Technology Strategist @ Dynatrace

martin.etmajer@dynatrace.com

@metmajer

3 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

From Continuous Integration toContinuous Delivery

4 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Integration

5 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Integration

6 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Integration

7 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Integration

8 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

9 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

10 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

11 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

12 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

13 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

14 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

✔ ✔

15 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

✔ ✔

16 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

✔ ✔ ✔

17 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

✔ ✔ ✔

18 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Continuous Delivery Build Pipeline

✔ ✔ ✔

19 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Introduction toAutomated Deployments

20 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Motivation

Production environments are often grown “works of art”:

» Not entirely reproducible

» Manual changes applied whenever needed

» Not even similar to the environments developers have

“Works on my machine.”

21 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Automation

22 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Makes provisioning a repeatable, low-risk “push-button” activity

» By providing executable specifications

» No manual changes involved (regarded immutable)

» The process is tested with each execution (builds confidence)

Benefits: Automation

RecreateEnvironments

23 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Makes provisioning an engineering discipline:

» Iteratively plan, code, test and verify

» Open to frequently changing requirements (agile)

Helps align efforts between Development and Operations:

» Jointly define desired environmental states

» Integrate and respect each others processes

Benefits: Automation

24 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

OPERATIONS

DEVELOPMENT

Benefits: Automation

current iteration(2 weeks)

time

Planning

Implementand test Verification

25 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Automation

Allows the provisioning process to be integrated into the Continuous Delivery build pipeline (build automation server):

» Environments can be provisioned multiple times a day

» When the process fails in staging, the release candidate is discarded - the production environment will not be harmed

26 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Automation

Reduces the risks of software releases by providing a consistent process for all staging and production environments

Risks?

» Differing library versions

» Differing middleware configurations

» Differing environmental variables in the OS

» Differing number of max. open file handles in the OS,…

27 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Auditability

28 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Auditability

What, who, why and when?

» Keep all (executable) specifications in VCS

» Provide meaningful commit messages (changelog)

» Build history tells you which revision got deployed

“Infrastructure as Code”

29 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Repeatability

30 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Repeatability

Establishes a process that is repeatable at any time:

» Environments are no longer in the hands of single people

» Any (authorized) person could recreate the environments

» Requires command execution to be idempotent

31 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Benefits: Repeatability

Allows for testability of the deployment process:

» Failures will be caught early-on in the process

What if something breaks?

» Caught a bug: use a version that is known to work

» Hardware failure: redeploy environment in minutes

Minimizes MTTR

32 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Deployment Automation Solutions:Agent-based vs. Agentless

33 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Solutions

34 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Deployments (Chef, Puppet)

35 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Deployments (Chef, Puppet)

36 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Deployments (Chef, Puppet)

37 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Deployments (Chef, Puppet)

» Can be used in client-server or client-only modes

» Client must be installed on each host to be provisioned

» Clients have dependencies: Ruby

38 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agent-Based Deployments

Puppet

» Written and extensible in Ruby (comes with a DSL)

» Order of statement does not specify order of execution

» Huge ecosystem (PuppetDB, MCollective, Hiera)

» Large entrance barrier

39 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agentless Solutions

40 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agentless Deployments (Ansible)

41 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agentless Deployments (Ansible)

42 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agentless Deployments (Ansible)

43 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Agentless Deployments (Ansible)

44 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible

» Written and extensible (Python)

» Human- and machine-readable configuration (YAML)

» No boot-strapping required on deployment hosts (SSH)

» Simple, easy to ramp up with (think of new employees!)

» Clear and concise documentation

Agentless Deployments

45 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Hands-On Training: Environment

46 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Sample Environment

Web Server

Frontend

Application Server

Backend

Application ServerDatabase

VCS Build Automation

check out deploy

47 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Sample Environment

Web Server FrontendApplication Server

BackendApplication Server

Database

Apache Tomcat Apache TomcatApache PostgreSQL

VCS

Git

Build Automation

Jenkins

check out deploy

48 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Use Case: Deploy Dynatrace Agents

Web Server FrontendApplication Server

BackendApplication Server

Database

Apache Tomcat Apache TomcatApache PostgreSQL

VCS

Git

Build Automation

Jenkins

check out deploy

49 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Use Case: Deploy Dynatrace Agents

Web Server FrontendApplication Server

BackendApplication Server

Database

Apache Tomcat Apache TomcatApache PostgreSQL

VCS

Git

Build Automation

Jenkins

check out deploy

Dynatrace Server

50 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Hands-On Training: Environment

51 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

1. Inject dynaTrace Agents into Apache Tomcats

2. Load database data into PostgreSQL

3. Integrate all this into Jenkins

Today you will learn how to automatically...

52 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible: Core Concepts

53 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts:Inventories

54 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Inventories

» Ansible provisions groups of servers at once

» Groups and hosts are stored in inventory files

» An inventory file is expressed in a simple INI format

» Default location: /etc/ansible/hosts

» bit.ly/ansible-inventory

55 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Inventories

[frontends]frontend.example.com

[backends]backend.example.com

[frontends:vars]dt_agent_name=frontend

[backends:vars]dt_agent_name=backend

GroupHost

GroupVariables Variable

56 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts:Ad-hoc Commands

57 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Ad-hoc Commands

ansible <host-pattern> [options]

Examples?

» ansible localhost -m copy –a ‘src=/usr/bin/a dest=/usr/bin/b’

» ansible appservers –a ‘/sbin/reboot’ –f 10

» ansible appservers –a ‘/sbin/reboot’ –f 10–u deploy ––sudo ––ask–sudo–pass

Module Arguments

58 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Ad-hoc Commands

ansible <host-pattern> [options]

Examples?

» ansible localhost -m copy –a ‘src=/usr/bin/a dest=/usr/bin/b’

» ansible appservers –a ‘/sbin/reboot’ –f 10

» ansible appservers –a ‘/sbin/reboot’ –f 10–u deploy ––sudo ––ask–sudo–pass

Forks

59 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Ad-hoc Commands

ansible <host-pattern> [options]

Examples?

» ansible localhost -m copy –a ‘src=/usr/bin/a dest=/usr/bin/b’

» ansible appservers –a ‘/sbin/reboot’ –f 10

» ansible appservers –a ‘/sbin/reboot’ –f 10–u deploy ––sudo ––ask–sudo–pass

User Use sudoAsk passwordinteractively

60 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks

61 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks

ansible-playbook [–i <inventory>] <playbook>

Playbooks

» Describe policies your remote systems shall enforce

» Consist of variables, tasks, handlers, files and roles

» Are expressed in the YAML format

» bit.ly/ansible-playbook

62 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

YAML (YAML Ain’t No Markup Language): Motivation

» “All data structures can be expressed via dicts, lists and scalars”

» Simplicity makes it much easier to read and parse than XML

Excursion to YAML

63 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Blockname: Michael Jordanage: 34

YAML Excursion » Dictionaries

--- # Inline{ name: Michael Jordan, age: 34 }

64 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Blockname: Michael Jordanage: 34

YAML Excursion » Dictionaries

--- # Inline{ name: Michael Jordan, age: 34 }

Document

65 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Blockname: Michael Jordanage: 34

YAML Excursion » Dictionaries

--- # Inline{ name: Michael Jordan, age: 34 }

key: value

SameIndentation

level

66 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Blockname: Michael Jordanage: 34

YAML Excursion » Dictionaries

--- # Inline{ name: Michael Jordan, age: 34 }

Comment

Optional quotesfor Strings

67 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Block- milk- bread- butter

YAML Excursion » Lists

--- # Inline[milk, bread, butter]

68 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Block- milk- bread- butter

YAML Excursion » Lists

--- # Inline[milk, bread, butter]

Items start withhyphen + space

69 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # Block- milk- bread- butter

YAML Excursion » Lists

--- # Inline[milk, bread, butter]Same

indentationlevel

70 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

---men: - { name: Jimi Hendrix, year: 1970 } - { name: Jim Morrison, year: 1971 }women: - { name: Janis Joplin, year: 1970 } - { name: Amy Winehouse, year: 2011 }

YAML Excursion » Complex

71 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

---men: - { name: Jimi Hendrix, year: 1970 } - { name: Jim Morrison, year: 1971 }women: - { name: Janis Joplin, year: 1970 } - { name: Amy Winehouse, year: 2011 }

YAML Excursion » Complex

Dictionary

List

72 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

---men: - { name: Jimi Hendrix, year: 1970 } - { name: Jim Morrison, year: 1971 }women: - { name: Janis Joplin, year: 1970 } - { name: Amy Winehouse, year: 2011 }

YAML Excursion » Complex

List

Dictionary

73 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # appservers.yml- hosts: frontends:backends vars_files: - variables.yml handlers: - name: restart tomcat service: name=tomcat state=restarted tasks: - name: Inject dynaTrace Java agent into Apache Tomcat template: > src=templates/tomcat-setenv.sh dest={{ tomcat_home }}/bin/setenv.sh notify: restart tomcat remote_user: deploy sudo: yes

Ansible Concepts: Playbooks

Play

74 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks

# production

[frontends]frontend.example.com

[backends]backend.example.com

[frontends:vars]dt_agent_name=frontend

[backends:vars]dt_agent_name=backend

75 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks

# templates/tomcat-setenv.sh

CATALINA_OPTS="$CATALINA_OPTS \ -agentpath:{{ dt_agent_dir }}/libdtagent.so =name={{ dt_agent_name }},collector={{ dt_collector_url }}"

76 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # variables.ymltomcat_home: /opt/tomcatdt_agent_dir: /opt/dynatrace/agentsdt_collector_url: dynatrace.example.com

Ansible Concepts: Playbooks

77 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks

ansible-playbook –i production appservers.yml

PLAY [frontends:backends] ******************************************************

TASK: [Inject dynaTrace Java agent into Apache Tomcat] ************************ changed: [backend.example.com]changed: [frontend.example.com]

PLAY RECAP ************************************************************************backend.example.com : ok=1 changed=1 unreachable=0 failed=0 frontend.example.com : ok=1 changed=1 unreachable=0 failed=0

Run!

78 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # playbook.yml- include: appservers.yml- include: dbservers.yml- include: webservers.yml

Ansible Concepts: Playbooks

Includes multiple playsinto a single playbook

79 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Usage

» {{ foo }}

» {{ foo[i] }}

» {{ foo.bar }}

» Hello, my name is {{ foo }}

» bit.ly/ansible-variables

80 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variables

81 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variables

Forces ‘foo’ to be defined

82 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variables

Defaults ‘foo’ to 0 if undefined

83 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variables

Computes the minimum in ‘list’

84 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variables

Computes distinct values in ‘list’

85 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Advance Usage

» {{ foo | mandatory }}

» {{ foo | default(0) }}

» {{ list| min }}

» {{ list| unique }}

» {{ list1 | union(list2) }}

» bit.ly/ansible-variablesComputes a join of lists ‘list1 and ‘list2’

86 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

Validity

» Valid: ‘foo_bar’, ‘foo5’

» Invalid: ‘foo-bar’, ‘foo bar’, ‘foo.bar’, ‘5foo’, ‘5’

87 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

--- # playbook.yml- hosts: all vars: - cleanup_home: yes - settings: ports: http: 80 ssl: 443 …

Inlined

88 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Variables

--- # playbook.yml- hosts: all vars_files: - variables.yml …

--- # variables.ymlcleanup_home: yessettings: ports: http: 80 ssl: 443

Imported

89 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # playbook.yml- hosts: all tasks: - { include: create-user.yml, user: deploy }…

Ansible Concepts: Playbooks » Variables

Defined intask inclusion

90 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

--- # playbook.yml- hosts: all roles: - { role: create-user, user: deploy }…

Ansible Concepts: Playbooks » Variables

Defined inrole inclusion

91 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

ansible –e ‘user=deploy’ playbook.yml

Ansible Concepts: Playbooks » Variables

Defined atinvocation

92 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Tasks

Tasks are...

» invocations of Ansible modules

» the units that do the actual deployment and configuration

» bit.ly/ansible-module

93 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Tasks

Example: Install package ‘apache2’

--- # webservers.yml- hosts: webservers tasks: - name: Install package ‘apache2’ apt: pkg=apache2 state=latest update_cache: yes

94 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Tasks

Example: Copy file from src (localhost) to dest (remote host)

--- # webservers.yml- hosts: webservers tasks: - name: Copy file from ‘foo.conf’ to /etc/default copy: > src=/srv/files/foo.conf dest=/etc/default owner=deploy group=deploy mode=644

95 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Roles

» Are the preferred means to organize and reuse related tasks

» Build on the idea of include files to form clean abstractions

» bit.ly/ansible-roles

96 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Reusing Roles in a Play

--- # webservers.yml- hosts: webservers roles: - { role: common } - { role: apache2 } remote_user: deploy sudo: yes

97 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Top-level Playbook

98 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Plays

99 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Holds a role named ‘x’

100 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Dependencies

101 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Default variables

102 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Files

103 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Handlers

104 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Tasks

105 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml Templates

106 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014

Ansible Concepts: Playbooks » Roles

Best Practice: Directory Layout for Role-based Playbooks

playbook.ymlappservers.ymldbservers.ymlwebservers.yml

/roles/x/roles/x/meta/main.yml/roles/x/defaults/main.yml/roles/x/files/roles/x/handlers/main.yml/roles/x/tasks/main.yml/roles/x/templates/main.yml/roles/x/vars/main.yml

Variables

107 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE #Perform2014