Ansible Introduction

35

description

Ansible is tool for Configuration Management. The big difference to Chef and Puppet is, that Ansible doesn't need a Master and doesn't need a special client on the servers. It works completely via SSH and the configuration is done in Yaml. These slides give a short introduction & motivation for Ansible.

Transcript of Ansible Introduction

Page 1: Ansible Introduction
Page 2: Ansible Introduction

Who I am?

❖ Robert Reiz ❖ Software Developer ❖ I started VersionEye ❖ I’m NOT your IT guy!

Page 3: Ansible Introduction

2012 VersionEye is running on Heroku.

Page 4: Ansible Introduction

2013 VersionEye moves to Yunicon because of performance reasons.

2 XXL Servers! Lovely hand crafted.

Page 5: Ansible Introduction

2013 VersionEye moves to AWS because of the Amazon Activate Program!

Page 6: Ansible Introduction

WWW

API

APP

APP

RabbitMQ

Tasks

MongoDB MongoDB MongoDB

Elastic Search

Memcached

Crawlers x N

VersionEye 2014

Page 7: Ansible Introduction

Handcrafted Servers are

❖ hard to maintain ❖ very time/cost intensive ❖ setup is not easily reproducible ❖ many times very buggy

Page 8: Ansible Introduction

Options to automate IT

PuppetChef

SaltAnsible

Page 9: Ansible Introduction

Reasons for Ansible

❖ No Master ❖ No Agents ❖ Configuration in Yaml ❖ Very easy to learn

Page 10: Ansible Introduction

Server

Server

Server

Server

You SSH

Ansible works via SSH. No Master Server! No Agent on the Server is required.

Page 11: Ansible Introduction

Installation

Page 12: Ansible Introduction

sudo pip install ansible

Page 13: Ansible Introduction

brew update brew install ansible

Page 14: Ansible Introduction

Ansible Concepts

❖ Inventory ❖ Playbooks ❖ Roles ❖ Tasks / Handlers / Vars ❖ Modules

Page 15: Ansible Introduction

Inventory

Page 16: Ansible Introduction

Inventory

[mongo_master] 168.197.1.14 !

[mongo_slaves] 168.197.1.15 168.197.1.16 168.197.1.17 !

[www] 168.197.1.2

Inventory files are simple text files which describe your servers.

IP Addresses or DNS Names grouped by names.

Page 17: Ansible Introduction

Inventory

[mongo_master] 168.197.1.14 !

[mongo_slaves] mongo1.server mongo2.server mongo3.server !

[www] 168.197.1.2

List of target hosts. Usually located in

/etc/ansible/hosts

Page 18: Ansible Introduction

Inventory

[mongo_master] mongo-[a:c]-server !

[mongo_slaves] mongo[1:3].server !

[www] {{my_little_webserver}}

Inventory files can take advantage of variables and enumerations

Page 19: Ansible Introduction

Playbooks

Page 20: Ansible Introduction

Simple Playbook--- - hosts: dev_servers user: ubuntu sudo: true roles: - java - memcached !- hosts: www_servers user: ubuntu sudo: true roles: - nginx

group name from the inventory file

server auth

Role which should be installed on the server

Page 21: Ansible Introduction

Roles / Modules

Page 22: Ansible Introduction

apt module

--- - name: update debian packages apt: update_cache=true !

- name: install Java JDK apt: name=openjdk-7-jdk state=present

Page 23: Ansible Introduction

apt module

--- - name: update debian packages apt: update_cache=true !

- name: install Java JDK apt: name=openjdk-7-jdk state=present

Documentation of this step!

Module

Parameters of the Module

Page 24: Ansible Introduction

--- - name: update debian packages apt: update_cache=true !- name: upgrade packages apt: upgrade=full !- name: ensure that basic packages are installed apt: name={{ item }} state=present with_items: - tree - wget - links2 - gcc - g++ - make - autoconf - automake - libssl-dev - libcurl4-openssl-dev

Page 25: Ansible Introduction

Thousands of

Modules

Page 26: Ansible Introduction

shell module

--- - name: do what you want shell: /opt/I_can_do_what_I_want.sh

Page 27: Ansible Introduction

A role directory

Page 28: Ansible Introduction

Variables

--- app_dir: /var/www/versioneye

rails_app/vars/main.yml--- - name: create versioneye directory command: mkdir -p {{ app_dir }}

rails_app/tasks/main.yml

Page 29: Ansible Introduction

Handlers

--- - name: restart mongodb service: name=mongod state=restarted

mongo/handlers/main.yml

- name: copy MongoDB configuration to the server copy: src=mongodb.conf dest=/etc/mongodb.conf notify: restart mongodb

mongo/tasks/main.yml

Page 30: Ansible Introduction

Files

mongo/files/mongodb.list

- name: add MongoDB debian server to the list of servers copy: src=mongodb.list dest=/etc/apt/sources.list.d/mongodb.list

mongo/tasks/main.yml

Page 31: Ansible Introduction

Demo

Page 32: Ansible Introduction

Demo

http://www.ansible.com/tower

Page 33: Ansible Introduction

Demo

https://galaxy.ansible.com/

Page 34: Ansible Introduction

Further Links

http://blog.versioneye.com/2014/07/03/intro-to-ansible/

http://blog.versioneye.com/2014/09/24/rebuilding-capistrano-like-deployment-with-ansible/

Intro do Ansible

Rebuilding Capistrano like deployment with Ansible

Page 35: Ansible Introduction

@RobertReiz

Questions?