Ansible

CM history

Key aspects

  • Simple interface
  • Just simple and plain SSH
  • Simple declarative language (YAML)
  • Team sync simply through VCS
  • No agent, only python required
  • Push model completely integrated
  • No remote install
  • Modules providing functionality
  • UN*X, ... for the time being

Architectures

Push
Pull

Basic usage

Install
 pip install ansible
Inventory
[webservers]
web01.domain.com
web02.domain.com
web03.domain.com
[database]
db01.domain.com
db02.domain.com
[production]
web01.domain.com
web02.domain.com
db01.domain.com
[staging]
web03.domain.com
db02.domain.com

Commands

ping
$ ansible web01.domain.com -m ping
web01.domain.com | success >> {
    "changed": false,
    "ping": "pong"
}
setup
 $ ansible web01.domain.com -m setup
web01.domain.com | success >> {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "172.31.13.7"
        ],
...
        "ansible_virtualization_role": "guest",
        "ansible_virtualization_type": "xen"
    },
    "changed": false
}

PLAYBOOKS

ansible-playbook example.yml 

Sections in a playbook

Target: How and where to run playbook
- hosts: webservers
  user: root 
Variable: Variables available to the running playbook
  vars:
    domain: www.example.com 
Task: Execution list of modules to use
  tasks:
    - name: Install latest nginx
      apt: name=nginx state=latest
    - name: Configure nginx
      template: src=nginx/default.j2 dest=/etc/nginx/sites-available/default
      notify: restart nginx

SECTIONS IN A PLAYBOOK

Handlers: Modularize tasks
  tasks:
  - name: Configure nginx
    template: name=default.j2 dest=
  handlers:
  - name: restart nginx
    service: name=nginx state=restarted
  Loops and conditionals
  tasks:
  - name: Install required packages
    apt: {{ item }}
    with_items:
      - nginx
      - mysql-server
    when: ansible_os_family == 'Debian'

Interesting resources

EC2 and Eucalyptus orchestration
http://www.slideshare.net/eucalyptus/ansible-eucalyptuswebinar
Ansible at scale 
http://www.slideshare.net/JesseKeating/ansiblefest-rax
OSXC - Boxen-like provisioning 
http://osxc.github.io/
How edX uses Ansible 
https://speakerdeck.com/jarv/how-edx-uses-ansible
Windows is coming
http://www.ansible.com/blog/windows-is-coming

Links

Ansible
http://www.ansible.com/home
Ansible Weekly 
https://devopsu.com/newsletters/ansible-weekly-newsletter.html
Ansible Configuration Management 
http://www.amazon.es/Ansible-Configuration-Management-Daniel-Hall/dp/1783280816
Ansible for DevOps
https://leanpub.com/ansible-for-devops

Ansible Galaxy

https://galaxy.ansible.com/



Questions?



http://slides.com/ignasifoschalonso/ansible#/
@ifosch
http://www.entredevyops.es