Introduction to CLI Automation with Ansible

Similar documents
Introduction to Ansible

Hands on New Tech Fast and FREE with DevNet Sandbox

vagrant up for Network Engineers Do it like they do on the Developer Channel!

Ansible: Server and Network Device Automation

Housekeeping. Timing Breaks Takeaways

Contents. Prerequisites 1. Linux 1. Installation 1. What is Ansible? 1. Basic Ansible Commands 1. Ansible Core Components 2. Plays and Playbooks 8

Study Guide. Expertise in Ansible Automation

Ansible Essentials 5 days Hands on

Ansible F5 Workshop +

Red Hat Ansible Workshop. Lai Kok Foong, Kelvin

Infoblox and Ansible Integration

Ansible and Firebird

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other

Ask an Expert: Ansible Network Automation

Harnessing your cluster with Ansible

Ansible. For Oracle DBAs. Alexander Hofstetter Trivadis GmbH

Choosing an orchestration tool: Ansible and Salt. Ken Wilson Opengear. Copyright 2017 Opengear, Inc. 1

Ansible Hands-on Introduction

Deploying MySQL HA. with Ansible and Vagrant (101) Daniel Guzman Burgos (Percona) Robert Barabas (Percona)

Ansible. Go directly to project site 1 / 36

Malaysian Open Source Conference (The) Multi Facets of the Open Source Tools. Muhammad Najmi Ahmad Zabidi

Ansible at Scale. David Melamed Senior Research Engineer, CTO Office, CloudLock

ansible-workshop Documentation

Splunk and Ansible. Joining forces to increase implementation power. Rodrigo Santos Silva Head of Professional Services, Tempest Security Intelligence

An introduction to ANSIBLE. Anand Buddhdev RIPE NCC

UCS Director Creating and Utilizing Custom Tasks and Script Modules

Get Automating with Infoblox DDI IPAM and Ansible

AUTOMATION ACROSS THE ENTERPRISE

Cloud and Devops - Time to Change!!! PRESENTED BY: Vijay

GIVING POWER TO THE PEOPLE With General Mills

Dell EMC Networking Ansible Integration Documentation

SELF-SERVICE IT WITH ANSIBLE TOWER & MICROSOFT AZURE. Chris Houseknecht Dave Johnson. June #redhat #rhsummit

Ansible Bootcamp. Bruce Becker: Coordinator, Africa-Arabia ROC

Managing 15,000 network devices with Ansible. Landon Holley & James Mighion May 8, 2018

(Almost) Instant monitoring

Be smart. Think open source.

ANSIBLE TOWER OVERVIEW AND ROADMAP. Bill Nottingham Senior Principal Product Manager

OPEN SOURCING ANSIBLE

Unix for Software Developers

Getting started with Ansible and Oracle

Modern Provisioning and CI/CD with Terraform, Terratest & Jenkins. Duncan Hutty

Zero Touch Provisioning of NIOS on Openstack using Ansible

Database Operations at Groupon using Ansible. Mani Subramanian Sr. Manager Global Database Services Groupon

Ansible - Automation for Everyone!

Henry Stamerjohann. Apfelwerk GmbH & Co. #macadmins

AGENTLESS ARCHITECTURE

Ansible in Operation. Bruce Becker: Coordinator, SAGrid

MULTI CLOUD AS CODE WITH ANSIBLE & TOWER

Getting Started with Ansible for Linux on z David Gross

Getting Started with Ansible - Introduction

Introduction to Ansible. yench

DevOPS, Ansible and Automation for the DBA. Tech Experience 18, Amsersfoot 7 th / 8 th June 2018

Infrastructure at your Service. Setup Oracle Infrastructure with Vagrant & Ansible

Managing BSD Systems with Ansible

Automate Patching for Oracle Database in your Private Cloud

Ansible + Hadoop. Deploying Hortonworks Data Platform with Ansible. Michael Young Solutions Engineer February 23, 2017

