Fact & General Modules

To gather facts about Brokers / Solace Cloud Services and Solace Cloud accounts specialized modules exist.

Example Usage

Call the module solace_gather_facts – gather broker facts at the beginning of your playbook, so all broker facts are available for the rest of the playbook.

solace_gather_facts places the facts gathered in ansible_facts.solace[inventory_hostname] as a JSON. You can save it to file, print it out and find where the fact you are interested in is located. Using jinja2, you can dynamically retrieve facts based on certain settings.

Here is a gotcha:

When using modules that require access to multiple brokers at the same time, for example solace_bridge_remote_vpn – bridge remote vpn, we need to ensure that solace_gather_facts is executed for each host in the inventory BEFORE the solace_bridge_remote_vpn is called.

The solution is to tell Ansible that by setting forks 1 parameter for ansible-playbook:

ansible-playbook \
        --forks 1 \
        -i inventory-with-two-brokers.yml \
        my.playbook.yml

This tells Ansible to execute each task for all hosts BEFORE moving onto the next task.

An additional convenience module allows you to retrieve certain facts from Ansible’s hostvars: solace_get_facts – get facts for a broker/vpn.

It implements a few functions to directly collect a set of facts without the need to understand the JSON structure. For example, to get the connection details of a newly created Solace Cloud service use the following in your playbook:

- name: "Gather Solace Facts"
  solace_gather_facts:

- name: get_vpnClientConnectionDetails
  solace_get_facts:
    hostvars: "{{ hostvars }}" # always use this setting
    hostvars_inventory_hostname: "{{ inventory_hostname }}"
    msg_vpn: "{{ vpn }}"
    get_functions:
      - get_vpnClientConnectionDetails
  register: result

- set_fact:
    client_connection_details: "{{ result.facts.vpnClientConnectionDetails }}"

- name: "Save 'client_connection_details' to File"
  copy:
    content: "{{ client_connection_details | to_nice_json }}"
    dest: "./tmp/generated/{{ inventory_hostname }}.client_connection_details.json"

Module Reference