{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# ignore this cell, this is just a helper cell to provide the magic %highlight_file\n", "%run ../highlighter.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inventory\n", "\n", "The Inventory is arguably the most important piece of nornir. Let's see how it works. To begin with the [inventory](../api/nornir/core/inventory.html#module-nornir.core.inventory) is comprised of [hosts](../api/nornir/core/inventory.html#nornir.core.inventory.Hosts), [groups](../api/nornir/core/inventory.html#nornir.core.inventory.Groups) and [defaults](../api/nornir/core/inventory.html#nornir.core.inventory.Defaults).\n", "\n", "In this tutorial we are using the [SimpleInventory](../api/nornir/plugins/inventory/simple.html#nornir.plugins.inventory.simple.SimpleInventory) plugin. This inventory plugin stores all the relevant data in three files. Let’s start by checking them:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
1---\n", " 2host1.cmh:\n", " 3 hostname: 127.0.0.1\n", " 4 port: 2201\n", " 5 username: vagrant\n", " 6 password: vagrant\n", " 7 platform: linux\n", " 8 groups:\n", " 9 - cmh\n", " 10 data:\n", " 11 site: cmh\n", " 12 role: host\n", " 13 type: host\n", " 14 nested_data:\n", " 15 a_dict:\n", " 16 a: 1\n", " 17 b: 2\n", " 18 a_list: [1, 2]\n", " 19 a_string: "asdasd"\n", " 20\n", " 21host2.cmh:\n", " 22 hostname: 127.0.0.1\n", " 23 port: 2202\n", " 24 username: vagrant\n", " 25 password: vagrant\n", " 26 platform: linux\n", " 27 groups:\n", " 28 - cmh\n", " 29 data:\n", " 30 site: cmh\n", " 31 role: host\n", " 32 type: host\n", " 33 nested_data:\n", " 34 a_dict:\n", " 35 b: 2\n", " 36 c: 3\n", " 37 a_list: [1, 2]\n", " 38 a_string: "qwe"\n", " 39\n", " 40spine00.cmh:\n", " 41 hostname: 127.0.0.1\n", " 42 username: vagrant\n", " 43 password: vagrant\n", " 44 port: 12444\n", " 45 platform: eos\n", " 46 groups:\n", " 47 - cmh\n", " 48 data:\n", " 49 site: cmh\n", " 50 role: spine\n", " 51 type: network_device\n", " 52\n", " 53spine01.cmh:\n", " 54 hostname: 127.0.0.1\n", " 55 username: vagrant\n", " 56 password: ""\n", " 57 platform: junos\n", " 58 port: 12204\n", " 59 groups:\n", " 60 - cmh\n", " 61 data:\n", " 62 site: cmh\n", " 63 role: spine\n", " 64 type: network_device\n", " 65\n", " 66leaf00.cmh:\n", " 67 hostname: 127.0.0.1\n", " 68 username: vagrant\n", " 69 password: vagrant\n", " 70 port: 12443\n", " 71 platform: eos\n", " 72 groups:\n", " 73 - cmh\n", " 74 data:\n", " 75 site: cmh\n", " 76 role: leaf\n", " 77 type: network_device\n", " 78 asn: 65100\n", " 79\n", " 80leaf01.cmh:\n", " 81 hostname: 127.0.0.1\n", " 82 username: vagrant\n", " 83 password: ""\n", " 84 port: 12203\n", " 85 platform: junos\n", " 86 groups:\n", " 87 - cmh\n", " 88 data:\n", " 89 site: cmh\n", " 90 role: leaf\n", " 91 type: network_device\n", " 92 asn: 65101\n", " 93\n", " 94host1.bma:\n", " 95 groups:\n", " 96 - bma\n", " 97 platform: linux\n", " 98 data:\n", " 99 site: bma\n", "100 role: host\n", "101 type: host\n", "102\n", "103host2.bma:\n", "104 groups:\n", "105 - bma\n", "106 platform: linux\n", "107 data:\n", "108 site: bma\n", "109 role: host\n", "110 type: host\n", "111\n", "112spine00.bma:\n", "113 hostname: 127.0.0.1\n", "114 username: vagrant\n", "115 password: vagrant\n", "116 port: 12444\n", "117 platform: eos\n", "118 groups:\n", "119 - bma\n", "120 data:\n", "121 site: bma\n", "122 role: spine\n", "123 type: network_device\n", "124\n", "125spine01.bma:\n", "126 hostname: 127.0.0.1\n", "127 username: vagrant\n", "128 password: ""\n", "129 port: 12204\n", "130 platform: junos\n", "131 groups:\n", "132 - bma\n", "133 data:\n", "134 site: bma\n", "135 role: spine\n", "136 type: network_device\n", "137\n", "138leaf00.bma:\n", "139 hostname: 127.0.0.1\n", "140 username: vagrant\n", "141 password: vagrant\n", "142 port: 12443\n", "143 platform: eos\n", "144 groups:\n", "145 - bma\n", "146 data:\n", "147 site: bma\n", "148 role: leaf\n", "149 type: network_device\n", "150\n", "151leaf01.bma:\n", "152 hostname: 127.0.0.1\n", "153 username: vagrant\n", "154 password: wrong_password\n", "155 port: 12203\n", "156 platform: junos\n", "157 groups:\n", "158 - bma\n", "159 data:\n", "160 site: bma\n", "161 role: leaf\n", "162 type: network_device\n", "
1---\n", " 2global:\n", " 3 data:\n", " 4 domain: global.local\n", " 5 asn: 1\n", " 6\n", " 7eu:\n", " 8 data:\n", " 9 asn: 65100\n", "10\n", "11bma:\n", "12 groups:\n", "13 - eu\n", "14 - global\n", "15\n", "16cmh:\n", "17 data:\n", "18 asn: 65000\n", "19 vlans:\n", "20 100: frontend\n", "21 200: backend\n", "
1---\n", "2data:\n", "3 domain: acme.local\n", "
1---\n", " 2global:\n", " 3 data:\n", " 4 domain: global.local\n", " 5 asn: 1\n", " 6\n", " 7eu:\n", " 8 data:\n", " 9 asn: 65100\n", "10\n", "11bma:\n", "12 groups:\n", "13 - eu\n", "14 - global\n", "15\n", "16cmh:\n", "17 data:\n", "18 asn: 65000\n", "19 vlans:\n", "20 100: frontend\n", "21 200: backend\n", "