Ansible and Ansible Tower by Red Hat

Ansible Tower on the AWS Cloud

AUTOMATION FOR EVERYONE Accelerating your journey to the Hybrid Cloud with Ansible Tower

Infrastructure As Code. Managing BSD systems with Ansible. Overview. Introduction to Ansible

Automate DBA Tasks With Ansible

ABOUT INTRODUCTION ANSIBLE END Ansible Basics Oleg Fiksel Security CSPI GmbH OpenRheinRuhr 2015

Ansible Tower Quick Setup Guide

Ansible in Depth WHITEPAPER. ansible.com

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

IN DEPTH INTRODUCTION ARCHITECTURE, AGENTS, AND SECURITY

Sanjay Shitole, Principle Solutions Engineer

WHAT IS ANSIBLE AND HOW CAN IT HELP ME?

Ansible. Systems configuration doesn't have to be complicated. Jan-Piet

How to avoid boring work - Automation for DBAs

Infrastructure Configuration and Management with Ansible. Kaklamanos Georgios

INTRODUCTION CONTENTS BEGINNER S GUIDE: CONTROL WITH RED HAT ANSIBLE TOWER

ANSIBLE AUTOMATION AT TJX

Ansible Tower Quick Setup Guide

Button Push Deployments With Integrated Red Hat Open Management

C Commands. Send comments to

Rapid Deployment of Bare-Metal and In-Container HPC Clusters Using OpenHPC playbooks

OSPF Mechanism to Exclude Connected IP Prefixes from LSA Advertisements

HASHICORP TERRAFORM AND RED HAT ANSIBLE AUTOMATION Infrastructure as code automation

Automation: Making the Best Choice for Your Organization

Enhancing Secrets Management in Ansible with CyberArk Application Identity Manager

AUTOMATING THE ENTERPRISE WITH ANSIBLE. Dustin Boyd Solutions Architect September 12, 2017

ANSIBLE SERVICE BROKER Deploying multi-container applications on OpenShift Todd Sanders John Matthews OpenShift Commons Briefing.

Ansible Tower Quick Install

Table of Contents HOL ADV

This tutorial is prepared for the beginners to help them understand the basics of Ansible. It can also help as a guide to engineers.

Network Automation with Ansible. Jason Edelman

goodplay Documentation

ansible-eos Documentation

ANSYS v14.5. Manager Installation Guide CAE Associates

Ansible. -- Make it so

Splunk ConfiguraAon Management and Deployment with Ansible

Automation and configuration management across hybrid clouds with CloudForms, Satellite 6, Ansible Tower

OSPF Sham-Link MIB Support

Kaseya 2. User Guide. Version 7.0

Zabbix Ansible Module. Patrik Uytterhoeven

From Nothing to Something using AutoCAD Electrical

Mini Turty II Robot Getting Started V1.0

From Docker les to Ansible Container

Building and Managing Clouds with CloudForms & Ansible. Götz Rieger Senior Solution Architect January 27, 2017

Transcription:

Introduction to CLI Automation with Ansible Tim Nothnagel, Consulting Engineer Mike Leske, Technical Leader

Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#

Agenda Introduction to Ansible Getting Started with Ansible Using Ansible Command Line, Playbooks & Templates Lab Introduction Lab Scenario Conclusion

Session Objective Understanding of the basic principles of Ansible Being able to write a playbook including various Ansible concepts Getting hands-on experience in using Ansible with IOS, IOS XR and NX-OS 5

Timetable 9:00h - 9:45h Ansible & Lab Intro 9:45h - 12:45h Lab time 12:45h - 13:00h Wrap up 6

Related Sessions DEVNET-1002 NetDevOps for the Network Dude DEVNET-1223 IOS-XR Automation with Ansible TECDEV-4500 Automating Network Operations with Ansible BRKDCN-2025 Maximizing Network Programmability and Automation (...) 7

