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.
  • Set an env property with key FOO value bar.

Fig. Set environment variable on a target node

In the post_configure_source of the AnsibleTasks component, we can write a script to access the enrionment variables of the AnsibleRole component:

- debug:
msg:
- "Hello I am an ansible task {{ SOURCE_NODE }} executes on {{ SOURCE_HOST }} to connect with {{ TARGET_NODE }} at {{ TARGET_IP }}."
- "I can access the env variable FOO on the target node {{ TARGET_NODE }} with value: {{ TARGET_FOO }}."

Expected result

Fig. Deployment logs of post_configure_source