08-30-2019 02:12 AM
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
08-30-2019 04:59 AM
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.
08-30-2019 06:07 AM
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.
08-30-2019 06:56 AM
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.
05-14-2020 10:47 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide