Ansible

Chad Nelson - Application Developer @ Lyrasis Digital

bibliotechy.github.io/ansible-talk

What is Ansible?

Tool for automating application configuration & deployment

DevOps for Humans

Why Automate?

Reusable

Faster

Auditable

Documentation

Why Ansible?

Simplicity

Language Neutral

Agentless

Excellent Documentation

Batteries Included

Ansible by Example

Tasks

Roles

Plays

Inventory

Tasks

- name: Install php5 and drupal dependencies
  apt: name={{ item }} state=present
  with_items:
    - php5
    - php5-mysql
    - libapache2-mod-php5
  sudo: yes
							
- name: Enable the devel module when dev variable is True
  shell: drush pm-enable devel
  when: dev is True
                            

Roles

Reusable group of tasks

Tasks

Templates

Defaults

Roles

Benefits

Reuse across projects

Share - Ansible Galaxy

Encapsulate

Plays

Put your roles together in order

 - name: Install Drupal
   hosts: webserver
   remote_user: conan_the_deployer
   roles:
     - drupal

 - name: Setup Tomcat where required
   hosts: tomcat
   remote_user: conan_the_deployer
   roles:
     - ansible-oracle_java7-role
     - tomcat
						

Inventory

[webserver] 
web1.lyrasistechnology.org
web2.lyrasistechnology.org

[fedora] 
fedora.lyrasistechnology.org

[solr]  
solr.lyrasistechnology.org

[tomcat:children] 
fedora
solr

[all:vars]
dev=True
						

Variables

Group Variables

Host Variables

Defaults

Variables

 - name: apply firewall rules
   ufw: rule=allow proto=tcp port={{ item.port }} 
   src={{ item.source }} delete={{ item.remove }}
   with_items: firewall							
						
# group_vars/database

firewall:
  -
    port: 22
    source: any
    remove: "no"
  -
    port: 3306
    source: 10.0.0.0/8
    remove: "no"							
						
# group_vars/tomcat

  firewall:
  -
    port: 22
    source: any
    remove: "no"
  -
    port: 8080
    source: 10.0.0.0/8
    remove: "no"							
						

I ain't gonna lie...

Sometimes Ansible drives me crazy

SIMPLE

Thanks

chad.nelson at lyrasis.org

@bibliotechy