SlideShare a Scribd company logo
Configuration Management
and
Deployment with Ansible
Иван Димитров
Manager Technical
Operations
Xogito Group, Inc
ivan.dimitrov@xogito.com
Application Deployment
Configuration Management
Ad-Hoc Execution
Rolling Updates
Multi Tier Deployment
Cloud Provisioning
Какво е Ansible
for i in `cat servers` ; do ssh ubuntu@$i “sudo
apt-get update && sudo apt-get -y install bash”
; done
“It works on my laptop’s virtual machine!”
ssh based && agentless
Лесен за използване и разбиране
Какво е Ansible
Inventory
[webservers]
web1.host.com
web2.host.com
[databases]
db1.host.com
db2.host.com
[linuxes:children]
webservers
databases
file
ssh_config
Cobler
AWS
Digital Ocean
OpenStack
RackSpace
Еднократни команди
$ ansible webservers -i hosts -m ping
web1.host.com | success >> {
"changed": false,
"ping": "pong"
}
web2.host.com | success >> {
"changed": false,
"ping": "pong"
}
$ ansible linuxes -i hosts -m shell -a "yum update bash" -s
Playbooks
$ cat websites.yml
---
- hosts: websites
user: ec2-user
sudo: yes
vars:
hostname: web1.host.com
website_home: "/var/www/website.host.com"
Playbooks
roles:
- common
- datadog
- nagios-agent
- httpd
- website.app
Roles
roles/
common/
tasks/
files/
handlers/
templates/
vars/
website/
tasks/
…./
Tasks
$ cat roles/common/tasks/main.yml
- name: Orcestrate all our instances
template: src=motd dest=/etc/motd
- name: Change bashrc
copy: src=bashrc dest=/etc/bashrc
- name: Install Development Tools
yum: name="@Development tools" state=present
Tasks
$ cat roles/httpd/tasks/main.yml
- name: Install httpd
yum: name=httpd state=present
- name: Copy httpd.conf template
template: src=httpd.conf dest=/etc/apache/httpd.conf owner=apache
mode=0644
- name: Ensure that httpd is running
service: name=httpd state=started enabled=yes
Tasks
- name: Checkout repository from bitbucket
git: repo=git@bitbucket.org:my-company/website.git
dest={{ website_home }}
update={{ website_deploy }}
accept_hostkey=yes
version={{ website_branch }}
sudo: yes
sudo_user: "{{ website_user }}"
notify:
- restart my-website-app
Configuration management and deployment with ansible
Modules
Batteries included - ~300 modules
From copying of files to mysql setup
Easy to write
Plugins
Inventory plugins
Connection plugins
Action plugins
Lookup Plugins
Vars Plugins
Filter Plugins
Demo
Tips
Continuous Integration && Continuous Delivery
Different inventory files and variables
Vagrant, Docker
Jenkins
if [ -f /usr/local/ansible/hacking/env-setup ] ; then
source /usr/local/ansible/hacking/env-setup -q
fi
ansible-playbook -i hosts.dev website.app.yml --start-at-task="Add website
user" -e "website_deploy=yes"
Връзки
http://www.ansible.com/
http://www.ansible.com/tower
https://galaxy.ansible.com/
http://docs.ansible.com/
https://github.com/ansible/ansible
Благодаря && Въпроси

More Related Content

Configuration management and deployment with ansible