Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dell ansible #265

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion canu/generate/switch/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ def error_check_preserve_config(switch_config):
hier_v1.set_order_weight()
for line in hier_v1.all_children_sorted():
switch_config_v1 += line.cisco_style_text() + "\n"
# for line in switch_config.split("\n"):
# switch_config_v1 += line + "\n"

if preserve:
preserve_lag_config = add_preserve_config(switch_config_v1)
Expand Down Expand Up @@ -1414,7 +1416,12 @@ def get_switch_nodes(

# sw-cdu ==> sw-spine
elif switch_name.startswith("sw-cdu"):
lag_number = 255
# dell has a max lag number of 128.
# We are keeping 255 for Aruba so we don't have to renumber LAGs.
if architecture == "network_v1":
lag_number = 110
else:
lag_number = 255
is_primary, primary, secondary = switch_is_primary(switch_name)

# sw-leaf-bmc ==> sw-spine
Expand Down
30 changes: 30 additions & 0 deletions canu/inventory/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,31 @@ def get_aruba_vars(datasource=None, hostname=None):
]


def get_dellos10_vars(datasource=None, hostname=None):
"""Get extra variables needed by Aruba ansible modules.

Args:
datasource : Data from the datasource.
hostname : The hostname to query.

Returns:
The ansible user defined in the datasource.
"""
# aruba needs extra variables for ansible community module
if "dell" in datasource["options"]["hosts"][hostname]["groups"]:
# arubanetworks.aoscx.aoscx for API
# network_cli for CLI/SSH
# httpapi legacy
ansible_network_os = "dellemc.os10.os10"
ansible_connection = "network_cli"

return [
{"ansible_network_os": ansible_network_os},
{"ansible_connection": ansible_connection},
{"authorize": True},
]


def ansible_host(datasource=None, hostname=None):
"""Print a specific host inventory in JSON.

Expand Down Expand Up @@ -410,6 +435,11 @@ def ansible_hostvars(datasource=None, hostname=None):
for var in aruba_vars:
ansible_inventory.update(var)

if "dell" in ansible_inventory["groups"]:
dell_vars = get_dellos10_vars(datasource, hostname)
for var in dell_vars:
ansible_inventory.update(var)

return ansible_inventory


Expand Down
29 changes: 29 additions & 0 deletions canu/inventory/plays/dell-os10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- hosts: sw-leaf-bmc-001
collections:
- dellemc.os10
gather_facts: true
vars:
# This should be a template but for now, pass is an extra var path to whatever config is needed
# pass in the folder containing the switch configs or be in the same directory
config_folder: ""
switch_config: "{{ config_folder }}/{{ inventory_hostname }}.cfg"

tasks:
- name: upload config
os10_config:
src: "{{ switch_config }}"
match: line
update: merge
replace: line
save: true
vars:
ansible_command_timeout: 600

# - name: upload config
# os10_config:
# src: "{{ switch_config }}"
# match: line
# update: check
# vars:
# ansible_command_timeout: 600
15 changes: 15 additions & 0 deletions canu/inventory/plays/mellanox-onyx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- hosts: sw-spine-001
collections:
- mellanox.onyx
vars:
# This should be a template but for now, pass is an extra var path to whatever config is needed
# pass in the folder containing the switch configs or be in the same directory
config_folder: ""
switch_config: "{{ config_folder }}/{{ inventory_hostname }}.cfg"

tasks:
- name: command
onyx_command:
username: admin
password: admin
commands: show version
Loading