# Issue passing Set\_Facts variable from one playbook to another

**URL:** <https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582>\
**Category:** Get Help\
**Tags:** facts, meraki\
**Created:** [September 30, 2025, 8:03am UTC](https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582 "2025-09-30T08:03:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![baily](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@baily](https://forum.ansible.com/u/baily)\
**Post date:** [September 30, 2025, 8:03am UTC](https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582/1 "2025-09-30T08:03:56Z")

</div>

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:

* * *

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

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [September 30, 2025, 1:00pm UTC](https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582/2 "2025-09-30T13:00:46Z")

</div>

`set_fact` does not create an `ansible_fact` but a host scoped variable, which has higher precedence than facts and is accessible both directly `networkId: “{{ FACT_Network_ID }}”` or via `hostvars`. The action has a confusing name, but we did modify it to add an option, `cacheable`, that when set to `True` , will in addition to the previous var, also create an actual fact.

---

<div class="post-metadata">

**Author:** ![baily](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@baily](https://forum.ansible.com/u/baily)\
**Post date:** [September 30, 2025, 3:31pm UTC](https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582/3 "2025-09-30T15:31:55Z")

</div>

Thanks for the update.

I’ve tried this, but still doesn’t seem to work. Not sure if its something in the dictionary for Meraki when setting the networkId: and it not liking it being a variable as the string.

Is there a way to debug what the module and see what it has built for the URL during the playbook running? Apologies i know this is very Meraki specific, but also part Ansible-y as well. 🙂

Cheers  
Neil

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [September 30, 2025, 3:38pm UTC](https://forum.ansible.com/t/issue-passing-set-facts-variable-from-one-playbook-to-another/44582/4 "2025-09-30T15:38:09Z")

</div>

If using `-vvv` you should see extended results for the module, but for `debug` you could just do:

```auto
msg: “{{ result }}”

```

to see the structure, just be aware that data types get messy with the `debug` action, use `|type_debug` to ensure things are what you expect for specific keys.
