Q: ***"Is it possible to share variables across instances?"***

A: Yes. The dictionary *hostvars* keeps the variables. *hostvars* lets you access variables for another host, including facts that have been gathered about that host. You can access host variables at any point in a playbook. For example,

```yaml
  {{ hostvars['test.example.com']['ansible_facts']['distribution'] }}
```

See:

* [Information about Ansible: magic variables](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html#information-about-ansible-magic-variables)

* [Scoping variables](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#scoping-variables)

* [Cache plugins](https://docs.ansible.com/ansible/latest/plugins/cache.html#cache-plugins)

<hr>

With “Fact Caching” disabled, to share information among Ansible playbooks, it's possible to store all *hostvars* in a file. For example with this template

      $ cat my_hostvars.json.j2
      my_hostvars_all:
      {% for my_host in ansible_play_hosts_all %}
        {{ my_host }}:
          {{ hostvars[my_host]|to_nice_json }}
      {% endfor %}

the playbook below stores *hostvars* of all hosts in the dictionary
*my_hostvars_all* and put it into the file
*{{ inventory_dir }}/my_hostvars.json* at localhost(master)

      - hosts: test_jails
        tasks:
          - set_fact:
              test_var: "test_var_in_{{ inventory_hostname }}"
          - template:
              src: my_hostvars.json.j2
              dest: "{{ inventory_dir }}/my_hostvars.json"
            delegate_to: localhost
            run_once: true

The dictionary can be included in the next playbook. For example the playbook below

      - hosts: test_jails
        tasks:
          - include_vars: my_hostvars.json
          - set_fact:
              my_hostvars: "{{ my_hostvars_all[inventory_hostname] }}"
          - debug:
              var: my_hostvars.test_var

gives

      ok: [test_01] => {
          "my_hostvars.test_var": "test_var_in_test_01"
      }
      ok: [test_02] => {
          "my_hostvars.test_var": "test_var_in_test_02"
      }
      ok: [test_03] => {
          "my_hostvars.test_var": "test_var_in_test_03"
      }