How to configure a connection between two ansible components

Examples

  • Design the topology as belows.
  • Connect the AnsibleTasks and the Bash component to the AnsibleRole component.

Fig. Ansible tasks relationship

tip

You can find this example under New Application / Topology Template / Ansible-Bash-Connector.

  • Select AnsibleRole.
  • Set the port property to 27017.
  • Add an entry in the env property with key FOO value bar.

Fig. Set environment variable on a target node

In the post_configure_source of AnsibleTasks, we can access the enrionment variables of the AnsibleRole component:

- debug:
msg:
- "{{ TARGET_NODE }} is running on {{ TARGET_HOST }} with ip {{ TARGET_IP }} on port {{ TARGET_PORT }}"
- "{{ TARGET_NODE }} has environment variable FOO with value: {{ TARGET_FOO }}"

Expected result

AnsibleRole is running on Compute_2 with ip 10.0.0.4 on port 27017
AnsibleRole has environment variable FOO with value: bar