-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from nornir import InitNornir | ||
from nornir.core.task import Task, Result | ||
from nornir_utils.plugins.functions import print_result | ||
from nornir_jinja2.plugins.tasks import template_file | ||
from nornir_scrapli.tasks import send_config, send_commands | ||
|
||
|
||
def deploy_base(task: Task) -> Result: | ||
r = task.run(task=template_file, | ||
template="reset.j2", | ||
path="./templates") | ||
|
||
task.host["config"] = r.result | ||
|
||
task.run(task=send_config, | ||
name="Clear all device config!", | ||
dry_run=False, | ||
config=task.host["config"]) | ||
|
||
task.run(task=send_commands, | ||
name="Show new config and copy running config to startup config.", | ||
commands=["show run", "write memory"]) | ||
|
||
if __name__ == "__main__": | ||
nr = InitNornir(config_file="config.yml") | ||
r = nr.run(task=deploy_base) | ||
print_result(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
no hostname {{ host["name"] }} | ||
no username {{ host["default_user"] }} privilege 15 role network-admin secret sha512 {{ host["default_password_sha512"] }} | ||
! | ||
no ip routing | ||
! | ||
no interface Loopback0 | ||
! | ||
{% for interface in host["interfaces"].values() %} | ||
interface {{ interface["name"] }} | ||
no description | ||
no ip address | ||
no ipv6 address | ||
shutdown | ||
! | ||
{% endfor %} | ||
! | ||
no router bgp {{ host["asn"] }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters