Configuration management and deployment with ansible
-
Upload
ivan-dimitrov -
Category
Technology
-
view
26 -
download
7
Transcript of Configuration management and deployment with ansible
Configuration Managementand
Deployment with Ansible
Иван ДимитровManager Technical OperationsXogito Group, Inc
Application DeploymentConfiguration ManagementAd-Hoc ExecutionRolling UpdatesMulti Tier DeploymentCloud 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.comweb2.host.com
[databases]db1.host.comdb2.host.com
[linuxes:children]webserversdatabases
filessh_configCoblerAWSDigital OceanOpenStackRackSpace
Еднократни команди
$ 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
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: [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
Modules
Batteries included - ~300 modulesFrom copying of files to mysql setupEasy to write
Plugins
Inventory pluginsConnection pluginsAction pluginsLookup PluginsVars PluginsFilter Plugins
Demo
Tips
Continuous Integration && Continuous DeliveryDifferent inventory files and variablesVagrant, Docker
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"
Връзки
http://www.ansible.com/http://www.ansible.com/towerhttps://galaxy.ansible.com/http://docs.ansible.com/https://github.com/ansible/ansible
Благодаря && Въпроси