Introduction to Ansible

Ansible Overview Open Source Agentless Simple Wide Adoption Con! guration Management Orchestration Deployment 10

Getting Started with Ansible

Getting started with Ansible Ansible Controller Targets SSH (user/pass, public key) 1. Push configuration 2. Get configuration/state 3. Execute commands ansible.cfg Inventory Playbooks Modules 12

Using Ansible

Common Ansible Terms? Let s first cover the basic terms and concepts. 14

Ansible Configuration ansible.cfg The place for adjusting default settings based on your requirements Multiple alternative places for parameters and setting exists Typically, default settings are sufficient for most users Precedence order of Ansible configuration files (in this order): 1. ANSIBLE_CONFIG (an environment variable) 2. ansible.cfg (in the current directory) 3..ansible.cfg (in the home directory) 4. /etc/ansible/ansible.cfg (global ansible configuration) This lab uses ansible.cfg in scenario/project directory 15

Further reading: http://docs.ansible.com/ansible/latest/intro_inventory.html Inventory INI format file usually called hosts Defines the hosts which Ansible manages Hosts can be grouped together with [] Additional optional parameters can be defined Where does Ansible look for the inventory file: Option 1 (Default): /etc/ansible/hosts Option 2: inventory parameter in local ansible.cfg Option 3: -i <path> option on the command line $ cat ansible/hosts [core] CORE_XR ansible_host=198.18.1.5 [branch1] BRANCH_1_CSR ansible_host=198.18.1.12 BRANCH_1_SWITCH ansible_host=198.18.1.11 [branch2] BRANCH_2_CSR ansible_host=198.18.1.22 BRANCH_2_SWITCH ansible_host=198.18.1.21 [csr] BRANCH_1_CSR BRANCH_2_CSR ansible_host=198.18.1.12 ansible_host=198.18.1.22 [switch] BRANCH_1_SWITCH ansible_host=198.18.1.11 BRANCH_2_SWITCH ansible_host=198.18.1.21 16

Modules Prepared Scripts performing an action on a host All modules (~465+ Oct 2017) ship with Ansible Enormous variety of Ansible modules You can write your own modules Further reading: http://docs.ansible.com/ansible/latest/modules.html http://docs.ansible.com/ansible/latest/modules_by_category.html 17

Ad-hoc Command Allows you to execute tasks really quick without saving steps Useful to understand the basics of how Ansible works Further reading: http://docs.ansible.com/ansible/latest/intro_adhoc.html http://docs.ansible.com/ansible/latest/ping_module.html ansible <hosts_section> -m <module> [-a <arguments>] Default module is command ( -m command can be omitted) -m ping is the `Hello World of Ansible $ ansible -a "date" control localhost SUCCESS rc=0 >> Wed Nov 15 05:58:55 CET 2017 $ ansible -m ping core 172.16.20.30 SUCCESS => { "changed": false, "failed": false, "ping": "pong" } 18

Further reading: http://docs.ansible.com/ansible/latest/playbooks.html Playbooks Ansible s method of procedures (MoP) Playbooks store task sequences for later reuse Can have one or more plays and tasks Playbooks are written in YAML $ cat sample.yaml --- - hosts: control gather_facts: no connection: local tasks: - name: PING ANSIBLE CONTROL ping: - name: DATE COMMAND ON CONTROL command: date $ ansible-playbook sample.yaml PLAY [control] ********************************************************************************************************************** TASK [PING ANSIBLE CONTROL] ********************************************************************************************************************** ok: [localhost] 19

Further reading: http://docs.ansible.com/ansible/latest/playbooks_templating.html Ansible & Jinja2 Templates Jinja2 templates further enhance Ansible s configuration modelling capabilities, e.g. represent configlets in native device CLI Jinja2 templates have access to Ansible variables and implement many filters and tests for validation Templating is executed on Ansible controller $ cat ios_interface.j2 {% for interface in interfaces %} {% if interface.name.startswith('gigabit') %} interface {{ interface.name }} ip address {{ interface.intf_address }} {{ interface.intf_netmask }} no shutdown exit! {% endif %} {% endfor %} $ cat ios_interface.yaml - hosts: branch1[0] gather_facts: no connection: local vars: interfaces: - name: GigabitEthernet4 intf_address: 10.1.10.2 intf_netmask: 255.255.255.252 - name: GigabitEthernet5 intf_address: 10.1.10.6 intf_netmask: 255.255.255.252 tasks: - name: BUILD DATA INTERFACE CONFIG template: src: templates/ios_interface.j2 dest: configs/ios_interface.cfg - name: CONFIGURE DATA INTERFACES ios_config: src: configs/ios_interface.cfg 20

Typical Folder Structure Project specific inventory Project specific configuration YAML playbooks Folder for configurations created by templates Folder for jinja2 templates 21

Ansible vs. & Cisco NSO

10,000-feet Comparison Ansible Run to completion or error No rollback SSH towards target device Explicit tasks to wrap CLI or operation Cisco NSO Transactions all or nothing Rollback built-in Variety of southbound protocols (Netconf, REST, SNMP,...) Model based abstraction via YANG 23

Reference Architectures Spanning Applications and Networks Further reading: https://www.ansible.com/networks-with-cisco-nso-ansible Application Centric Connectivity Centric Ansible Playbooks NSO NSO Ansible Playbooks App App App App 24

Lab Introduction

Lab Setup Lab contains 1 XRv core router, 2 IOSv branch routers, 2 NX-OS switches and 2 PCs to verify end-to-end connectivity Ansible VM (Ubuntu) running Ansible operations 26

Lab Access Cisco dcloud is used for this lab, a Cisco CCO account is mandatory Click View to get more lab access details In-browser Remote Desktop session Get your dcloud Lab VPN details 27

Lab Access, cont. Option A Access the Windows Workstation directly via in-browser RDP session Option B Use the Cisco AnyConnect Client on your laptop with your Cisco dcloud Lab VPN settings to connect to your lab instance Use RDP to connect to the virtual Windows Workstation Alternatively, while inside dcloud VPN ssh directly into the Ansible controller 28

Lab Access, cont. The Windows Workstation provides access to multiple resources Putty: Atom: Chrome: Maestro: Doubleclick to direcly log into the Ansible controller Text editor with yaml syntax highlighting & FileSync plugin to copy files from/to Ansible controller Access to Internet & Ansible Docs Access to VIRL (not required for this Lab) 29

Lab Scenario

Lab Scenario Exercise Ansible Concepts & Objectives 1 Basics: ansible.cfg, inventory Ad-Hoc Operations, modules 2 Playbooks, parents, wait_for, tags, variables Prepare core config for CORE_XR: Loopback0 Interface, global OSPF activation 3 with_items, when, Jinja2 templates, register, debug Activate OSPF on BRANCH_1_CSR, configure interfaces on CORE_XR and BRANCH_1_CSR 4 nxos_nxapi, device-specific modules OSPF & Interface configuration on BRANCH_1_SWITCH 5 Playbook optimization, vars_dir, import_playbook Re-use playbooks to deploy configuration for BRANCH_2 service 31

Lab Time

Conclusion

Conclusion Ansible is simple and easy to kickstart Ansible can work together with Cisco NSO Before you write a shell script consider to write a playbook! Networking 34

Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#

Please complete your Online Session Evaluations after each session Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt All surveys can be completed via the Cisco Live Mobile App or the Communication Stations Complete Your Online Session Evaluation Don t forget: Cisco Live sessions will be available for viewing on-demand after the event at www.ciscolive.com/global/on-demand-library/.

Continue Your Education Demos in the Cisco campus Walk-in Self-Paced Labs Tech Circle Meet the Engineer 1:1 meetings Related sessions 37

Thank you