Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Getting Started with Ansible

498 views

Published on

Presentation of my TechTalk at eSapce (Every Thursday one of the departments make a session about something recently begun to use or a new technology, this was my session from SysOps team.) This is an introduction to Ansible, and how to get started with it ... and since then we moved to Ansible :-)

Ansible is a great tool for many purposes like: configuration management, contentious deployment, and multi-tier orchestration ... and more!

- http://tech.aabouzaid.com/
- http://espace.com.eg/
- http://ansible.com/

Published in: Technology
  • Be the first to comment

Getting Started with Ansible

  1. 1. Getting Started with Ansible Ahmed M. AbouZaid tech.aabouzaid.com 2 April 2015
  2. 2. What’s the problem? • Getting Things Done Easier! • Getting Things Done Faster! • Getting Things Done Better!
  3. 3. Old style! • Manual. • Bash and Shell scripts. • Complex and not reliable tools like “expect”.
  4. 4. Solution? CM! • Configuration Management! • Why CM? • What is CM? • Who lead the market?
  5. 5. Ansib ... what? • Configuration Management. • Application Deployment. • Multi-Tier Orchestration.
  6. 6. Why Ansible? • Decentralized. • Agent-less (Just SSH). • Super duper easy! • YAML syntax, no coding. • Lots of modules. • Ad-Hoc mode! • Orchestration and Deployment.
  7. 7. Ansible vs Others? • Puppet. • Chef. • Salt.
  8. 8. Ansible vs Others? Puppet package { 'ntp': ensure => installed, } file { 'ntp.conf': path => '/etc/ntp.conf', ensure => file, source => "ntp.conf" } service { 'ntp': name => $service_name, ensure => running, enable => true, } Ansible - name: Install NTP. apt: package=ntp - name: Copy NTP conf. template: src=ntp.conf dest=/etc/ntp.conf - name: Start NTP service. service: name=ntp state=started enabled=yes
  9. 9. Ansible concepts • Inventory. • Modules. • Plays and Playbooks. • Tasks and Handlers. • Facts and Variables. • Templates. • Roles.
  10. 10. Inventory mail.example.com [webservers] foo.example.com bar.example.com [dbservers] one.example.com two.example.com three.example.com:5309 four ansible_ssh_port=5555 ansible_ssh_host=192.168.1.50
  11. 11. Modules • Cloud Modules • Database Modules • Inventory Modules • Monitoring Modules • Notification Modules • Source Control Modules • Utilities Modules • Commands Modules • Files Modules • Messaging Modules • Network Modules • Packaging Modules • System Modules • Web Infrastructure Modules - name: Ensure Nginx is at the latest version. apt: pkg: nginx state: latest
  12. 12. Plays and Playbooks --- - name: Install and start Nginx. host: webservers user: root tasks: - name: Install Nginx. apt: name=nginx state=latest - name: Start Nginx. service: name=nginx state=running Playbook Play Task
  13. 13. Tasks and handlers tasks: - name: Ensure Nginx is at the latest version. apt: pkg: nginx state: latest - name: Write the Nginx config file. template: src: /srv/nginx.j2 dest: /etc/nginx/nginx.conf notify: Restart Nginx. - name: Ensure Nginx is running. service: name: nginx state: started handlers: - name: Restart Nginx. service: name: nginx state: restarted
  14. 14. Facts and Variables - hosts: webservers vars: http_port: 80 server_hostname: www.example.com ip: “{{ ansible_eth0.ipv4.address }}” tasks: - name: Ensure domain is pingable. command: ping “{{ server_hostname }}”
  15. 15. Templates #################### # {{ server_hostname }} added by Ansible. # server { listen {{ http_port }} default_server; server_name {{ server_hostname }}; …. ….
  16. 16. Roles --- - hosts: webservers roles: - common - webservers site.yml webservers.yml roles/ |- common/ |- files/ |- templates/ |- tasks/ |- handlers/ |- vars/ |- defaults/ |- meta/ |- webservers/ |- files/ |- templates/ |- tasks/ |- handlers/ |- vars/ |- defaults/ |- meta/
  17. 17. Demo Time! • Install Wordpress (Nginx, PHP-FPM, MySQL) on VirtualBox machine with Ansible and Vagrant!
  18. 18. Questions? :-)

×