Slide 1

Slide 1 text

INTRODUCTION TO ANSIBLE COMPLETE IT AUTOMATION

Slide 2

Slide 2 text

Ansible is automation for everyone. Ansible seamlessly unites workflow orchestration with configuration management, provisioning, and application deployment in one easy-to-use and deploy platform. Regardless of where you start with Ansible, you’ll find our simple, powerful and agentless automation platform has the capabilities to solve your most challenging problems. ansible.com COMPLETE IT AUTOMATION

Slide 3

Slide 3 text

WHY ANSIBLE? USE CASES ▸ Provisioning ▸ Configuration Management ▸ App Deployment ▸ Continuous Delivery ▸ Security & Compliance ▸ Orchestration

Slide 4

Slide 4 text

WHY ANSIBLE? INTEGRATIONS: INFRASTRUCTURE ▸ Bare metal ▸ Cobbler, Stacki, RackHD, … ▸ Virtualization ▸ VMware, Red Hat Enterprise Virtualization (RHEV), Libvirt, Xenserver, Vagrant ▸ Operating systems ▸ Linux, Windows, OS X

Slide 5

Slide 5 text

WHY ANSIBLE? INTEGRATIONS: NETWORKS ▸ Arista ▸ Cisco ▸ Cumulus ▸ Juniper

Slide 6

Slide 6 text

WHY ANSIBLE? INTEGRATIONS: CONTAINERS ▸ Containers ▸ Docker orchestration ▸ Building containers

Slide 7

Slide 7 text

WHY ANSIBLE? INTEGRATIONS: CLOUD ▸ AWS ▸ Google Cloud ▸ Digital Ocean ▸ Linode ▸ OpenStack

Slide 8

Slide 8 text

WHY ANSIBLE? INTEGRATIONS: DEVOPS TOOLS ▸ Source Control ▸ Monitoring ▸ Chat ▸ Analytics ▸ Testing & Continuous Integration

Slide 9

Slide 9 text

WHY ANSIBLE? MISC. ▸ Secure (SSH) ▸ Agentless ▸ Source control your infrastructure ▸ Minimal dependencies

Slide 10

Slide 10 text

HOW? INVENTORY [webservers] web1.example.com web2.example.com [webservers:vars] load_balancer=lb1.example.com [lbservers] lb1.example.com [dbservers] db1.example.com db2.example.com slave=true [ruby] web1.example.com web2.example.com lb1.example.com [east] web1.example.com db1.example.com lb1.example.com [west] web2.example.com db2.example.com

Slide 11

Slide 11 text

HOW? INVENTORY [webservers] web1.example.com web2.example.com [webservers:vars] load_balancer=lb1.example.com [lbservers] lb1.example.com [dbservers] db1.example.com db2.example.com slave=true [ruby] web1.example.com web2.example.com lb1.example.com [east] web1.example.com db1.example.com lb1.example.com [west] web2.example.com db2.example.com ALL RUBY WEBSERVERS web1.example.com web2.example.com LBSERVERS lb1.example.com DBSERVERS db1.example.com db2.example.com EAST web1.example.com db1.example.com lb1.example.com WEST web2.example.com db2.example.com

Slide 12

Slide 12 text

HOW? DYNAMIC INVENTORY ▸ Executable that returns JSON ▸ AWS ▸ OpenStack ▸ Google Compute Engine ▸ DigitalOcean ▸ and more community contributed executables

Slide 13

Slide 13 text

HOW? DYNAMIC INVENTORY { "all" : { "hosts" : [ "web1.example.com", "web2.example.com", "lb1.example.com", "db1.example.com", "db2.example.com" ], "vars" : { "load_balancer": "lb1.example.com" } }, "_meta" : { "hostvars" : { "db2.example.com": { "slave": "true" } } }, "webservers": { "hosts": [ "web1.example.com", "web2.example.com" ] }, "lbservers": { "hosts": [ "lb1.example.com" ] }, "dbservers": { "hosts": [ "db1.example.com", "db2.example.com" ] }, "ruby": { "hosts": [ "web1.example.com", "web2.example.com", "lb1.example.com" ] }, "east": { "hosts": [ "web1.example.com", "db1.example.com", "lb1.example.com" ] }, "west": { "hosts": [ "web2.example.com", "db2.example.com" ] } }

Slide 14

Slide 14 text

HOW? PLAYBOOKS ▸ Expressed in YAML ▸ Jinja2 templates ▸ A playbook is a list of plays ▸ A play maps a group of hosts to roles or tasks ▸ A task is a call to an ansible module

Slide 15

Slide 15 text

HOW? PLAYBOOK EXAMPLE - hosts: webservers vars: http_port: 80 max_clients: 200 tasks: - name: ensure nginx is at the latest version apt: name=nginx state=latest - name: write the nginx config file template: src=/srv/nginx.conf.j2 dest=/etc/nginx/nginx.conf - name: restart nginx service: name: nginx state: restarted - name: ensure nginx is running (and enable it at boot) service: name=nginx state=started enabled=yes

Slide 16

Slide 16 text

HOW? MODULES ▸ Modules are [generally] idempotent ▸ Executes on the targeted hosts ▸ Hundreds of core and community contributed modules ▸ Write your own ▸ http://docs.ansible.com/ansible/list_of_all_modules.html

Slide 17

Slide 17 text

DEMO DEPLOYING THE MONCTONUG WEBSITE ▸ Create a Digital Ocean droplet ▸ Install dependencies required for building site ▸ Configure authorization keys for accessing GitHub and Eventbrite ▸ Build site ▸ Configure nginx

Slide 18

Slide 18 text

DIRECTORY STRUCTURE . ├── ansible.cfg ├── build.yml ├── configure-webserver.yml ├── group_vars │ ├── all │ │ ├── secrets.ml ** encrypted with ansible-vault ** │ │ └── vars.yml │ └── webservers.yml ├── inventory │ └── digital_ocean.py ├── roles │ ├── build-monctonug │ │ └── tasks │ │ └── main.yml │ │ └── templates │ │ └── dotenv │ ├── configure-git │ │ └── tasks │ │ └── main.yml │ └── configure-nginx │ ├── defaults │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── templates │ ├── default.conf.j2 │ └── monctonug.conf.j2 └── run DEMO

Slide 19

Slide 19 text

QUESTIONS [email protected] / @VROY