Hello Meraki community 🙂, This year, I wrote an article about Ansible and Meraki on Cisco Blog, to illustrate how a concrete usecase could be addressed with Ansible, https://gblogs.cisco.com/fr/reseaux/jai-teste-ansible-pour-meraki/, Here is the translation in English for those who are interested : I tested... Ansible for Meraki! Meraki, Cisco's cloud-native solution, has its own Ansible collection, For a solution that can be managed in GUI mode via the Meraki Dashboard ("at scale"), you might well wonder what the point of this collection is. Let's take a concrete example! Let's take the example of a network administrator who needs to update the trunk ports of his network, to add freshly created VLANs: "Easy! "With Meraki's Virtual Stacking (not to be confused with StackWise Virtual under IOS-XE), all we have to do is select all the ports we want to update, edit them, and add the new VLANs to the list of authorized VLANs: It's as simple as that, if the whole LAN is in Meraki: But even if our network administrator has chosen Meraki as the standard (convinced of the solution's simplicity and scalability), making his network homogeneous is not always easy (recovery of existing hardware, company takeovers, decentralized technological decisions, etc.). His environment will look more like this: Same task, but a much more complex deployment... It's out of the question for our network administrator to go round each vendor's management console, or worse still, to update the configuration of each piece of equipment one by one, using CLI/GUI. The operation would be too laborious, risky and costly. This is where the Ansible collection comes into its own. Let's install Ansible for Meraki We need to install Ansible, but not only that. In a network context, Ansible often uses SSH to interact with devices (as is the case in this article). However, Ansible can also use other means of transport, such as REST APIs. This is how Ansible will drive the Meraki dashboard. So let's install the elements needed to use Meraki's REST APIs via Ansible: # Installing Ansible
xvalette@lab cisco-meraki-ansible % python3 -m pip install --user ansible
# Install Meraki SDK
xvalette@lab cisco-meraki-ansible % python3 -m pip install --user meraki
# Command for Mac OS users
xvalette@lab cisco-meraki-ansible % export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES Let's create a playbook We want to update the VLANs allowed on the trunk ports, Inspecting the collection documentation, we find the devices_switch_ports module to meet our needs, From the documentation and examples, we arrive at the following playbook: - hosts: localhost
vars:
network_id: L_00000000000000 | to be replaced
serial_number: XXXX-XXXX-XXXX | to be replaced
meraki_api_key: clé API | to be replaced
gather_facts: false
tasks:
- name: Update Allowed VLANs on trunk ports
cisco.meraki.devices_switch_ports:
meraki_api_key: "{{meraki_api_key}}"
state: present
serial: "{{serial_number}}"
portId: 4
allowedVlans: 42-44,100-200 All set! We can launch our playbook. No need for inventory, since Ansible will drive the Meraki dashboard, not the equipment. xvalette@lab cisco-meraki-ansible % ansible-playbook playbooks/updateAllowedVlanTrunk.yml In conclusion In previous articles, we have used : Ansible with Catalyst Center Ansible with IOS-XE devices (or third-party via the respective collections) Today we've just seen how to use Ansible with Meraki, In this way, managing a heterogeneous network becomes less laborious, less risky and less costly for our network administrator: References Ansible for Meraki collection: https://docs.ansible.com/ansible/latest/collections/cisco/meraki/index.html Playbook examples from the Ansible collection: https://github.com/meraki/dashboard-api-ansible/tree/main/playbooks Florian GIRARD's article on Ansible for Catalyst Center: https://gblogs.cisco.com/fr/reseaux/accelerer-vos-operations-avec-ansible-et-cisco-dna-center/ Article on Ansible for IOS-XE: https://gblogs.cisco.com/fr/reseaux/manager-vos-equipements-cisco-avec-ansible/
... View more