Giter Club home page Giter Club logo

Comments (5)

ubaumann avatar ubaumann commented on August 16, 2024

What is your use case where you need the SimpleInventory but empty?

from nornir.

mpaccione avatar mpaccione commented on August 16, 2024

Hi @ubaumann

Initial setup and install of a product to have an empty yaml file for users.
Meaning that the main config.yaml references the file paths correctly and things are in the correct locations but it is empty for users to edit. A better process than having them manually create the files themselves and potentially become confused about other configuration and file path details.

What do you think? Is there a better way here given the exact intention?

from nornir.

ubaumann avatar ubaumann commented on August 16, 2024

I would add a demo host to the configuration file. Mybe the localhost. Otherwise, you have to wait for the response of the maintainer on how he feels about a PR or implementing your inventory plugin.

I assume it also fails if your host file looks like this?

---
...

from nornir.

mpaccione avatar mpaccione commented on August 16, 2024

Correct, it also fails.

Currently I am making a util function that gets the file path from the config yaml and then does a kinda of validation check on the hosts file.

I know the docs say hosts are mandatory so this might be a far fetched request but imo a crash is a really rough way to handle this.

from nornir.

dbarrosop avatar dbarrosop commented on August 16, 2024

My concern with not crashing and allowing an empty hosts file is that if a user makes a typo and points to a file that doesn't exist (i.e. pointing to hosts.yaml while they actually called it hosts.yml) the whole thing will fail silently. You could argue the same is true for groups and defaults but the main difference is that the need for an empty hosts file is an edge case (first time someone asks for this) while lots of people doesn't have groups and defaults.

What I'd suggest is the following; create your own Inventory plugin that inherits from SimpleInventory, before calling super do your check and return an empty inventory if the file doesn't exist or if it's empty. Otherwise call super and just let SimpleInventory do its job.

from nornir.

Related Issues (20)

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.