-
Notifications
You must be signed in to change notification settings - Fork 0
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
15 changed files
with
1,119 additions
and
35 deletions.
There are no files selected for viewing
Submodule NetAutomationExamples
added at
567767
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,4 @@ | ||
| ansible-vmx1 | ||
| ansible-vmx2 | ||
| ansible-vmx3 | ||
| ansible-vmx4 |
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,50 @@ | ||
| --- | ||
| ## First Play | ||
| - hosts: localhost | ||
| name: Create per node data model | ||
| gather_facts: no | ||
| tags: [ model ] | ||
| vars_files: | ||
| - "core/{{model|default('core-model.yml')}}" | ||
| tasks: | ||
| - name: Create per-node data model from fabric data model | ||
| template: src=core/core-to-nodes.j2 dest=./nodes.yml | ||
|
|
||
| ## Second Play | ||
| - name: Generate Configuration for all routers | ||
| gather_facts: no | ||
| connection: local | ||
| hosts: all | ||
| tags: [ template ] | ||
| tasks: | ||
| - include_vars: "./nodes.yml" | ||
| - name: create the directory for the configuration | ||
| file: path=core_config state=directory | ||
| run_once: true | ||
| - name: Generate Configuration | ||
| template: src={{ansible_network_os}}/core.j2 dest=core_config/{{inventory_hostname}}-config.txt | ||
|
|
||
| ## Third Play | ||
| # commit variable is used to control the play | ||
| # if commit=0 then we will not commit the changes we will only generate diff | ||
| # if commit=1 then we will commit the changes and generate diff | ||
| - name: push the configuration to the devices | ||
| gather_facts: no | ||
| # connection: local | ||
| hosts: all | ||
| tags: [ deploy ] | ||
| tasks: | ||
| - include_vars: "./nodes.yml" | ||
| - file: path=diff state=directory | ||
| run_once: true | ||
| - name: load the configuration to the devices | ||
| napalm_install_config: | ||
| hostname: "{{ ansible_host }}" | ||
| username: "{{ ansible_user }}" | ||
| dev_os: "{{ ansible_network_os }}" | ||
| optional_args: | ||
| key_file: "{{ ansible_ssh_private_key_file }}" | ||
| config_file: core_config/{{inventory_hostname}}-config.txt | ||
| commit_changes: "{{commit}}" | ||
| diff_file: diff/{{inventory_hostname}}-diff.txt | ||
| when: "inventory_hostname in nodes.keys()" |
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,46 @@ | ||
| --- | ||
|
|
||
| common: | ||
| bgp_asn: 65000 | ||
|
|
||
| nodes: | ||
| - name: ansible-vmx1 | ||
| mgmt: 10.39.0.41 | ||
| rid: 10.39.8.41 | ||
|
|
||
| - name: ansible-vmx2 | ||
| mgmt: 10.39.0.42 | ||
| rid: 10.39.8.42 | ||
|
|
||
| - name: ansible-vmx3 | ||
| mgmt: 10.39.0.43 | ||
| rid: 10.39.8.43 | ||
|
|
||
| - name: ansible-vmx4 | ||
| mgmt: 10.39.0.44 | ||
| rid: 10.39.8.44 | ||
|
|
||
| links: | ||
| - {left: ansible-vmx1, left_port: ge-0/0/0, left_ip: 172.10.12.1, | ||
| right: ansible-vmx2, right_port: ge-0/0/0, right_ip: 172.10.12.2, cost: 10 } | ||
|
|
||
| - {left: ansible-vmx1, left_port: ge-0/0/1, left_ip: 172.10.13.1, | ||
| right: ansible-vmx3, right_port: ge-0/0/0, right_ip: 172.10.13.3, cost: 10 } | ||
|
|
||
| - {left: ansible-vmx2, left_port: ge-0/0/1, left_ip: 172.10.23.2, | ||
| right: ansible-vmx3, right_port: ge-0/0/1, right_ip: 172.10.23.3, cost: 10 } | ||
|
|
||
| - {left: ansible-vmx1, left_port: ge-0/0/2, left_ip: 172.10.14.1, vlan: 40, | ||
| right: ansible-vmx4, right_port: ge-0/0/0, right_ip: 172.10.14.4, cost: 10 } | ||
|
|
||
| bgp: | ||
| rr: [10.39.8.41] | ||
| clients: [10.39.8.42, 10.39.8.43, 10.39.8.44] | ||
| af: | ||
| - inet | ||
| - inet-vpn | ||
|
|
||
| ospf: | ||
| area: 0 | ||
| network: p2p | ||
|
|
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,52 @@ | ||
| # | ||
| # Nodes in the network | ||
| # | ||
| {% macro core_link(name,ip,cost,vlan,remote) %} | ||
| {{name}}.{{vlan}}: { ip: {{ip}}, remote: {{remote}} {% if cost %}, cost: {{cost}}{% endif %} {% if vlan %}, vlan: {{vlan}}{% endif %}}{% endmacro %} | ||
|
|
||
| --- | ||
|
|
||
| common: | ||
| bgp_asn: {{ common.bgp_asn }} | ||
|
|
||
| nodes: | ||
| {% for node in nodes %} | ||
|
|
||
| {{ node.name }}: | ||
| mgmt: {{ node.mgmt }} | ||
| rid: {{ node.rid }} | ||
| links: | ||
| {% for link in links %} | ||
| {% if link.left == node.name %} | ||
| {{ core_link(link.left_port,link.left_ip,link.cost|default(''),link.vlan|default('0'),link.right) }} | ||
| {% elif link.right == node.name %} | ||
| {{ core_link(link.right_port,link.right_ip, link.cost|default(''),link.vlan|default('0'),link.left) }} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% if bgp is defined %} | ||
| bgp: | ||
| ibgp: | ||
| {% if node.rid in bgp.rr %} | ||
| rr: true | ||
| peers: | ||
| {% for peer in bgp.clients %} | ||
| - {{ peer }} | ||
| {% endfor %} | ||
| {% else %} | ||
| peers: | ||
| {% for peer in bgp.rr %} | ||
| - {{ peer }} | ||
| {% endfor %} | ||
| {% endif %} | ||
| af: | ||
| {% for af in bgp.af %} | ||
| - {{ af }} | ||
| {% endfor %} | ||
| {% endif %} | ||
| {% if ospf is defined %} | ||
| ospf: | ||
| area: {{ospf.area}} | ||
| network: {{ospf.network}} | ||
| {% endif %} | ||
| {% endfor %} | ||
|
|
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,158 @@ | ||
|
|
||
| system { | ||
| host-name ansible-vmx1; | ||
| no-redirects; | ||
| root-authentication { | ||
| encrypted-password "$5$mcE0Hfiq$JfBeC3QSAvnd1tjqlOhlYXDgVrwvd6S4G3oVj5wiMO7"; ## SECRET-DATA | ||
| } | ||
| login { | ||
| user salt { | ||
| uid 2001; | ||
| class super-user; | ||
| authentication { | ||
| encrypted-password "$5$yp7ziGTI$F5F.6AUlR8hDK2JIsw5WRrTLex/yTCWH3iSR1Auk293"; ## SECRET-DATA | ||
| ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjxY2hLZ+ju5wdK4GYNhKGgnS8EWLBoEVpo+xQkhDzkTiBx3HGAnmARcVV0B9MqrHZl1omdnirJeygWzVbVY4yPUqGgEcUsTTq9fvK4AjTwtaoB5txAosaOnZq0zewmuZ6EMi6E3RND6A3FGXkf1Il2jg3I8k/dGqdyFI80B7sWy90fk+EqsGMPxVc+l5vAtY2jm84ellxxzBsulxfCSKPH86hZ1GqZ8A1ZBWITu15NjQw0aGssSYGMMTa1T8eFyY4hHWqqdwgOlODg9mZwwP1JdJH79SRoTOjqGGixuAFDGAgH3fNX6u8wTmYya/z7WXH6B2XwiiaZYdcyEbMLPZt"; ## SECRET-DATA | ||
| } | ||
| } | ||
| } | ||
| services { | ||
| ssh; | ||
| netconf { | ||
| ssh; | ||
| traceoptions { | ||
| file nc.txt size 1m world-readable; | ||
| flag incoming; | ||
| } | ||
| } | ||
| } | ||
| syslog { | ||
| user * { | ||
| any emergency; | ||
| } | ||
| file messages { | ||
| any any; | ||
| authorization info; | ||
| } | ||
| file interactive-commands { | ||
| interactive-commands any; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| interfaces { | ||
| ge-0/0/0 { | ||
| description "ansible-vmx2" | ||
| unit 0 { | ||
| family inet { | ||
| address 172.10.12.1/24 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ge-0/0/1 { | ||
| description "ansible-vmx3" | ||
| unit 0 { | ||
| family inet { | ||
| address 172.10.13.1/24 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ge-0/0/2 { | ||
| description "ansible-vmx4" | ||
| vlan-tagging; | ||
| encapsulation flexible-ethernet-services; | ||
| unit 40 { | ||
| vlan-id 40; | ||
| family inet { | ||
| address 172.10.14.1/24 | ||
| } | ||
| family mpls; | ||
| } | ||
| } | ||
|
|
||
| fxp0 { | ||
| description "OOB to MGMT Network"; | ||
| unit 0 { | ||
| family inet { | ||
| address 10.39.0.41/24; | ||
| } | ||
| } | ||
| } | ||
| lo0 { | ||
| unit 0 { | ||
| family inet { | ||
| address 10.39.8.41/32; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| routing-options { | ||
| router-id 10.39.8.41; | ||
| autonomous-system 65000; | ||
| static { | ||
| route 0.0.0.0/0 { | ||
| next-hop 10.39.0.1; | ||
| no-readvertise; | ||
| preference 255; | ||
| } | ||
| } | ||
| } | ||
| protocols { | ||
| bgp { | ||
| group Core { | ||
| type internal; | ||
| local-address 10.39.8.41; | ||
| cluster 10.39.8.41; | ||
| family inet { | ||
| unicast; | ||
| } | ||
| family inet-vpn { | ||
| unicast; | ||
| } | ||
| neighbor 10.39.8.42; | ||
| neighbor 10.39.8.43; | ||
| neighbor 10.39.8.44; | ||
| } | ||
| } | ||
| ospf { | ||
| area 0 { | ||
| interface ge-0/0/0.0 { | ||
| interface-type p2p; | ||
| metric 10; | ||
| } | ||
| interface ge-0/0/1.0 { | ||
| interface-type p2p; | ||
| metric 10; | ||
| } | ||
| interface ge-0/0/2.40 { | ||
| interface-type p2p; | ||
| metric 10; | ||
| } | ||
| interface lo0.0 { | ||
| passive; | ||
| } | ||
| } | ||
| } | ||
| ldp { | ||
| interface ge-0/0/0.0; | ||
| interface ge-0/0/1.0; | ||
| interface ge-0/0/2.40; | ||
| interface lo0.0; | ||
| } | ||
| rsvp { | ||
| interface ge-0/0/0.0; | ||
| interface ge-0/0/1.0; | ||
| interface ge-0/0/2.40; | ||
| } | ||
| mpls { | ||
| interface ge-0/0/0.0; | ||
| interface ge-0/0/1.0; | ||
| interface ge-0/0/2.40; | ||
| } | ||
| lldp { | ||
| interface ge-0/0/0; | ||
| interface ge-0/0/1; | ||
| interface ge-0/0/2; | ||
| } | ||
| } |
Oops, something went wrong.