Comments (7)
I am definitely not saying that ansible's approach is good, but I still feel that the current abstraction is not intuitive.
from nornir.
Let's start by saying this is not ansible, so if you try to extrapolate everything from ansible without reading the docs you are doomed to be confused.
But what does it really mean that to run the task write_file on a number of networking devices without digging a lot into doc?
Well, if you don't read the docs you can only guess and maybe, only maybe, get it right. But that's why the docs are there :) Take for example the command
and remote_command
tasks (https://nornir.readthedocs.io/en/latest/plugins/tasks/commands.html) I think it's pretty clear what they do and is way less confusing than using delegate_to, connection_local and other crap like that. Also, it doesn't limit you to one mode as you can combine them as you please.
I need to check docs or sometimes source code to be sure.
Well, reading the docs should be a must :) Checking the source code shouldn't so if something is not clear feel free to raise an issue or a PR to improve them.
I am afraid I don't understand the problem you are describing as the "localhost" mode of ansible is how nornir works and you seem to be proposing solutions to implement exactly that. I was actually thinking in writing a plugin/task/wrapper to allow running code remotely in linux servers but that hasn't been a priority yet.
from nornir.
Yes, I am not really seeing an issue here...in Ansible-speak everything by default for Nornir is connection: local
.
from nornir.
I understand your points, just two more things:
1)
https://github.com/nornir-automation/nornir-tools/blob/master/tools/network/backup/backup.py
def backup(task, path):
r = task.run(
task=napalm_get,
getters=["config"],
severity_level=logging.DEBUG,
)
task.run(
task=write_file,
filename=f"{path}/{task.host}",
content=r.result["config"]["running"],
)
We apply this task on a group of networking devices. Don't you find confusing that the first subtask will go to the device and do something (in this case it will collect configuration), but the second task will write the files locally even though the target is a bunch of networking devices? On the first glance (again, without looking into docs), I would assume that it saves the configuration directly on the device, because this is the target.
2) David mentioned that may be at some point there will be tasks to run code remotely, let's imagine this is implemented. What kind of user-facing API would that be?
from nornir.
I think point1 is a fair point, but I find Ansible even more confusing here (so I wouldn't want to follow patterns similar to what they do).
I would say the essential item is that the location where tasks are run is dictated by the task. So a 'napalm_' task or a 'netmiko_' task is inherently on the remote network device whereas a write_file task would be a control machine task.
So I would say the problem is how to clearly indicate where a task is being executed (and whether this indication is necessary).
from nornir.
I am closing this ticket. Feel free to reopen if there is anything else to discuss but I think this is just a matter of making sure people understands all the code runs locally and properly document which connection type other tasks utilizes so they are aware when netmiko/paramiko/napalm/others are used with the implications those may have.
from nornir.
@dbarrosop
On slack you mentioned that you create empty localhost
in your inventory to do host-agnostic tasks. Do you think we could add implicit localhost
to the inventory? Or it would be too much magic
?
from nornir.
Related Issues (20)
- Does support to initialize SimpleInventory with native objects still work? HOT 2
- SimpleInventory crashes with empty hosts file HOT 5
- use plugin after, how to write Cisco's enable password HOT 5
- Fallback to local credentials in case of TACACS unavailability HOT 2
- Can't get device state from Nornir HOT 5
- Create a second connection HOT 1
- No output from Cisco XR on "admin show inventory" HOT 2
- Threading Nornir with Netbox inventory HOT 3
- mypy_extensions is only declared as a dev dependency but it directly imported HOT 3
- Contiribute documentation referes to makefile targets that don't exist HOT 1
- Remove mypy_extensions this has been deprecated HOT 1
- Need to add tests into ci-cd to ensure wheel built from pyproject.toml file is importable HOT 2
- Need support for reading in plural hosts.yaml in order to format the stored switch infos HOT 2
- Async architecture (inventory) HOT 30
- Async Architecture Topics HOT 5
- Shell prompt hangs once Result is printed when at least one host fails if InitNornir is done inside main()
- Processors: ability to know the run hosts HOT 2
- Inventory Data Plugin HOT 5
- Serialization in grouped tasks breaks when using click HOT 15
- Docs - fixing several broken hyperlinks HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nornir.