How to configure a connection between two ansible components¶
You can connect AnsibleTask, AnsibleRole, AnsibleGalaxy, and Bash component with each other.
The operation post_configure_source and add_source are executed in the same order as described in Section How to configure a connection between two Bash components.
The environment variables of the SOURCE node and TARGET node are available in the operations as described in Environment variables for Bash script.
Examples¶
Design the topology as belows.
Connect the AnsibleTasks and the Bash component to the AnsibleRole component.
Tip
You can find this example under New Application / Topology Template / Ansible-Bash-Connector.
Select AnsibleRole.
Set the
port
property to27017
.Set an
env
property with keyFOO
valuebar
.
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 }}."