Network Automation: Ansible 101

Similar documents
NetDevOps Style Configuration Management for the Network

ANSIBLE BEST PRACTICES: THE ESSENTIALS

NetDevOps Style Configuration Management for the Network

DevOps Course Content

Network Automation at Oracle+Dyn NANOG on the Road Boston, 14 Sept 2017

Junos Platform Automation (JAUT)

ANSIBLE BEST PRACTICES: THE ESSENTIALS Ansible Automates: DC. Jamie

Think Small to Scale Big

CSC209. Software Tools and Systems Programming.

NetDevOps for the Network Dude How to get started with API's, Ansible and Python

CSC209. Software Tools and Systems Programming.

NETWORK AUTOMATION TUTORIAL. David Barroso

Optimizing the Usability of YANG Models for Network Automation

Lesson 13 Transcript: User-Defined Functions

Orchestrate JBoss Middleware with Ansible Tower Red Hat Summit San Francisco

Adding Transparency and Automation into the Galaxy Tool Installation Process

Verteego VDS Documentation

Inventory. PlayBook. Python. Ansible Config. Modules SSH

Automation and Programmability using Cisco Open NXOS and DevOps Tools

We are ready to serve Latest Testing Trends, Are you ready to learn?? New Batches Info

Automating, Securing, and Managing Cox Automotive's (AutoTrader) Big Data Infrastructure

Build Cloud like Rackspace with OpenStack Ansible

Deploying a Private OpenStack Cloud at Scale. Matt Fischer & Clayton O Neill

Ansible Cookbook 2014

Automatically deploy Schema Changes with Ansible and Liquibase

Automatically deploy Schema Changes with Ansible and Liquibase

Cisco Network Programmability for the Enterprise NPEN v1.0

VXLAN EVPN Fabric and automation using Ansible

EPHEMERAL DEVOPS: ADVENTURES IN MANAGING SHORT-LIVED SYSTEMS

Getting Started With Containers

Short Read Sequencing Analysis Workshop

Overhauling Dev Arch with Ansible Tower and Docker

Be smart. Think open source.

Cleaning up Exited Docker Containers with Help from Awk and Grep

Zero-Touch Operations - Managing Your Network as Code

Software Development I

INDIGO PAAS TUTORIAL. ! Marica Antonacci RIA INFN-Bari

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

DevOps Course Content

LING 408/508: Computational Techniques for Linguists. Lecture 5

DEVOPS TRAINING COURSE CONTENT

My network deploys. How about yours? EOS APIs. Andrei Dvornic

VPN Quick Configuration Guide. D-Link

DevOps Online Training

Exercises. Cacti Installation and Configuration

Exercises. Cacti Installation and Configuration

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Network Automation using modern tech. Egor Krivosheev 2degrees

You re Leaking: Incident Response in the World of DevOps Jerry Dixon & Levi Gundert

Vagrant and Ansible. Two so2ware tools to create and manage your custom VMs

CATCH ERRORS BEFORE THEY HAPPEN. Lessons for a mature data governance practice

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

L105190: Proactive Security Compliance Automation with CloudForms, Satellite, OpenSCAP, Insights, and Ansible Tower

WHO'S TALKING? Edvinas Aleksejonokas Member of OXID core team Joined two years ago

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Junos Ansible Modules Documentation

CS197U: A Hands on Introduction to Unix

CS354 gdb Tutorial Written by Chris Feilbach

STATS Data Analysis using Python. Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak

WRITING CONSOLE APPLICATIONS IN C

Redhat OpenStack 5.0 and PLUMgrid OpenStack Networking Suite 2.0 Installation Hands-on lab guide

Section 1 Click Instructions Talking Points

EVERYTHING AS CODE A Journey into IT Automation and Standardization. Raphaël Pinson

AN INTRODUCTION TO PERFORMANCE TESTING USING JMETER

Test environment configuration with Ansible.

Oracle Solaris 11 Virtualization

An Introduction to the Puppet Ecosystem

Alternatives for Improving OpenStack Networking to Address NFV Needs

Linux Systems Administration Getting Started with Linux

Media-Ready Network Transcript

Building a Django Twilio Programmable Chat Application

Platform Migrator Technical Report TR

APIs and API Design with Python

Lab #2 Physics 91SI Spring 2013

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Making GENI Experiments Repeatable and Replicable

FISMA COMPLIANCE FOR CONTAINERIZED APPS

