Hi,
So, i’m not sure if this is the right way to complete this task and not really a Meraki specific thing, but through i would ask the question.
So I’m using the below code to grab the Network ID for a specific network
get_network.yaml
- name: Get_Networks
hosts: localhost
gather_facts: false
vars:
network_name_query: “meraki_response[?name==‘{{ Network_Name }}’].id”
vars_prompt:-
name: Network_Name
prompt: Please Enter the Network Name
private: false
tasks: -
name: Get Specific Org Network
cisco.meraki.networks_info:
organizationId:
register: result -
name: Set Network ID Fact
set_fact:
FACT_Network_ID: “{{ result | json_query(network_name_query) }}”
cacheable: true
-
When running this, It sets the NetworK ID of the name you enter in the Prompt as a fact for use in another playbook.
get_l3_fw_rules.yaml
-
name: Get_L3_Firewall_Rules
hosts: localhost
gather_facts: false
tasks:-
name: Get L3 Firewall Rules
cisco.meraki.networks_appliance_firewall_l3_firewall_rules_info:
networkId: “{{ ansible_facts[‘FACT_Network_ID’] }}”
register: result -
name: Show All Firewall Rules
ansible.builtin.debug:
msg: “{{ result.meraki_response.rules }}”
-
If I run the two playbooks together (as below), I can see that the fact is being passed through to the next playbook, but it doesn’t seem to be presented to the meraki collection properly. I’ve tested with just putting a network ID in manually and it returns data, so it has to be something with my code.
get_rules_for specific_network.yaml
- name: Get Network ID
import_playbook: Get_Network.yaml - name: Get L3 Firewall Rules
import_playbook: Get_L3_FW_Rules.yaml
Apologies if this is in the wrong forum, but just wondered if someone had come across something similar at all?
Cheers
Neil