Ansible – DevOps for Humans – Basics



Ansible – DevOps for Humans – Basics

0 0


ansible-iwp

Presentation for the Ithaca Web People

On Github a-fro / ansible-iwp

Ansible

DevOps for Humans

Created for the Ithaca Web People Meetup by @aaronfroehlich

Who Am I?

Demo

What is Ansible?

  • Server configuration tool similar to Puppet, Chef or Salt
  • Known for having an agentless architecture
  • Host computer communicates with json protocol over ssh
  • No daemons running ongoing processes

Key Features

Basics

Inventories:

          [dev]
          a-fro.dev

          [staging]
          stage.a-fro.com

          [production]
          a-fro.com

          [droplets:children]
          staging
          production

Basics

Commands:


            ansible production -m ping -i inventory
            

Basics

Modules:


            ansible production -m ping -i inventory
            

List of all Modules

Basics

Tasks:


            ---
              - name: Get software for Python-based control.
                apt: "pkg={{ item }} state=installed"
                with_items:
                - curl
                - python-apt
                - python-pycurl
            

Basics

Variables:


              ---
              domain: "ithacawebpeople.dev"
              webroot: "/var/www/{{ domain }}"
              repo_url: "git@github.com:a-fro/ansible-iwp.git"

              apache_vhosts:
                - {servername: "{{ domain }}", documentroot: "{{ webroot }}"}

            

Basics

Playbooks:


              ---
              - hosts: drupal7
                tasks:
                  - name: Download drupal core patch.
                    get_url:
                      url: https://www.drupal.org/files/issues/SA-CORE-2014-005-D7.patch
                      dest: /tmp/SA-CORE-2014-005-D7.patch

                  - name: Apply the patch from the drupal docroot.
                    shell: "patch -p1 < /tmp/SA-CORE-2014-005-D7.patch chdir={{ drupal_docroot }}"

                  - name: Restart apache (or nginx, and/or php-fpm, etc.) to rebuild opcode cache.
                    service: name=httpd state=restarted

                  - name: Clear Drupal caches (because it's always a good idea).
                    command: "drush cc all chdir={{ drupal_docroot }}"

                  - name: Ensure we're not vulnerable anymore.
                    [redacted]
            

Basics

Roles:

  • Like RubyGems or Node Packaged Modules
  • Widely available through Ansible Galaxy
  • Creates a modular structure easily configurable via variables

Demo

Additional Resources

Thanks!