Intro. Scheme Basics. scm> 5 5. scm>

Installing and Using Docker Toolbox for Mac OSX and Windows

Network configuration management at CERN

Introducing NEMS Linux: Part 2 Monitoring a Local Linux Server

Automated Cyber Hardening of Mission Management Systems

Red Hat OpenStack Platform 14

NEW TOOLS. ngage vaping. MATT GRISWOLD

Developing and Testing Java Microservices on Docker. Todd Fasullo Dir. Engineering

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

Important DevOps Technologies (3+2+3days) for Deployment

Patching and Updating your VM SUSE Manager. Donald Vosburg, Sales Engineer, SUSE

Consolidation and Review

Quick Prototyping+CI with LXC and Puppet

Introduction to Python Part 2

EDGE Tutorial and Sample Project Overview

SECURITY POLICY COMPLIANCE WITH PUPPET AND ANSIBLE. Sean M. Shore Best Buy MSP RHUG Dec 2017

DCLI User's Guide. Data Center Command-Line Interface 2.7.0

NetDevOps. Building New Culture around Infrastructure as Code and Automation. Tom Davies Sr. Manager,

Lesson 9 Transcript: Backup and Recovery

The Road to Digital Transformation: Increase Agility Building and Managing Cloud Infrastructure. Albert Law Solution Architect Manager

CS 261 Recitation 1 Compiling C on UNIX

Garment Documentation

Transcription:

Network Automation: Ansible 101 APRICOT - Feb 28th, 2017 Bronwyn Lewis and Matt Peterson

Our assumptions New to the world of DevOps No prior Ansible knowledge Want to stop hand-crafting your network configs

Agenda Introduction Tutorial Tutorial dependencies Ansible intro & concepts Introductions Configuration templating DevOps intro Homework, next steps

Tutorial repository https://git.io/vzkzh

Required knowledge 1. basic familiarity with the command line 2. use of a command line text editor (e.g. vim or nano) http://git.io/vzkzh

Technical requirements Required Recommendations Linux, MacOS, or Win10 Ubuntu 16.04 Python 2.7 VM (VirtualBox, Vagrant) Ansible 2.2 http://git.io/vzkzh

Introductions

whois Bronwyn Lewis Technical advisor at SFMIX Networking, systems, and automation @ SFMIX and PCH for 3+ years Background in operations, project management, & international affairs

whois Matt Peterson Principal at Two P (network / systems) President at SFMIX (San Francisco IXP) Previously: Cumulus Networks, Tumblr, Square, Burning Man

Got {Net}DevOps?

DevOps Unite people and {organization appropriate} methods Typically Developers & Operations staff Shared service(s) availability responsibility Not a specific software program, license, certification

{Net}DevOps Leverage common DevOps tenants within Networking Configuration management (today s focus) Infrastructure as code Reactive to infrastructure as a whole Consistency (sometimes viewed as transparency)

This is not a DevOps talk DevOps Kung Fu https://github.com/chef/devops-kungfu Phoenix Project / IT Revolution http://itrevolution.com/ DevOps Cafe podcast http://devopscafe.org/

Automation Tools while true ; do cat ~/.history ; done

Automation tools aren t new Expect (1990) CFEngine (1993) Puppet (2005) NETCONF (2006) OpenConfig (2014) Lots of homegrown tools And much, much more...

Today s frameworks

What s great about frameworks? Technical Benefits - procedural - repeatable - idempotent Other Benefits - open source (majority) - enterprise support - community

Why Ansible? 1. 2. 3. 4. agent less low risk (run it locally) small investment easy to learn (abstraction!)

Abstraction instructions: what: update pkgs where: myserver1, myserver5 when: 23.00UTC reference: pkgs: openssh, apache

How Ansible works * SSH localhost remote host(s) *default assumption, unless module exists for target host OS

(But we re running it locally.) localhost

Terminology

WARNING! Visually boring, but important information packed slides ahead. (Sorry.)

JSON { "roles": { "noc": { "name": "Alice" }, "dev": { "name": "Ian" } } Data exchange format More powerful than CSV Data can imply it s a list, integer, string, etc. }

YAML Human readable data format, subset of JSON Always starts with -- Filename extension.yml or.yaml # EXAMPLE DATA FILE 1 --roles: - { who: dev, name: Ian } - { who: noc, name: Alice } # EXAMPLE DATA FILE 2 --roles: noc: name: Alice dev: name: Ian

