Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ansible: Automation made simple

Steve Teo
February 12, 2015

Ansible: Automation made simple

Projects these days typically involves a huge number of servers, which increases the complexity and load for Ops and Dev Teams. This makes typical tasks like deployment, configuration management or orchestration increasingly tricky and difficult.

To deal with such complexity, automation tools are needed. Automation allows engineers to scale beyond what they are humanly capable of, eg. GitHub Ops Engineers is responsible for 10,000 instances each.

Ansible is an example of a tool which brings the benefit of automation minus the traditional complexity associated with such tools.

I will cover the following concepts using Ansible.

1) Ad-hoc task-execution
2) Configuration Management (Infrastructure as Code)
3) Application Deployment
4) Multinode Orchestration

Steve Teo

February 12, 2015
Tweet

More Decks by Steve Teo

Other Decks in Technology

Transcript

  1. Why Ansible? As the ‘environment’ guy, I rather drink coffee

    than change 42 expiring passwords manually
  2. Why Ansible? As the ‘environment’ guy, I need a way

    of standardizing every environment to reduce environment complexity
  3. Why Ansible? As the ‘deployment’ guy, I need a way

    of automating deployments across multiple environments in a reliable, repeatable fashion
  4. Why Ansible? As the ‘automation’ guy, I need an automation

    solution which works in a severely restricted environment
  5. What is Ansible? Simple, Powerful open-source automation engine Written in

    Python Competes with Chef, Puppet, Salt Stack Since 2012 by Michael Deehan
  6. Low Barrier to Entry Operates over SSH Agentless => Low

    Footprint Control Machine: > Python 2.6 Managed Nodes: > Python 2.4 No Database
  7. How do I install it? From Source git clone git://github.com/ansible/ansible.git

    –recursive cd ./ansible source ./hacking/env-setup Package Managers sudo pip install ansible brew install ansible sudo yum install ansible Easiest Offline Non-Root Installation pip local + virtualenvwrapper + ansible => portable tarball
  8. Playbooks Recipe book, consists of ‘plays’ => Mapping between tasks

    and hosts Declared in English and YAML => Say what, not how Executed in the order it was written => No dependency graph
  9. Inventory List of hosts in your ‘inventory’ in INI style

    Can be grouped together, groups of groups too
  10. Modules Ansible is battery packed Ships with over 250 modules,

    split into core and extras http://docs.ansible.com/modules.html Modules are idempotent, avoids a whole set of problems abs(abs(x)) ≡ abs(x)
  11. Frequently Used Modules Packages apt, yum, homebrew, pkg Command Execution

    command, shell System cron, service, supervisor File operations copy, template, file, fetch synchronize, unarchive User Management user, group Network get_url
  12. Windows Modules? Powered by PowerShell Remoting win_chocolatey Installs packages using

    chocolatey win_feature Installs and uninstalls Windows Features win_get_url Fetches a file from a given URL win_group Add and remove local groups win_msi Installs and uninstalls Windows MSI files win_ping A windows version of the classic ping module win_service Manages Windows services win_stat returns information about a Windows file win_updates Lists / Installs windows updates win_user Manages local Windows user accounts
  13. Variables Can be defined in inventory => all, group, host

    level Can be defined inlined Can be defined from included files and roles Can have defaults in roles Can be overridden at the command line level Referenced in tasks or templates
  14. Roles Organizational abstraction which separate tasks from the hosts that

    it needs to run on DRY, Can be reused and redistributed Convention over configuration approach Global Repository => https://galaxy.ansible.com/
  15. Multiple Environments ├── │ └── ├── │ ├── │ │

    ├── │ │ ├── │ │ └── │ └── ├── │ ├── │ │ ├── │ │ ├── │ │ └── │ └──
  16. Cloud Provisioning Provisioning modules Amazon Azure Digital Ocean Docker Google

    Linode OpenStack Rackspace VMWare http://docs.ansible.com/list_of_cloud_modules.html
  17. Cloud Provisioning Inventory is never static Inventories can be specified

    as a script, manifest generated only at run-time http://docs.ansible.com/intro_dy namic_inventory.html
  18. Ansible Tower Mission Control Dashboard Role Based Access Control Push

    Button Job Runs Job Scheduling Audit Trail Free only up to 10 Nodes