cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2308
Views
0
Helpful
4
Replies

Ansible on Cisco MDS switches

Hello, there's anybody here with experience on automate cisco mds configuration? Ansible official module doesn't cover so much this kind of device. 

I'm searching automation like:

 

- disable or enable fc interfaces

- change vsan of of interfaces

- activate a zoneset

 

Thanks 

4 Replies 4

Seb Rupik
VIP Alumni
VIP Alumni

Hi there,

I don't have any experience with MDS switches and ansible, but what you are after can be achieved with ios_command, registering variables and when statements.

Register variables to record state, and then create tasks which execute based on comparing the actual state to a desired state/ variable, eg:

 

tasks:
- name: Some IOS stuff
block: - name: Check IOS command
ios_command: commands: "<some_ios_command>" vars: ansible_command_timeout: 60 register: ios_cmd_result
- name: Copy IOS onto flash ios_command: commands: - command: "<another_ios_command_based_on_conditional>"
prompt: "]?" answer: "\r" - "<another_command_based_on_the_same_condition>" vars: ansible_command_timeout: 600 when: condition != ios_cmd_result.stdout[0].split(' = ')[1]

 

In the above example the value of 'condition' can either be pulled from the inventory or via var_prompt sequence at the beginning of your play.

 

cheers,

Seb.

 

 

First thanks for the reply. Do you think the IOS_COMMAND open one session for every command or it act smart?

 

I'm thinking about something like the example below where the second command is valid only if the first is done.

 

ios_command:

commands:

- configure t

- interface fc 5/9

- ...something else....

- end

 

From a simple test seems ok but I don't have a dev/test environment and I don't want to generate any lock in the fabric.

playbook tasks will fail abruptly and once ansible receive a response it wasn't expecting it will halt the task and remove the device from the remainder of the play.

 

You can also look at error handling techniques to keep the play going:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html

 

cheers,

Seb.

subharad
Cisco Employee
Cisco Employee

I hope you have looked into this

https://github.com/Cisco-SAN/MDS_Ansible_Modules

 

Thanks,

Suhas

Review Cisco Networking for a $25 gift card