Jinja2 # EXAMPLE TEMPLATE Employees: {% for k,v in roles %} Role: {% k %} Name: {% v %} {% endfor %} Python template engine Enumerates files using variable data Supports conditionals: If statements Loops Piping Ansible standard file extension.j2

Hosts # EXAMPLE HOSTS LIST Group host addresses, assign names, specify variables, etc. Default is /etc/ansible/hosts can override this easily [dev] test-switch1 mgmt_ip=10.1.10.1 100.0.0.42 dev-router4 [prod] mywebsite.com 172.16.0.56 name=dev42.prod 172.16.0.17

Playbooks --- name: Generate configs hosts: localhost gather_facts: no roles: - router - switch Specifies execution Single or multiple OK You can write all tasks and vars in a playbook... but not recommended

Facts # EXAMPLE SYSTEM FACTS Gathers information on the remote host(s) Hardware, OS, uptime, MAC address & more You can use this info like a regular variable data point "ansible_architecture": "x86_64", "ansible_bios_date": "09/20/2012", "ansible_bios_version": "6.00",

Inventory [EXAMPLE STRUCTURE] myplaybook.yml roles inventory hosts group_vars sites.yml Allows you to pass in specific data with different playbooks Can specify hosts, group vars, and host-specific vars Can be accessed across multiple roles

Roles A built-in structure for compartmentalizing Roles make it easy / clean to manage execution Makes scaling and collaboration easier! [EXAMPLE STRUCTURE] ansible myplaybook.yml roles router tasks templates switch tasks

Hands-on

General outline Inventory + Roles Variables Templates IP Address Filter Tasks Hosts Playbook

Hello world

Hello world (before)

Hello world (after)

Structure myplaybook.yml inventory group_vars sites.yml hosts roles router tasks main.yml templates template1.j2 vars main.yml switch Lots of ways to structure Use roles? Use an inventory? Global, group, host variables? Depends on your situation No right way

Reference files Copy these from workspace/reference/ config1: we ll use this as our 1st template config2: we ll use this as our 2nd template config1-dhcp: advanced example template config2-dhcp: advanced example template ipaddress: RFC 5737 IP addresses (for demo/docs) variables: we ll use these as our demo vars

Inventory + roles Inventory is an easy way to share variables across roles, as well as managing hosts & host-specific variables Roles make managing multiple templates and sets of tasks easier by compartmentalizing them

Variables Variables can be formatted individually, as a flat list, as a dictionary, or as an array Specific formatting can vary Formatting impacts how you pass variables into templates and tasks be careful here!

Templates You can template anything! Lots of neat advanced features, including: If, when, and for statements/loops Variable manipulation via filters

Tasks Procedural list of actions to execute, which combines templates and vars Conditions can be included, and are based on vars (i.e., only do X when Y is present)

IP address filter The ipaddr() filter is included in Ansible 1.9< Provides an interface to the netaddr Python package; does a lot of neat things including: subnet manipulation address validation address conversion MAC address formatting

Hosts What host we should be running the tasks on normally this would be a remote host, but for us: localhost

Playbook Brings it together: Hosts Roles Tasks Templates Variables And executes! --- name: Create files hosts: localhost connection: local gather_facts: no roles: - router

Running a play [command] [flag] [dir] [playbook] ansible-playbook -i inventory myplaybook.yml

You ve got configs!

And if it didn t work... Common issues: Missing packages? Missing variables? Formatting weirdness? Typos? Ansible can provide clues.

Ansible Debugging 101 Common Ansible debugging issues include: One or more undefined variables: 'dict object' has no attribute 'hostname' One or more undefined variables: 'hostname' is undefined ERROR: Syntax Error while loading YAML script

So what s next? Think how you can apply this to your work Start small; doesn t need to be overly complex Check out more resources...

Some resources books blogs/sites http://jedelman.com/ https://blog.tylerc.me/ https://pynet.twb-tech.com/ http://packetpushers.net/ http://keepingitclassless.net/ http://ansible-tips-and-tricks.rtfd.org/ and more!

Join us for 102 after the break... Advanced templating techniques Inventory + advanced variable & hosts management Dynamic inventory And more!

Thanks! 1. Questions? Comments? 2. Come talk to us! 3. Email or tweet us me@bronwynlewis.com matt@peterson.org @bronwyn @dorkmatt