Giter VIP home page Giter VIP logo

Comments (7)

dmfigol avatar dmfigol commented on August 18, 2024 1

I am definitely not saying that ansible's approach is good, but I still feel that the current abstraction is not intuitive.

from nornir.

dbarrosop avatar dbarrosop commented on August 18, 2024

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.

ktbyers avatar ktbyers commented on August 18, 2024

Yes, I am not really seeing an issue here...in Ansible-speak everything by default for Nornir is connection: local.

from nornir.

dmfigol avatar dmfigol commented on August 18, 2024

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.

ktbyers avatar ktbyers commented on August 18, 2024

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.

dbarrosop avatar dbarrosop commented on August 18, 2024

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.

dmfigol avatar dmfigol commented on August 18, 2024

@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)

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.