automating with ansible

27
Ricardo Schmidt / [email protected] Automating with Ansible

Upload: ricardo-schmidt

Post on 16-Jul-2015

144 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Automating with Ansible

Ricardo Schmidt / [email protected]

Automating with Ansible

Page 2: Automating with Ansible

Enjoy tonight!

+ +

Page 3: Automating with Ansible

Who Am I?

- - -

- define devops user

- user: name=Ricardo Schmidt

[email protected]

accent=Brazilian

Page 4: Automating with Ansible

What we will use in this presentation

- Linux

- YAML

My examples use:

- Vagrant

- EC2/AWS

Page 5: Automating with Ansible

What’s Ansible?

• Open source tool, created +- 3 years ago by Michael DeHaan.

• Configuration Management + Application Deployment +

Provisioning + Orchestration.

• Written in Python.

• Competes with Puppet, Chef, Salt Stack.

Page 6: Automating with Ansible

Ansible is…

• Fast

• Clear

• Complete

• Secure

Page 7: Automating with Ansible

Fast

• Minimal Setup

• Manage 5 or 5000 nodes

• Short learning curve - It is easy to learn

Page 8: Automating with Ansible

Clear

• Developers

• System Administrators

• IT Management

Page 9: Automating with Ansible

Complete

configuration

management

deployment

orchestration provisioning

Page 10: Automating with Ansible

Secure

• Go Agentless!

• SSH transport

• No additional firewall rules

• No additional open ports

• Use your own user

• You can sudo

Page 11: Automating with Ansible

Dynamic Provisioning

• Ansible can manage your cloud.

Page 12: Automating with Ansible

Key Components of Ansible

• Inventory

• Modules/Tasks

• Ad-Hocs

• Plays

• Playbooks

Page 13: Automating with Ansible

Inventory

• Hosts and Groups

• Port and address

• Remote/sudo usernames

Page 14: Automating with Ansible

Inventory: Hosts

web1.example.com ansible_ssh_port=5555 ansible_ssh_host=192.168.1.50

Inventory Name SSH port Connection address

Page 15: Automating with Ansible

Inventory: Groups

[webservers]

web1.example.com ansible_ssh_port=22 ansible_ssh_host=192.168.1.50

web2.example.com ansible_ssh_port=22 ansible_ssh_host=192.168.1.51

web3.example.com ansible_ssh_port=22 ansible_ssh_host=192.168.1.52

[database]

mysql1.example.com ansible_ssh_port=22 ansible_ssh_host=192.168.1.54

mysql2.example.com ansible_ssh_port=22 ansible_ssh_host=192.168.1.55

Page 16: Automating with Ansible

Modules

• Bits of code copied to the target system.

• Modules avoid changes to the system unless a change

needs to be made.

• You can write your own modules.

Page 17: Automating with Ansible

Modules: Commonly Used

• apt/yum

• copy

• ec2

• file

• service

• git

• user

200+ Ansible

Modules

Page 18: Automating with Ansible

Tasks

Task is a declaration about the state of a system.

- name: install memcached

yum: name=memcached state=present

- name: Create database user with all database privileges

mysql_user: name=bob password=12345 priv=*.*:ALL

state=present

Page 19: Automating with Ansible

• Ad-Hoc

• Playbook

Page 20: Automating with Ansible

Ad-Hoc commands

$ ansible web-hosts -m file -a "path=/opt/cache state=directory"

$ ansible web-hosts -m yum -a "name=nginx state=present"

$ ansible web-hosts -m service -a "name=nginx enabled=yes state=started"

Page 21: Automating with Ansible

Playbook / Play

---

- name: This is Play 1

hosts: web-servers

remote_user: fred

sudo: yes

tasks:

- name: create user

user: name=ricardo

- name: install nginx

yum: name=nginx state=present

- name: This is Play 2

hosts: memcache-1

remote_user: root

tasks:

- name: install memcached

yum: name=memcached state=present

- name: start memcached

service: name=memcached state=started

- name: copy file ABC to somewhere

files: name=/etc/abc state=/etc/abc

Page 22: Automating with Ansible

Demo Time

• inventory

• ad-hoc commands

• playbook

Page 23: Automating with Ansible

Support to Windows

Starting in version 1.7, Ansible also contains support

for managing Windows machines. This uses native

powershell remoting, rather than SSH.

Page 24: Automating with Ansible

Ansible Galaxy

• Collection of 500 roles

• Community reviewed

• Great starting point

http://galaxy.ansible.com

Page 25: Automating with Ansible

What we didn’t talk…

• Variables

• Templates

• Roles

• Ansible-vault

• Ansible Tower

Page 26: Automating with Ansible

How should I start with Ansible?

ansible.com

docs.ansible.com

twitter: @ansible

Page 27: Automating with Ansible

Q&A

Thanks!

Looking for a new Job?

strut.ly is hiring! Talk to me!

Ricardo Schmidt - [email protected]