-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New inventory requires "hostname" even when not needed #289
Comments
I should note that the following inventory does resolve the issue but is not an appropriate long-term solution.
|
A few notes:
Nornir doesn't assume defaults so if you don't specify hostname, port or something else it will assume it's not needed and won't be passed around, it won't assume that because you are trying to use ssh (netmiko or paramiko) it's going to be port 22, the underlying lib might but not nornir. As a workaround we could pass an option to the
|
I understand your first two points, but not the third. Why would multiple hosts share a common hostname? I see this as being equivalent to defining Overall this isn't a big deal so long as consumers clearly understand how to use nornir in that it doesn't try to "out think" its underlying libraries. |
Virtualization, console servers; the hostname may point to the virtualization cluster or the console server while the port points to the specific VM/device. In any case, it's mostly done for consistency. All attributes behave the same way. I understand the convenience of auto assigning the hostname from the yaml so I don't mind adding the optional feature. |
I think it is probably fine the way it is...in Ansible INI-style format it is more assumed that the name by itself is something you could connect to. Once you are in YAML, I think the assumption that YAML entry name is what you would connect to is much lower. I would probably be against making it an option in InitNornir as it adds complexity in the code, and it adds complexity in the inventory (i.e. where is "hostname" coming from: is it coming from the host-yaml entry, the group-yaml entry, the default-yaml entry or from this implied "name" entry). I think it is probably not worth adding that extra choice. I also think the mapping the schema is clearer in not doing this. |
I am against changing the current defaults, but I am open to the feature "auto-populating the hostname" (as long as it is not default!) because "Explicit is better than implicit". @nickrusso42518
|
I disagree with @dmfigol here:
It presupposes that we are going to put the right behavior into the connection-plugin and implement the proper checking there as opposed to (generally) letting the arguments flow through to the underlying library. For example in Netmiko, Netmiko can use either a I think it is a mistake to try to push this checking up into the Nornir connection-plugin. We would push a lot of complexity into the connection-plugin and likely have a set of bugs because of it. |
I agree with ktbyers. I think we should log what we are passing to the connection plugins but we shouldn't add any smartness. Imagine you write a connection plugin that uses some service discovery tool instead of DNS/IP to connect to devices/services, making |
I agree adding smartness would be messy and puts undue pressure on Nornir to know "too much" about the libraries it consumes. The auto-population option would be nice and seems relatively easy to implement. I imagine this would also slightly simplify v1 to v2 migrations. Is there any reason not to enable this by default? I noticed @dbarrosop said Nornir doesn't assume defaults, and I also assume this is by design. Any particular reason for it, or is "Explicit better than implicit" a big part of the Nornir implementation plan? All in all this isn't a big deal, and could probably be mitigated with a bit of documentation. https://github.com/nornir-automation/nornir/blob/develop/docs/upgrading/1_to_2.rst After saying
|
@ktbyers @dbarrosop |
Pretty much.
Yeah, and that's as far as we should go I think; we don't manipulate parameters, we don't assume a parameter is wrong, we just map them for convenience and if a user overrides that mapping that fact is respected (lines 49-50 in that same file). As of today nornir is not in the business of abstracting connection plugins and if we decide to do it (I am not against it) we should do it explicitly by having a wrapper around existing connection plugins and tasks so the user can explicitly choose to use the abstractions (something new) or be explicit about which one to use (current plugins/tasks). |
I agree that an option to autopopulate the hostname would be nice, but for now I'm using the following as a simple workaround:
|
Closing as not an issue (i.e. the current behavior is the intended behavior). |
Version 2.0.0 has introduced a regression requiring the
hostname
key to be defined for individual inventory hosts. This is a poor assumption since an environment with name resolution (DNS, local hosts file, or otherwise) should not require such information. For example, this inventory worked in Version 1.x because the hostnamecsr1000v
is resolvable.However when running the existing Nornir runbook, an exception is raised because the
hostname
key is undefined. Even worse, the error message saysip
orhost
must be defined which aren't even the right keys.I recommend two things:
The text was updated successfully, but these errors were encountered: