Skip to content

Commit 0bd853e

Browse files
contivcontiv
contiv
authored and
contiv
committed
initial comit
0 parents  commit 0bd853e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1528
-0
lines changed

ansible.cfg

+496
Large diffs are not rendered by default.

facts_module.retry

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leaf103

facts_module.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
#Task 1: create vlans on leaf switches
3+
4+
- hosts: leafs
5+
vars:
6+
nxos_provider:
7+
username: "{{ user }}"
8+
password: "{{ pwd }}"
9+
transport: cli
10+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
11+
12+
tasks:
13+
14+
- name: GATHER FACTS FOR Leaf "{{ inventory_hostname }}"
15+
nxos_facts:
16+
provider: "{{ nxos_provider }}"
17+
register: facts_module
18+
19+
- debug: var=facts_module
20+
21+
- name: switch ports qty
22+
set_fact:
23+
ports: "{{ module[0].ports }}"
24+
- debug: var=ports

hosts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This is the default ansible 'hosts' file.
2+
#
3+
# It should live in /etc/ansible/hosts
4+
#
5+
# - Comments begin with the '#' character
6+
# - Blank lines are ignored
7+
# - Groups of hosts are delimited by [header] elements
8+
# - You can enter hostnames or ip addresses
9+
# - A hostname/ip can be a member of multiple groups
10+
11+
[all:vars]
12+
ansible_connection=local
13+
user=admin
14+
pwd=C1sc0123!
15+
gather_fact=no
16+
17+
[leafs]
18+
leaf103 ansible_host=10.2.6.147 lo0_ipaddr=100.64.0.103 lo1_ipaddr=100.64.1.103 hostname=leaf103
19+
leaf101 ansible_host=10.2.6.146 lo0_ipaddr=100.64.0.101 lo1_ipaddr=100.64.1.101 hostname=leaf101
20+
leaf102 ansible_host=10.2.6.145 lo0_ipaddr=100.64.0.102 lo1_ipaddr=100.64.1.102 hostname=leaf102
21+
22+
[spines]
23+
spine201 ansible_host=10.2.6.144 lo0_ipaddr=100.64.0.201 lo1_ipaddr=100.64.1.201 hostname=spine201
24+
spine202 ansible_host=10.2.6.143 lo0_ipaddr=100.64.0.202 lo1_ipaddr=100.64.1.202 hostname=spine202

interface_description.retry

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leaf103

interface_description.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
#Task 1: Configure uplinks to spines
3+
- hosts: leafs
4+
any_errors_fatal: yes
5+
vars_prompt:
6+
name: "confirmation"
7+
prompt: "Did you execute the leaf_underlay playbook? Answer 'Yes' or 'No' "
8+
default: "No"
9+
private: no
10+
11+
vars:
12+
nxos_provider:
13+
username: "{{ user }}"
14+
password: "{{ pwd }}"
15+
transport: cli
16+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
17+
18+
tasks:
19+
20+
- name: Check Confirmation
21+
fail: msg="Playbook run confirmation failed"
22+
when: confirmation != "Yes"
23+
24+
- name: GATHER FACTS FOR Leaf "{{ inventory_hostname }}"
25+
nxos_facts:
26+
provider: "{{ nxos_provider }}"
27+
28+
- debug: var=ansible_net_neighbors
29+
30+
- name: create interface keys
31+
set_fact:
32+
interfaces: "{{ ansible_net_neighbors.keys() }}"
33+
- debug: var=interfaces
34+
35+
36+
- name: Configure uplink interfaces to spines
37+
nxos_config:
38+
provider: "{{ nxos_provider }}"
39+
lines:
40+
- no switchport
41+
- mtu 9216
42+
- medium p2p
43+
- ip unnumbered loopback0
44+
- ip ospf network point-to-point
45+
- ip router ospf UNDERLAY area 0.0.0.0
46+
- no shutdown
47+
parents: interface {{ item }}
48+
match: none
49+
with_items: "{{ interfaces }}"
50+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")
51+
52+
- name: Ensure an interface has the proper description
53+
nxos_interface:
54+
provider: "{{ nxos_provider }}"
55+
name: "{{ item }}"
56+
description: 'Connected-to-{{ ansible_net_neighbors[item][0]["port"] }}-{{ ansible_net_neighbors[item][0]["sysname"] }} '
57+
with_items: "{{ interfaces}}"
58+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")

jinja2_leaf.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- hosts: jinja2_leaf
3+
connection: local
4+
roles:
5+
- jinja2_leaf

leaf_overlay.yml

Whitespace-only changes.

leaf_underlay.retry

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leaf103

leaf_underlay.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
#Task 1: Build the Underlay for all Leafs
3+
- hosts: leafs
4+
connection: local
5+
roles:
6+
- leaf_underlay
7+
8+
vars:
9+
nxos_provider:
10+
username: "{{ user }}"
11+
password: "{{ pwd }}"
12+
transport: cli
13+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
14+
15+
tasks:
16+
17+
- name: GATHER FACTS FOR Leaf "{{ inventory_hostname }}"
18+
nxos_facts:
19+
provider: "{{ nxos_provider }}"
20+
21+
- debug: var=ansible_net_neighbors
22+
23+
- name: CREATE INTERFACE KEYS BASED ON CDP INFORMATION
24+
set_fact:
25+
interfaces: "{{ ansible_net_neighbors.keys() }}"
26+
- debug: var=interfaces
27+
28+
29+
- name: CONFIGURE UPLINK INTERFACES TO SPINES
30+
nxos_config:
31+
provider: "{{ nxos_provider }}"
32+
lines:
33+
- no switchport
34+
- mtu 9216
35+
- medium p2p
36+
- ip unnumbered loopback0
37+
- ip ospf network point-to-point
38+
- ip router ospf UNDERLAY area 0.0.0.0
39+
- no shutdown
40+
parents: interface {{ item }}
41+
match: none
42+
with_items: "{{ interfaces }}"
43+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")
44+
45+
- name: CONFIGURE PROPER DISCRIPTION FOR UPLINKS TO LEAFS BASED ON CDP INFORMATION
46+
nxos_interface:
47+
provider: "{{ nxos_provider }}"
48+
name: "{{ item }}"
49+
description: 'Connected-to-{{ ansible_net_neighbors[item][0]["port"] }}-{{ ansible_net_neighbors[item][0]["sysname"] }} '
50+
with_items: "{{ interfaces}}"
51+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")

leaf_uplink_config.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
#Task 1: Configure uplinks to spines
3+
- hosts: leafs
4+
any_errors_fatal: yes
5+
vars_prompt:
6+
name: "confirmation"
7+
prompt: "Did you execute the leaf_underlay playbook? Answer 'Yes' or 'No' "
8+
default: "No"
9+
private: no
10+
11+
vars:
12+
nxos_provider:
13+
username: "{{ user }}"
14+
password: "{{ pwd }}"
15+
transport: cli
16+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
17+
18+
tasks:
19+
20+
- name: Check Confirmation
21+
fail: msg="Playbook run confirmation failed"
22+
when: confirmation != "Yes"
23+
24+
- name: GATHER FACTS FOR Leaf "{{ inventory_hostname }}"
25+
nxos_facts:
26+
provider: "{{ nxos_provider }}"
27+
28+
- debug: var=ansible_net_neighbors
29+
30+
- name: create interface keys
31+
set_fact:
32+
interfaces: "{{ ansible_net_neighbors.keys() }}"
33+
- debug: var=interfaces
34+
35+
36+
- name: Configure uplink interfaces to spines
37+
nxos_config:
38+
provider: "{{ nxos_provider }}"
39+
lines:
40+
- no switchport
41+
- mtu 9216
42+
- medium p2p
43+
- ip unnumbered loopback0
44+
- ip ospf network point-to-point
45+
- ip router ospf UNDERLAY area 0.0.0.0
46+
- no shutdown
47+
parents: interface {{ item }}
48+
match: none
49+
with_items: "{{ interfaces }}"
50+
when: ansible_net_neighbors[item][0]["sysname"] is search("spine")
51+
52+
- name: Ensure an interface has the proper description
53+
nxos_interface:
54+
provider: "{{ nxos_provider }}"
55+
name: "{{ item }}"
56+
description: 'Connected-to-{{ ansible_net_neighbors[item][0]["port"] }}-{{ ansible_net_neighbors[item][0]["sysname"] }} '
57+
with_items: "{{ interfaces}}"
58+
when: ansible_net_neighbors[item][0]["sysname"] is search("spine")

leafs_uplinks.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
#Task 1: Configure uplinks to spines
3+
- hosts: leafs
4+
any_errors_fatal: yes
5+
vars_prompt:
6+
name: "confirmation"
7+
prompt: "Did you execute the leaf_underlay playbook? Answer 'Yes' or 'No' "
8+
default: "No"
9+
private: no
10+
11+
vars:
12+
nxos_provider:
13+
username: "{{ user }}"
14+
password: "{{ pwd }}"
15+
transport: cli
16+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
17+
18+
tasks:
19+
20+
- name: Check Confirmation
21+
fail: msg="Playbook run confirmation failed"
22+
when: confirmation != "Yes"
23+
24+
- name: GATHER FACTS FOR Leaf "{{ inventory_hostname }}"
25+
nxos_facts:
26+
provider: "{{ nxos_provider }}"
27+
28+
- debug: var=ansible_net_neighbors
29+
30+
- name: create interface keys
31+
set_fact:
32+
interfaces: "{{ ansible_net_neighbors.keys() }}"
33+
- debug: var=interfaces
34+
35+
36+
- name: Configure uplink interfaces to spines
37+
nxos_config:
38+
provider: "{{ nxos_provider }}"
39+
lines:
40+
- no switchport
41+
- mtu 9216
42+
- medium p2p
43+
- ip unnumbered loopback0
44+
- ip ospf network point-to-point
45+
- ip router ospf UNDERLAY area 0.0.0.0
46+
- no shutdown
47+
parents: interface {{ item }}
48+
match: none
49+
with_items: "{{ interfaces }}"
50+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")
51+
52+
- name: Ensure an interface has the proper description
53+
nxos_interface:
54+
provider: "{{ nxos_provider }}"
55+
name: "{{ item }}"
56+
description: 'Connected-to-{{ ansible_net_neighbors[item][0]["port"] }}-{{ ansible_net_neighbors[item][0]["sysname"] }} '
57+
with_items: "{{ interfaces}}"
58+
when: ansible_net_neighbors[item][0]["sysname"] is search("Spine")

roles/jinja2_leaf/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Role Name
2+
=========
3+
4+
A brief description of the role goes here.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10+
11+
Role Variables
12+
--------------
13+
14+
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15+
16+
Dependencies
17+
------------
18+
19+
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20+
21+
Example Playbook
22+
----------------
23+
24+
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25+
26+
- hosts: servers
27+
roles:
28+
- { role: username.rolename, x: 42 }
29+
30+
License
31+
-------
32+
33+
BSD
34+
35+
Author Information
36+
------------------
37+
38+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

roles/jinja2_leaf/defaults/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# defaults file for jinja2_leaf

roles/jinja2_leaf/handlers/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for jinja2_leaf

roles/jinja2_leaf/meta/main.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
galaxy_info:
2+
author: your name
3+
description: your description
4+
company: your company (optional)
5+
6+
# If the issue tracker for your role is not on github, uncomment the
7+
# next line and provide a value
8+
# issue_tracker_url: http://example.com/issue/tracker
9+
10+
# Some suggested licenses:
11+
# - BSD (default)
12+
# - MIT
13+
# - GPLv2
14+
# - GPLv3
15+
# - Apache
16+
# - CC-BY
17+
license: license (GPLv2, CC-BY, etc)
18+
19+
min_ansible_version: 2.4
20+
21+
# If this a Container Enabled role, provide the minimum Ansible Container version.
22+
# min_ansible_container_version:
23+
24+
# Optionally specify the branch Galaxy will use when accessing the GitHub
25+
# repo for this role. During role install, if no tags are available,
26+
# Galaxy will use this branch. During import Galaxy will access files on
27+
# this branch. If Travis integration is configured, only notifications for this
28+
# branch will be accepted. Otherwise, in all cases, the repo's default branch
29+
# (usually master) will be used.
30+
#github_branch:
31+
32+
#
33+
# Provide a list of supported platforms, and for each platform a list of versions.
34+
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
35+
# To view available platforms and versions (or releases), visit:
36+
# https://galaxy.ansible.com/api/v1/platforms/
37+
#
38+
# platforms:
39+
# - name: Fedora
40+
# versions:
41+
# - all
42+
# - 25
43+
# - name: SomePlatform
44+
# versions:
45+
# - all
46+
# - 1.0
47+
# - 7
48+
# - 99.99
49+
50+
galaxy_tags: []
51+
# List tags for your role here, one per line. A tag is a keyword that describes
52+
# and categorizes the role. Users find roles by searching for tags. Be sure to
53+
# remove the '[]' above, if you add tags to this list.
54+
#
55+
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
56+
# Maximum 20 tags per role.
57+
58+
dependencies: []
59+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
60+
# if you add dependencies to this list.

0 commit comments

Comments
 (0)