GithubHelp home page GithubHelp logo

dalrrard / ansible-solarwinds-inventory-plugin Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 57 KB

The Ansible Solarwinds Inventory Plugin was built to allow you to use your preexisting Solarwinds NCM inventory information to run Ansible playbooks against.

License: GNU General Public License v3.0

Python 100.00%
ansible ansible-inventory ansible-plugin solarwinds solarwinds-orion

ansible-solarwinds-inventory-plugin's Introduction

Ansible Solarwinds Inventory Plugin
Explore the docs ยป

Report a Bug ยท Request a Feature . Ask a Question

Project license Code style: black

Pull Requests welcome code with love by dalrrard

Table of Contents

About

The Ansible Solarwinds Inventory Plugin was built to allow you to use your preexisting Solarwinds NCM inventory information to run Ansible playbooks against.

Built With

This project was built and tested using Python 3.9 and Ansible 4.8.0 (ansible-core 2.11.6) though earlier versions should work with minimal to no tweaking.

Getting Started

Prerequisites

This plugin currently uses the Cirrus.Nodes table from Solarwinds NCM using the Solarwinds Information Service (SWIS). In the future, the ability to pull information from Orion may be added.

Installation

You can install this plugin in a few ways. The most straightforward is to add the plugin locally as described in these instructions. For convenience, this is how you can add it to your user's home directory in Linux.

mkdir -p ~/.ansible/plugins/inventory

cd ~/.ansible/plugins/inventory

curl -O https://raw.githubusercontent.com/dalrrard/ansible-solarwinds-inventory-plugin/main/solarwinds.py

You can verify that Ansible sees the plugin by running this command:

ansible-doc -t inventory solarwinds

Usage

To use this plugin, you'll need to create a file named any of these names:

  • solarwinds_inventory.yaml
  • solarwinds_inventory.yml
  • solarwinds.yaml
  • solarwinds.yml

The information below is mandatory information to put in the file.

---
plugin: solarwinds
base_url: https://<server-fqdn-or-ip>
username: <vault encrypted username for Solarwinds>
password: <vault encrypted password for Solarwinds>

This details most available options. See Ansible's constructed inventory documentation for more standard options.

---
plugin: solarwinds
base_url: https://<server-fqdn-or-ip>
username: <vault encrypted username for Solarwinds>
password: <vault encrypted password for Solarwinds>
api_port: 17778
verify_ssl: true
additional_properties:
  # Example options. You can use any field from the Cirrus.Nodes table.
  - Location
  - OwningGroup
  - Tenant
  - SiteID
groups:
  cellular_routers: "'-4G' in inventory_hostname or '-4g' in inventory_hostname"
use_connection_profiles: true

The additional_properties option is a list of column names from Cirrus.Nodes that you want to group the inventory by. The plugin automatically retrieves these fields from Cirrus.Nodes:

  • AgentIP
  • SysName
  • ConnectionProfile
  • MachineType
  • OSVersion
  • OSImage

It uses SysName for the ansible_host variable and will attempt to retrieve the ConnectionProfile information for each device and set the ansible_user, ansible_password, and ansible_become_password for each device with the information from the associated profile.

You can use the inventory just like any other. This command will print an inventory graph to your screen of all the hosts and groups they belong to.

ansible-inventory -i solarwinds_inventory.yml --graph --ask-vault-pass

Roadmap

See the open issues for a list of proposed features (and known issues).

Support

Reach out to the maintainer at one of the following places:

Project assistance

If you want to say thank you or/and support active development of Ansible Solarwinds Inventory Plugin:

  • Add a GitHub Star to the project.
  • Tweet about the Ansible Solarwinds Inventory Plugin.
  • Write interesting articles about the project on Dev.to, Medium or your personal blog.

Together, we can make Ansible Solarwinds Inventory Plugin better!

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Authors & contributors

The original setup of this repository is by Dalton Rardin.

For a full list of all authors and contributors, see the contributors page.

Security

Ansible Solarwinds Inventory Plugin follows good practices of security, but 100% security cannot be assured. Ansible Solarwinds Inventory Plugin is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the GNU General Public License v3.

See LICENSE for more information.

ansible-solarwinds-inventory-plugin's People

Contributors

dalrrard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-solarwinds-inventory-plugin's Issues

feat: Make GetConnectionProfile optional

Feature Request

Just wanted to say I appreciate your work on this. We're not fully using Ansible yet, and I was goofing about with my own plugin with... mixed results. I was thinking "there's no way we're the only ones using Orion/NCM as a source!" and was surprised there wasn't one in collections that I could find.

Describe the Feature Request

Invoking GetConnectionProfile is really handy, but depending on how much access and trust we want to give to Ansible, it's unhelpful to have the only option be cutting it out of the script.

Describe Preferred Solution

Add an additional parameter to the inventory source that allows toggling of this feature.

Describe Alternatives

Provide an alternative version with this aspect removed. I could fork and do my own, if that's easier.

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.