SlideShare a Scribd company logo
1 of 66
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Brown bag - Crash course
Automation makes IT better
@soldasimo
simonesoldateschi
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Agenda
● Presentation (20’)
o The basics
o Playbooks
o Sharing code
● Q&A (5’)
● Quiz (5’)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
The basics
Installation on management host:
$ pip install ansible
That’s it!
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
The basics
Installing agent on
managed hosts:
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
The basics
Can be as simple as:
mail.example.com
or:
10.1.157.183
Create an inventory file
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
The basics
Is host alive?
$ ansible -i ~/etc/hosts all -m ping
Ansible - Quickstart
ss-dfw-00 | success >> {
"changed": false,
"ping": "pong"
}
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
The basics
Tons of servers to run commands on?
$ ansible -i ~/etc/hosts all -m shell -a 'df -h'
Ansible - Quickstart
ss-dfw-00 | success | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 1.6G 18G 9% /
udev 10M 0 10M 0% /dev
...
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
A few facts about Ansible
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
A few facts about Ansible
● open-source
● free-software (GPL v3)
● written in Python
● agent-less
● push model ← K.I.S.S.
● commercial version
...OK, SSH is an agent ;)
● enterprise support, SLA, …
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Why use ansible?
Automate repetitive tasks
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
mail.example.com
10.1.157.183
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
$ ansible -i /path/to/inventory
GROUP_NAME …
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
ss-dfw-00
10.182.37.244
$ ansible -i ~/etc/hosts all --sudo -m command -a 'aptitude update'
ss-dfw-00 | success | rc=0 >>
Get: 1 http://mirror.rackspace.com wheezy Release.gpg [1672 B]
Get: 2 http://mirror.rackspace.com wheezy/updates Release.gpg [836 B]
Get: 3 http://mirror.rackspace.com wheezy-backports Release.gpg [836 B]
…
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
$ ansible -i hosts webserver -f10 
-m command 
-a ‘aptitude install apache2’
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
$ ansible -i hosts dbserver -f10 
-m command 
-a ‘aptitude install mysql’
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
[webservers]
foo.example.com
bar.example.com
[dbservers]
foo.example.com
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts and Groups
[webservers]
www[01:10].example.com
bar.example.com
[dbservers]
db-[a:f].example.com
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Inventory - Hosts variables
[atlanta]
host1 http_port=80 maxRequestsPerChild=808
host2 http_port=303 maxRequestsPerChild=909
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Modules
What can modules do?
● run commands
● transfer files
● install packages
● manage daemons
● manage users and groups
● gather facts
● deploy software with SCM
● manage DBs (MySQL,
PostgreSQL, MongoDB,
Redis, …)
● manage Cloud devices
See:
http://docs.ansible.com/modules_by_category.html
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Desired State
Go live!
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Desired state
Write code to tell the computer
how to set up itself!
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Agenda
● Presentation (20’)
o The basics
o Playbooks
o Sharing code
● Q&A (5’)
● Quiz (5’)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
● Contain one or more plays
● Written in YAML
○ declarative config
○ not code
● Executed in the order it is
written (aka Imperative)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
---
- name: deploy web server
user: foouser
sudo: True
hosts: all
tasks:
- name: install apache
apt: pkg=apache2-mpm-prefork state=latest
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
---
- name: deploy web server
user: foouser
sudo: True
hosts: all
tasks:
- name: install apache
apt: pkg=apache2-mpm-prefork state=latest
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
---
- name: deploy web server
user: foouser
sudo: True
hosts: all
tasks:
- name: install apache
apt: pkg=apache2-mpm-prefork state=latest
Inventory
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
---
- name: deploy web server
user: foouser
sudo: True
hosts: all
tasks:
- name: install apache
apt: pkg=apache2-mpm-prefork state=latest
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
---
- name: deploy web server
user: foouser
sudo: True
hosts: all
tasks:
- name: install apache
apt: pkg=apache2-mpm-prefork state=latest
Documentation
Arguments
Module
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - output
$ ansible-playbook -i ~/etc/hosts main.yml
PLAY [deploy web server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [ss-dfw-00]
TASK: [install apache] ********************************************************
changed: [ss-dfw-00]
PLAY RECAP ********************************************************************
ss-dfw-00 : ok=2 changed=1 unreachable=0 failed=0
foouser@ss-dfw-00:~$ sudo netstat -putan | grep 80
tcp6 0 0 :::80 :::* LISTEN
11306/apache2
Desired state
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - output
$ ansible-playbook -i ~/etc/hosts main.yml
PLAY [deploy web server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [ss-dfw-00]
TASK: [install apache] ********************************************************
changed: [ss-dfw-00]
PLAY RECAP ********************************************************************
ss-dfw-00 : ok=2 changed=1 unreachable=0 failed=0
foouser@ss-dfw-00:~$ sudo netstat -putan | grep 80
tcp6 0 0 :::80 :::* LISTEN
11306/apache2
NOT Desired state
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks
Idempotency
1 * N 0 + N
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - output
$ ansible-playbook -i ~/etc/hosts main.yml
PLAY [deploy web server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [ss-dfw-00]
TASK: [install apache] ********************************************************
ok: [ss-dfw-00]
PLAY RECAP ********************************************************************
ss-dfw-00 : ok=2 changed=0 unreachable=0 failed=0
Idempotency
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Conditionals
---
.
.
.
tasks:
- name: install apache on Debian based distros
apt: pkg=apache2-mpm-prefork state=latest
when: ansible_os_family=="Debian"
- name: install apache on Red-Hat based distros
yum: pkg=httpd state=latest
when: ansible_os_family=="RedHat"
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Conditionals
---
.
.
.
tasks:
- name: install apache on Debian based distros
apt: pkg=apache2-mpm-prefork state=latest
when: ansible_os_family=="Debian"
- name: install apache on Red-Hat based distros
yum: pkg=httpd state=latest
when: ansible_os_family=="RedHat"
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Includes
---
.
.
.
tasks:
- include: apache_debian.yml
when: ansible_os_family=="Debian"
- include: apache_redhat.yml
when: ansible_os_family=="RedHat"
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Includes
---
.
.
.
tasks:
- include: apache_debian.yml
when: ansible_os_family=="Debian"
- include: apache_redhat.yml
when: ansible_os_family=="RedHat"
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Includes
---
# apache_debian.yml
tasks:
- name: install apache on Debian based distros
apt: pkg=apache2-mpm-prefork state=latest
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Includes
---
# apache_redhat.yml
tasks:
- name: install apache on Red-Hat based distros
yum: pkg=httpd state=latest
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
Let’s deploy LAMP with Ansible!
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Groups of servers
webservers dbservers
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
Inventory file
[webservers]
web0
web1
[dbservers]
db0
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
roles
common
db
web
lamp_simple
---
# This playbook deploys the whole application stack in this
site.
- name: apply common configuration to all nodes
hosts: all
user: root
roles:
- common
- name: configure and deploy the webservers and application
code
hosts: webservers
user: root
roles:
- web
- name: deploy MySQL and configure the databases
hosts: dbservers
user: root
roles:
- db
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
roles
common
db
web
lamp_simple
---
# This playbook deploys the whole application stack in this
site.
- name: apply common configuration to all nodes
hosts: all
user: root
roles:
- common
- name: configure and deploy the webservers and application
code
hosts: webservers
user: root
roles:
- web
- name: deploy MySQL and configure the databases
hosts: dbservers
user: root
roles:
- db
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
roles
common
db
web
lamp_simple
---
# This playbook deploys the whole application stack in this
site.
- name: apply common configuration to all nodes
hosts: all
user: root
roles:
- common
- name: configure and deploy the webservers and application
code
hosts: webservers
user: root
roles:
- web
- name: deploy MySQL and configure the databases
hosts: dbservers
user: root
roles:
- db
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
common
tasks
db
tasks
web
tasks
playbooks
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
common
tasks
---
# This playbook contains common plays that will be run on all nodes.
- name: Install ntp
yum: name=ntp state=present
tags: ntp
- name: Configure ntp file
template: src=ntp.conf.j2 dest=/etc/ntp.conf
tags: ntp
notify: restart ntp
…
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
db
tasks
---
# This playbook will install mysql
# and create db user and give permissions.
- name: Install Mysql package
yum: name={{ item }} state=installed
with_items:
- mysql-server
- MySQL-python
- libselinux-python
- libsemanage-python
…
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Playbooks - Deploy LAMP
web
tasks
---
# These tasks install http and the php modules.
- name: Install http and php etc
yum: name={{ item }} state=present
with_items:
- httpd
- php
- php-mysql
- …
- name: insert iptables rule for httpd
lineinfile: dest=/etc/sysconfig/iptables create=yes state=present
regexp="{{ httpd_port }}" insertafter="^:OUTPUT "
line="-A INPUT -p tcp --dport {{ httpd_port }} -j
ACCEPT"
notify: restart iptables
…
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Best practices - Directory layout
site.yml # master playbook
webservers.yml # playbook for webserver tier
dbservers.yml # playbook for dbserver tier
roles/
common/ # this hierarchy represents a "role"
tasks/ #
main.yml # <-- tasks file can include smaller files if warranted
handlers/ #
main.yml # <-- handlers file
templates/ # <-- files for use with the template resource
ntp.conf.j2 # <------- templates end in .j2
files/ #
bar.txt # <-- files for use with the copy resource
foo.sh # <-- script files for use with the script resource
vars/ #
main.yml # <-- variables associated with this role
webtier/ # same kind of structure as "common" was above, done for the webtier role
monitoring/ # ""
fooapp/ # ""
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Agenda
● Presentation (20’)
o The basics
o Playbooks
o Sharing code
● Q&A (5’)
● Quiz (5’)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing playbooks
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing playbooks
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing playbooks
$ git clone https://github.com/ansible/ansible-examples
Cloning into 'ansible-examples'...
remote: Reusing existing pack: 1698, done.
remote: Total 1698 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1698/1698), 3.73 MiB | 296.00
KiB/s, done.
Resolving deltas: 100% (355/355), done.
Checking connectivity... done
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing playbooks
$ ansible-playbook -i ~/etc/hosts lamp_simple/site.yml
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing playbooks
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Sharing code
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Agenda
● Presentation (20’)
o The basics
o Playbooks
o Git repositories
● Q&A (5’)
● Quiz (5’)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Agenda
● Presentation (20’)
o The basics
o Playbooks
o Git repositories
● Q&A (5’)
● Quiz (5’)
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Quiz
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Give your feedback!
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
References
Ansible Workshttp://www.ansible.com/home
Ansible
Documentationhttp://docs.ansible.com/inde
x.html
Ansible source
codehttps://github.com/ansible/ansible
Ansible
exampleshttps://github.com/ansible/ansible-
examples
Best
practiceshttp://docs.ansible.com/
playbooks_best_practices.html
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
Homework
● Replay examples
● commit result to GitHub
● send me a message
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
@soldasimo
simonesoldateschi

More Related Content

What's hot

Making the most out of kubernetes audit logs
Making the most out of kubernetes audit logsMaking the most out of kubernetes audit logs
Making the most out of kubernetes audit logsLaurent Bernaille
 
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...Amazon Web Services Korea
 
Learning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNILearning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNIHungWei Chiu
 
nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제choi sungwook
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMartin Etmajer
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축Ji-Woong Choi
 
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用DeNA
 
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送Google Cloud Platform - Japan
 
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?VMware Tanzu Korea
 
KubeVirt (Kubernetes and Cloud Native Toronto)
KubeVirt (Kubernetes and Cloud Native Toronto)KubeVirt (Kubernetes and Cloud Native Toronto)
KubeVirt (Kubernetes and Cloud Native Toronto)Stephen Gordon
 
CloudFoundryをつかってみよう
CloudFoundryをつかってみようCloudFoundryをつかってみよう
CloudFoundryをつかってみようKazuto Kusama
 
Introduce Docker
Introduce DockerIntroduce Docker
Introduce DockerYongbok Kim
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
대용량 로그분석 Bigquery로 간단히 사용하기
대용량 로그분석 Bigquery로 간단히 사용하기대용량 로그분석 Bigquery로 간단히 사용하기
대용량 로그분석 Bigquery로 간단히 사용하기Jaikwang Lee
 
Task migration using CRIU
Task migration using CRIUTask migration using CRIU
Task migration using CRIURohit Jnagal
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹InfraEngineer
 

What's hot (20)

Making the most out of kubernetes audit logs
Making the most out of kubernetes audit logsMaking the most out of kubernetes audit logs
Making the most out of kubernetes audit logs
 
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...
Cloud Migration 과 Modernization 을 위한 30가지 아이디어-박기흥, AWS Migrations Specialist...
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Learning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNILearning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNI
 
nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제
 
Kubernetes PPT.pptx
Kubernetes PPT.pptxKubernetes PPT.pptx
Kubernetes PPT.pptx
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
 
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用
IoTと業務システムをつなぐgRPC/RESTサービスの開発と運用
 
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送
[Cloud OnAir] Google Cloud へのデータ移行 2019年1月24日 放送
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
 
KubeVirt (Kubernetes and Cloud Native Toronto)
KubeVirt (Kubernetes and Cloud Native Toronto)KubeVirt (Kubernetes and Cloud Native Toronto)
KubeVirt (Kubernetes and Cloud Native Toronto)
 
Ansible
AnsibleAnsible
Ansible
 
CloudFoundryをつかってみよう
CloudFoundryをつかってみようCloudFoundryをつかってみよう
CloudFoundryをつかってみよう
 
Introduce Docker
Introduce DockerIntroduce Docker
Introduce Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
대용량 로그분석 Bigquery로 간단히 사용하기
대용량 로그분석 Bigquery로 간단히 사용하기대용량 로그분석 Bigquery로 간단히 사용하기
대용량 로그분석 Bigquery로 간단히 사용하기
 
Task migration using CRIU
Task migration using CRIUTask migration using CRIU
Task migration using CRIU
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
 

Similar to Ansible - Crash course

Building cloud stack at scale
Building cloud stack at scaleBuilding cloud stack at scale
Building cloud stack at scaleShapeBlue
 
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce StackIQ
 
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014Amazon Web Services
 
Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016StackIQ
 
Rackspace Hack Night - Vagrant & Packer
Rackspace Hack Night - Vagrant & PackerRackspace Hack Night - Vagrant & Packer
Rackspace Hack Night - Vagrant & PackerMarc Cluet
 
Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5bilcorry
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102APNIC
 
An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring Abhishek Kumar
 
Be a Cloud Native
Be a Cloud NativeBe a Cloud Native
Be a Cloud NativeInnoTech
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShellDale Lane
 
Consideration for Building a Private Cloud
Consideration for Building a Private CloudConsideration for Building a Private Cloud
Consideration for Building a Private CloudOpenStack Foundation
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionSysdig
 
Stacki: Remove Commands
Stacki: Remove CommandsStacki: Remove Commands
Stacki: Remove CommandsStackIQ
 
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015Remi Bergsma
 

Similar to Ansible - Crash course (20)

Building cloud stack at scale
Building cloud stack at scaleBuilding cloud stack at scale
Building cloud stack at scale
 
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
 
Stacki - The1600+ Server Journey
Stacki - The1600+ Server JourneyStacki - The1600+ Server Journey
Stacki - The1600+ Server Journey
 
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
 
Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016
 
Rackspace Hack Night - Vagrant & Packer
Rackspace Hack Night - Vagrant & PackerRackspace Hack Night - Vagrant & Packer
Rackspace Hack Night - Vagrant & Packer
 
Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5Asynchronous Threads in Lasso 8.5
Asynchronous Threads in Lasso 8.5
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
 
An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring
 
Git Crash Course
Git Crash CourseGit Crash Course
Git Crash Course
 
Be a Cloud Native
Be a Cloud NativeBe a Cloud Native
Be a Cloud Native
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShell
 
Consideration for Building a Private Cloud
Consideration for Building a Private CloudConsideration for Building a Private Cloud
Consideration for Building a Private Cloud
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Hadoop on aws amazon
Hadoop on aws amazonHadoop on aws amazon
Hadoop on aws amazon
 
Hadoop on aws amazon
Hadoop on aws amazonHadoop on aws amazon
Hadoop on aws amazon
 
Stacki: Remove Commands
Stacki: Remove CommandsStacki: Remove Commands
Stacki: Remove Commands
 
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015
The Mission Critical Cloud @ Apache CloudStack meetup Amsterdam June 2015
 
Network Manual
Network ManualNetwork Manual
Network Manual
 

Recently uploaded

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Recently uploaded (20)

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

Ansible - Crash course

  • 1. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Brown bag - Crash course Automation makes IT better @soldasimo simonesoldateschi
  • 2. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Agenda ● Presentation (20’) o The basics o Playbooks o Sharing code ● Q&A (5’) ● Quiz (5’)
  • 3. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk The basics Installation on management host: $ pip install ansible That’s it!
  • 4. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk The basics Installing agent on managed hosts:
  • 5. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk The basics Can be as simple as: mail.example.com or: 10.1.157.183 Create an inventory file
  • 6. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk The basics Is host alive? $ ansible -i ~/etc/hosts all -m ping Ansible - Quickstart ss-dfw-00 | success >> { "changed": false, "ping": "pong" }
  • 7. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk The basics Tons of servers to run commands on? $ ansible -i ~/etc/hosts all -m shell -a 'df -h' Ansible - Quickstart ss-dfw-00 | success | rc=0 >> Filesystem Size Used Avail Use% Mounted on rootfs 20G 1.6G 18G 9% / udev 10M 0 10M 0% /dev ...
  • 8. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk A few facts about Ansible
  • 9. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk A few facts about Ansible ● open-source ● free-software (GPL v3) ● written in Python ● agent-less ● push model ← K.I.S.S. ● commercial version ...OK, SSH is an agent ;) ● enterprise support, SLA, …
  • 10. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Why use ansible? Automate repetitive tasks
  • 11. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory
  • 12. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups mail.example.com 10.1.157.183 [webservers] foo.example.com bar.example.com [dbservers] one.example.com two.example.com three.example.com $ ansible -i /path/to/inventory GROUP_NAME …
  • 13. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups ss-dfw-00 10.182.37.244 $ ansible -i ~/etc/hosts all --sudo -m command -a 'aptitude update' ss-dfw-00 | success | rc=0 >> Get: 1 http://mirror.rackspace.com wheezy Release.gpg [1672 B] Get: 2 http://mirror.rackspace.com wheezy/updates Release.gpg [836 B] Get: 3 http://mirror.rackspace.com wheezy-backports Release.gpg [836 B] …
  • 14. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups [webservers] foo.example.com bar.example.com [dbservers] one.example.com two.example.com three.example.com
  • 15. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups $ ansible -i hosts webserver -f10 -m command -a ‘aptitude install apache2’ [webservers] foo.example.com bar.example.com [dbservers] one.example.com two.example.com three.example.com $ ansible -i hosts dbserver -f10 -m command -a ‘aptitude install mysql’
  • 16. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups [webservers] foo.example.com bar.example.com [dbservers] foo.example.com
  • 17. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts and Groups [webservers] www[01:10].example.com bar.example.com [dbservers] db-[a:f].example.com
  • 18. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Inventory - Hosts variables [atlanta] host1 http_port=80 maxRequestsPerChild=808 host2 http_port=303 maxRequestsPerChild=909
  • 19. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Modules What can modules do? ● run commands ● transfer files ● install packages ● manage daemons ● manage users and groups ● gather facts ● deploy software with SCM ● manage DBs (MySQL, PostgreSQL, MongoDB, Redis, …) ● manage Cloud devices See: http://docs.ansible.com/modules_by_category.html
  • 20. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Desired State Go live!
  • 21. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Desired state Write code to tell the computer how to set up itself!
  • 22. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Agenda ● Presentation (20’) o The basics o Playbooks o Sharing code ● Q&A (5’) ● Quiz (5’)
  • 23. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks ● Contain one or more plays ● Written in YAML ○ declarative config ○ not code ● Executed in the order it is written (aka Imperative)
  • 24. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks --- - name: deploy web server user: foouser sudo: True hosts: all tasks: - name: install apache apt: pkg=apache2-mpm-prefork state=latest
  • 25. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks --- - name: deploy web server user: foouser sudo: True hosts: all tasks: - name: install apache apt: pkg=apache2-mpm-prefork state=latest
  • 26. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks --- - name: deploy web server user: foouser sudo: True hosts: all tasks: - name: install apache apt: pkg=apache2-mpm-prefork state=latest Inventory
  • 27. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks --- - name: deploy web server user: foouser sudo: True hosts: all tasks: - name: install apache apt: pkg=apache2-mpm-prefork state=latest
  • 28. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks --- - name: deploy web server user: foouser sudo: True hosts: all tasks: - name: install apache apt: pkg=apache2-mpm-prefork state=latest Documentation Arguments Module
  • 29. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - output $ ansible-playbook -i ~/etc/hosts main.yml PLAY [deploy web server] ****************************************************** GATHERING FACTS *************************************************************** ok: [ss-dfw-00] TASK: [install apache] ******************************************************** changed: [ss-dfw-00] PLAY RECAP ******************************************************************** ss-dfw-00 : ok=2 changed=1 unreachable=0 failed=0 foouser@ss-dfw-00:~$ sudo netstat -putan | grep 80 tcp6 0 0 :::80 :::* LISTEN 11306/apache2 Desired state
  • 30. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - output $ ansible-playbook -i ~/etc/hosts main.yml PLAY [deploy web server] ****************************************************** GATHERING FACTS *************************************************************** ok: [ss-dfw-00] TASK: [install apache] ******************************************************** changed: [ss-dfw-00] PLAY RECAP ******************************************************************** ss-dfw-00 : ok=2 changed=1 unreachable=0 failed=0 foouser@ss-dfw-00:~$ sudo netstat -putan | grep 80 tcp6 0 0 :::80 :::* LISTEN 11306/apache2 NOT Desired state
  • 31. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks Idempotency 1 * N 0 + N
  • 32. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - output $ ansible-playbook -i ~/etc/hosts main.yml PLAY [deploy web server] ****************************************************** GATHERING FACTS *************************************************************** ok: [ss-dfw-00] TASK: [install apache] ******************************************************** ok: [ss-dfw-00] PLAY RECAP ******************************************************************** ss-dfw-00 : ok=2 changed=0 unreachable=0 failed=0 Idempotency
  • 33. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Conditionals --- . . . tasks: - name: install apache on Debian based distros apt: pkg=apache2-mpm-prefork state=latest when: ansible_os_family=="Debian" - name: install apache on Red-Hat based distros yum: pkg=httpd state=latest when: ansible_os_family=="RedHat"
  • 34. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Conditionals --- . . . tasks: - name: install apache on Debian based distros apt: pkg=apache2-mpm-prefork state=latest when: ansible_os_family=="Debian" - name: install apache on Red-Hat based distros yum: pkg=httpd state=latest when: ansible_os_family=="RedHat"
  • 35. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Includes --- . . . tasks: - include: apache_debian.yml when: ansible_os_family=="Debian" - include: apache_redhat.yml when: ansible_os_family=="RedHat"
  • 36. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Includes --- . . . tasks: - include: apache_debian.yml when: ansible_os_family=="Debian" - include: apache_redhat.yml when: ansible_os_family=="RedHat"
  • 37. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Includes --- # apache_debian.yml tasks: - name: install apache on Debian based distros apt: pkg=apache2-mpm-prefork state=latest
  • 38. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Includes --- # apache_redhat.yml tasks: - name: install apache on Red-Hat based distros yum: pkg=httpd state=latest
  • 39. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP Let’s deploy LAMP with Ansible!
  • 40. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Groups of servers webservers dbservers
  • 41. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP Inventory file [webservers] web0 web1 [dbservers] db0
  • 42. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP roles common db web lamp_simple --- # This playbook deploys the whole application stack in this site. - name: apply common configuration to all nodes hosts: all user: root roles: - common - name: configure and deploy the webservers and application code hosts: webservers user: root roles: - web - name: deploy MySQL and configure the databases hosts: dbservers user: root roles: - db
  • 43. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP roles common db web lamp_simple --- # This playbook deploys the whole application stack in this site. - name: apply common configuration to all nodes hosts: all user: root roles: - common - name: configure and deploy the webservers and application code hosts: webservers user: root roles: - web - name: deploy MySQL and configure the databases hosts: dbservers user: root roles: - db
  • 44. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP roles common db web lamp_simple --- # This playbook deploys the whole application stack in this site. - name: apply common configuration to all nodes hosts: all user: root roles: - common - name: configure and deploy the webservers and application code hosts: webservers user: root roles: - web - name: deploy MySQL and configure the databases hosts: dbservers user: root roles: - db
  • 45. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP common tasks db tasks web tasks playbooks
  • 46. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP common tasks --- # This playbook contains common plays that will be run on all nodes. - name: Install ntp yum: name=ntp state=present tags: ntp - name: Configure ntp file template: src=ntp.conf.j2 dest=/etc/ntp.conf tags: ntp notify: restart ntp …
  • 47. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP db tasks --- # This playbook will install mysql # and create db user and give permissions. - name: Install Mysql package yum: name={{ item }} state=installed with_items: - mysql-server - MySQL-python - libselinux-python - libsemanage-python …
  • 48. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Playbooks - Deploy LAMP web tasks --- # These tasks install http and the php modules. - name: Install http and php etc yum: name={{ item }} state=present with_items: - httpd - php - php-mysql - … - name: insert iptables rule for httpd lineinfile: dest=/etc/sysconfig/iptables create=yes state=present regexp="{{ httpd_port }}" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport {{ httpd_port }} -j ACCEPT" notify: restart iptables …
  • 49. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Best practices - Directory layout site.yml # master playbook webservers.yml # playbook for webserver tier dbservers.yml # playbook for dbserver tier roles/ common/ # this hierarchy represents a "role" tasks/ # main.yml # <-- tasks file can include smaller files if warranted handlers/ # main.yml # <-- handlers file templates/ # <-- files for use with the template resource ntp.conf.j2 # <------- templates end in .j2 files/ # bar.txt # <-- files for use with the copy resource foo.sh # <-- script files for use with the script resource vars/ # main.yml # <-- variables associated with this role webtier/ # same kind of structure as "common" was above, done for the webtier role monitoring/ # "" fooapp/ # ""
  • 50. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Agenda ● Presentation (20’) o The basics o Playbooks o Sharing code ● Q&A (5’) ● Quiz (5’)
  • 51. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing playbooks
  • 52. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing playbooks
  • 53. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing playbooks $ git clone https://github.com/ansible/ansible-examples Cloning into 'ansible-examples'... remote: Reusing existing pack: 1698, done. remote: Total 1698 (delta 0), reused 0 (delta 0) Receiving objects: 100% (1698/1698), 3.73 MiB | 296.00 KiB/s, done. Resolving deltas: 100% (355/355), done. Checking connectivity... done
  • 54. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing playbooks $ ansible-playbook -i ~/etc/hosts lamp_simple/site.yml
  • 55. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing playbooks
  • 56. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Sharing code
  • 57. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
  • 58. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Agenda ● Presentation (20’) o The basics o Playbooks o Git repositories ● Q&A (5’) ● Quiz (5’)
  • 59. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
  • 60. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Agenda ● Presentation (20’) o The basics o Playbooks o Git repositories ● Q&A (5’) ● Quiz (5’)
  • 61. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Quiz
  • 62. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Give your feedback!
  • 63. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk References Ansible Workshttp://www.ansible.com/home Ansible Documentationhttp://docs.ansible.com/inde x.html Ansible source codehttps://github.com/ansible/ansible Ansible exampleshttps://github.com/ansible/ansible- examples Best practiceshttp://docs.ansible.com/ playbooks_best_practices.html
  • 64. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk Homework ● Replay examples ● commit result to GitHub ● send me a message
  • 65. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk
  • 66. RACKSPACE® HOSTING | WWW.RACKSPACE.COMsimone.soldateschi@rackspace.co.uk @soldasimo simonesoldateschi

Editor's Notes

  1. In fact Ansible is agent-less.OK, OK, SSH is an agent ;)
  2. The inventory file references hosts to be managed. It might contain credentials and key-value pairs.
  3. ansible is the swiss-army-knife
  4. The inventory file references hosts to be managed. It might contain credentials and key-value pairs.
  5. You have many servers to manage
  6. The inventory file references hosts to be managed. It might contain credentials and key-value pairs.
  7. The inventory file references hosts to be managed. It might contain credentials and key-value pairs.
  8. The inventory file references hosts to be managed. It might contain credentials and key-value pairs. ‘-f10’ tells Ansible to fork 10 times, aka manage 10 servers in parallel
  9. The inventory file references hosts to be managed. It might contain credentials and key-value pairs. ‘-f10’ tells Ansible to fork 10 times, aka manage 10 servers in parallel
  10. foo.example.com is both a web server and a database server
  11. www01.example.com … www10.example.com are web serversdb-a.example.com … db-f.example.com are database servers
  12. Let’s install Apache HTTP server using a playbook
  13. Let’s install Apache HTTP server using a playbook
  14. all refers to all the host defined within the inventory file It could be any group-name.
  15. Let’s install Apache HTTP server using a playbook
  16. Let’s install Apache HTTP server using a playbook
  17. Let’s install Apache HTTP server using a playbook
  18. Let’s install Apache HTTP server using a playbook
  19. Let’s install Apache HTTP server using a playbook
  20. Let’s install Apache HTTP server, using the same playbook, on Debian and Red-Hat based distros.
  21. Let’s install Apache HTTP server, using the same playbook, on Debian and Red-Hat based distros.
  22. It’s possible to achieve the same result including sub-playbooks
  23. It’s possible to achieve the same result including sub-playbooks
  24. It’s possible to achieve the same result including sub-playbooks
  25. It’s possible to achieve the same result including sub-playbooks
  26. It’s possible to achieve the same result including sub-playbooks
  27. It’s possible to achieve the same result including sub-playbooks
  28. It’s possible to achieve the same result including sub-playbooks
  29. It’s possible to achieve the same result including sub-playbooks
  30. It’s possible to achieve the same result including sub-playbooks
  31. It’s possible to achieve the same result including sub-playbooks
  32. It’s possible to achieve the same result including sub-playbooks
  33. It’s possible to achieve the same result including sub-playbooks
  34. It’s possible to achieve the same result including sub-playbooks
  35. It’s possible to achieve the same result including sub-playbooks
  36. Please, give your feedback!