configuration management and deployment with ansible

21
Configuration Management and Deployment with Ansible

Upload: ivan-dimitrov

Post on 18-Aug-2015

31 views

Category:

Technology


7 download

TRANSCRIPT

Page 1: Configuration management and deployment with ansible

Configuration Managementand

Deployment with Ansible

Page 2: Configuration management and deployment with ansible

Иван ДимитровManager Technical OperationsXogito Group, Inc

[email protected]

Page 3: Configuration management and deployment with ansible

Application DeploymentConfiguration ManagementAd-Hoc ExecutionRolling UpdatesMulti Tier DeploymentCloud Provisioning

Какво е Ansible

Page 4: Configuration management and deployment with 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!”

Page 5: Configuration management and deployment with ansible

ssh based && agentlessЛесен за използване и разбиране

Какво е Ansible

Page 6: Configuration management and deployment with ansible

Inventory[webservers]web1.host.comweb2.host.com

[databases]db1.host.comdb2.host.com

[linuxes:children]webserversdatabases

filessh_configCoblerAWSDigital OceanOpenStackRackSpace

Page 7: Configuration management and deployment with ansible

Еднократни команди

$ ansible webservers -i hosts -m pingweb1.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

Page 8: Configuration management and deployment with ansible

Playbooks

$ cat websites.yml---- hosts: websites user: ec2-user sudo: yes

vars: hostname: web1.host.com website_home: "/var/www/website.host.com"

Page 9: Configuration management and deployment with ansible

Playbooks

roles: - common - datadog - nagios-agent - httpd - website.app

Page 10: Configuration management and deployment with ansible

Roles

roles/common/

tasks/files/handlers/templates/vars/

website/tasks/…./

Page 11: Configuration management and deployment with ansible

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

Page 12: Configuration management and deployment with ansible

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

Page 13: Configuration management and deployment with ansible

Tasks

- name: Checkout repository from bitbucket git: [email protected]: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

Page 14: Configuration management and deployment with ansible
Page 15: Configuration management and deployment with ansible

Modules

Batteries included - ~300 modulesFrom copying of files to mysql setupEasy to write

Page 16: Configuration management and deployment with ansible

Plugins

Inventory pluginsConnection pluginsAction pluginsLookup PluginsVars PluginsFilter Plugins

Page 17: Configuration management and deployment with ansible

Demo

Page 18: Configuration management and deployment with ansible

Tips

Continuous Integration && Continuous DeliveryDifferent inventory files and variablesVagrant, Docker

Page 19: Configuration management and deployment with ansible

Jenkins

if [ -f /usr/local/ansible/hacking/env-setup ] ; then source /usr/local/ansible/hacking/env-setup -qfiansible-playbook -i hosts.dev website.app.yml --start-at-task="Add website user" -e "website_deploy=yes"

Page 20: Configuration management and deployment with ansible

Връзки

http://www.ansible.com/http://www.ansible.com/towerhttps://galaxy.ansible.com/http://docs.ansible.com/https://github.com/ansible/ansible

Page 21: Configuration management and deployment with ansible

Благодаря && Въпроси