introduction to ansible

12
Introduction To Ansible Kasun Madura Rathnayaka. Senior Sys/Devops Engineer BSc (Hons) Electrical and Information, Engineering AWS Certified Solutions Architect Associate AMIE(SL),CCIP,RHCE,RHCSA,CCNA.ITIL [email protected] skype:kasunmadura141

Upload: kasun-madura-rathnayaka

Post on 12-Apr-2017

184 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Introduction to ansible

Introduction To Ansible

Kasun Madura Rathnayaka.Senior Sys/Devops Engineer

BSc (Hons) Electrical and Information, Engineering AWS Certified Solutions Architect Associate AMIE(SL),CCIP,RHCE,RHCSA,[email protected] skype:kasunmadura141

Page 2: Introduction to ansible

Continuous Integration

Teams integrate their work multiple times per day.

Each integration is verified by an automated build

Significantly reduces integration problems

Develop cohesive software more rapidly

Source: Martin Fowler

Page 3: Introduction to ansible

Continuous Integration

Page 4: Introduction to ansible

Continuous Integration and Automation Tools

●CI Tools

○ Jenkins ,Teamcity ,Buildbot, Bamboo

●Automation Tools

○ Puppet,Chef,Ansible

●Version Control

○ svn,git,perforce

●Build Tool

○ Maven,ant,grant

● Code quality inspection tool

○ Sonar,Sonarqube

Page 5: Introduction to ansible

Ansible

What is Anible ?

Why we need Ansible ?

Advantage and Disadvantages..

Compare with Puppet and Chef

Page 6: Introduction to ansible

What is Ansible

● “radically simple IT automation platform”

●Describe the intended system state using playbooks written in YAML

●Requires no agent on the managed machine, only a Python interpreter and an

SSH server

Page 7: Introduction to ansible

Shell Script● #!/bin/bash

● echo "fs.file-max=20000" | sudo tee -a /etc/sysclt.conf

● sudo apt-get -y install build-essential

● sudo mkdir -p /var/www/kasun

● sudo apt-get -y install apache2

● sudo a2enmod rewrite

● sudo tee /etc/apache2/sites-available/mysite <<ENDOFFILE

● <VirtualHost *:80>

● DocumentRoot "/var/www/kasun/"

● ServerName www.kasun.com

● # Other directives here

● </VirtualHost>

● ENDOFFILE

Page 8: Introduction to ansible

Ad-hoc configurationConfiguration file /etc/ansible/ansible.cfg

1st ansible command :)

$ cat >hosts [webservers] 192.168.1.40 ^D

$ ansible -vvv all -i hosts -u root -m ping

$ ansible -vvv webserver -i hosts -u root -m apt -a 'name=cowsay state=present'

$ ssh 192.169.1.40 cowsay moo

Page 9: Introduction to ansible

Playbooks

Consolidate tasks and configuration knobs into a single YAML file

Support templating—both in playbooks and in file templates—by way of Jinja2

Can be one file, or split up into many roles (more later!)

Page 10: Introduction to ansible

Running a playbook

• ansible-playbook playbook.yml

• -i to specify a local inventory file (e.g. hosts)

• -k if you have to enter a password for this run

• Use authorized_key to install an SSH key for future runs

Page 11: Introduction to ansible

Real Example

Get the ball rolling :)

Page 12: Introduction to ansible

Discussion

Quiz