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.

../_images/8-Ansible-tasks-relation.png

Figure 1. 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.

../_images/8-Ansible-tasks-relation-env.png

Figure 2. 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

../_images/8-Ansible-tasks-post-configure.png

Figure 3. Deployment logs of post_configure_source