In the previous example, we used a python script to implement a software component. In this example, we use an ansible playbook to create a mongodb.
Step 1. Import TOSCA types
Step 2. Implement the interfaces
We implement the
create interfaces by providing an ansible script (e.g.,
- Use the keyword
HOSTto get information of the hosted compute node.
- Use the function
get_attributeto get the runtime attribute
private_addressof the hosted compute node. The compute node also has the following attributes available at runtime that you can use by default:
Step 3a. Implement an ansible playbook for the interface
In the following example, the ansible script (e.g.,
mongodb_install.yaml) imports a third party ansible role
undergreen.ansible-role-mongodb and uses it to install mongodb:
In the same folder of the ansible script, we have an ansible role available at
The orchestration engine will apply the ansible playbook
mongodb_install.yaml on the remote compute node, which in turn imports the ansible role
undergreen.ansible-role-mongodb to create the mongodb.
Step 3b. (alternative) Zip the whole playbook folder
Define ansible roles
- In this scenario, we create a folder (e.g.,
playbook) contaning more than one
- Each roles has an entry script (e.g., the entry script
create.ymlimports the role
Zip the playbook folder
Zip the content of the
playbook folder into the file
Implement the interface
create interfaces, we specify the zip file as an implementation and set the
PLAYBOOK_ENTRY to the entry script
The orchestration engine will apply the entry script
create.yml, which in turn imports the role
create (in the zip file) to create the component on the remote compute node.