Skip to main content

No project description provided

Project description

PyPI version Python 3.6 Python 3.7 Python 3.8 Code Style

nornir ansible

Ansible Inventory plugin for nornir.

Install

In most cases installation via pip is the simplest and best way to install nornir_ansible.

pip install nornir_ansible

Basic Example

In your nornir configuration, set the inventory plugin value to AnsibleInventory

---
inventory:
  plugin: AnsibleInventory
  options:
    hostsfile: "inventory.yaml"

The hostsfile inventory option argument should point to a valid Ansible inventory file, in this case a yaml style inventory such as:

---
all:
  vars:
    ansible_python_interpreter: "/usr/bin/python3"
    username: "vrnetlab"
    password: "VR-netlab9"
  children:
    sea:
      hosts:
        sea-eos-1:
          ansible_host: "172.18.0.14"
        sea-nxos-1:
          ansible_host: "172.18.0.12"
      children:
        arista-eos:
          hosts:
            sea-eos-1:
          vars:
            platform: "eos"
        cisco-nxos:
          hosts:
            sea-nxos-1:
          vars:
            platform: "nxos"

Initialize your nornir object and validate the appropriate inventory plugin was loaded, and the inventory file was parsed:

>>> from nornir import InitNornir
>>> nr = InitNornir(config_file="config.yaml")
>>> print(nr.config.inventory.plugin)
<class 'nornir_ansible.plugins.inventory.ansible.AnsibleInventory'>
>>> print(nr.inventory.hosts)
{'sea-eos-1': Host: sea-eos-1, 'sea-nxos-1': Host: sea-nxos-1}
>>>

Useful Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nornir_ansible-2023.12.28.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distribution

nornir_ansible-2023.12.28-py3-none-any.whl (12.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page