Add a Syslog Server to all your Meraki MX devices using ANSIBLE.
List all the MERAKI devices on your organization.
(Or the ones you want to affect with this playbook)
One easy way to do that is to use POSTMAN. We can take advantage of the MERAKI collection available. For this case we will use the List the Netowrks in an Organitation API call
GET {{baseUrl}}/organizations/:organizationId/networks
This API call will return the list of all networks (in our cas all of them are MX devices). We can use that information to feed an invetory file on ANSIBLE or we can use the directly as I did on this case.
ANSIBLE PLAYBOOK
For this case I will be using the Meraki Syslog module. You see the documentation on this link.
This is the actual YAML file that I used to change the SYSLOG servers on all my Merakidevices.
---
- name: Query syslog configurations on network named MyNet in the YourOrg organization
connection: local
hosts: localhost
#gather_facts: false
tasks:
- name: Syslog
meraki_syslog:
auth_key: xxxxxxx
state: present
org_id: 1234
net_id: "{{ item }}"
servers:
- host: 192.168.1.50
port: 514
roles:
- Flows
- URLs
- Security Events
- Appliance event log
output_level: debug
register: syslog_servers_1
loop:
- L_123
- L_456
- L_0931
- L_03435
- L_43252
- L_2345
- L_1314
- L_134245
- L_123255
- L_1456
- L_12343256
- L_12345
- L_431245
- L_13245
- L_12325
- L_347645787
- L_2354236
- L_02375
- name: Debug
debug:
msg: "{{ syslog_servers_1 }}"
delegate_to: localhost
To run the playbook use the folowwing command:
ansible-playbook Meraki\_filename.yaml
This is probably the simplest way to use Ansiblle to do this. A cleaneer version would be to use an inventory file. This was actually my first Ansible Palybook so I will be making improvements and posting them here.
Thank you for reading