How to use the nornir.plugins.tasks.text function in nornir

To help you get started, we’ve selected a few nornir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nornir-automation / nornir / tests / plugins / tasks / text / test_template_string.py View on Github external
def test_template_string(self, nornir):

        result = nornir.run(text.template_string, template=simple_j2)

        assert result
        for h, r in result.items():
            assert "host-name: {}".format(h) in r.result
            if h == "host1.group_1":
                assert "my_var: comes_from_host1.group_1" in r.result
            if h == "host2.group_1":
                assert "my_var: comes_from_group_1" in r.result
github twin-bridges / nornir_course / class5 / exercises / exercise4 / exercise4b.py View on Github external
def junos_acl(task):
    in_yaml = task.run(task=data.load_yaml, file=f"acl.yaml")
    in_yaml = in_yaml[0].result
    multi_result = task.run(
        task=text.template_file, template="acl.j2", path=".", acls=in_yaml
    )

    print()
    print("#" * 80, end="")
    print(multi_result[0].result)
    print("#" * 80)
    print()
github twin-bridges / nornir_course / class6 / exercises / exercise2 / exercise2a / exercise2a.py View on Github external
def render_configurations(task):
    task.run(task=text.template_file, template="loopback.j2", path=".", **task.host)
github twin-bridges / nornir_course / class5 / exercises / exercise5 / exercise5c.py View on Github external
def render_configurations(task):
    bgp = task.run(
        task=text.template_file, template="bgp.j2", path="nxos/", **task.host
    )
    intf = task.run(
        task=text.template_file, template="routed_int.j2", path="nxos/", **task.host
    )
    task.host["bgp_config"] = bgp.result
    task.host["intf_config"] = intf.result
github twin-bridges / nornir_course / class5 / exercises / exercise5 / exercise5b.py View on Github external
def render_configurations(task):
    bgp = task.run(
        task=text.template_file, template="bgp.j2", path="nxos/", **task.host
    )
    intf = task.run(
        task=text.template_file, template="routed_int.j2", path="nxos/", **task.host
    )
    task.host["bgp_config"] = bgp.result
    task.host["intf_config"] = intf.result