Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 4. Enabling substitutable variables across the order process workflow
You can substitute variables across products used in your order process workflow. Implementing substitutable variables requires creating or editing the job template survey on Ansible Tower and enabling substitution on surveys attached to products on Automation Services Catalog.
Substitution format and requirements
Substitutable values are expressed in the format {{substitution_express}} with no spaces allowed between the braces and the expression. Refer to Substitute variables for information on each variable you can use for substitution.
4.1. Implementing substitutable variables in your order process workflow Link kopierenLink in die Zwischenablage kopiert!
In this section we will demonstrate how to align data you expose to Automation Services Catalog in your playbooks with substitutable variables, using the playbooks examples provided earlier in this guide.
4.1.1. Creating a before order process to pass a value to the product order. Link kopierenLink in die Zwischenablage kopiert!
Example playbook before_order.yml for before order process
This playbook returns to Automation Services Catalog a playbook artifact favorite_color that has the value orange. You do not need to make a job template survey on Ansible Tower since no user input is required. Instead, you can pass favorite_color to the product playbook by editing the survey on Automation Services Catalog set to the before order process product.
4.1.2. Configuring the product order to use a substituted variable Link kopierenLink in die Zwischenablage kopiert!
This example product playbook accepts a substituted variable for {{favorite_color}} and passes back to Automation Services Catalog the artifact 'after_data'.
Example playbook product_order.yml
Create a job template on Ansible Tower for the 'product_order.yml' playbook that sets favorite_color as the *Answer Variable Name.
Create a survey for the product_order.yml job template that includes:
- Enter What is your favorite color? in the Prompt field.
- Enter favorite_color in the Answer Variable Name field.
- Click .
Enable the product order survey on Automation Services Catalog to use the 'favorite_color' value passed from before_order.yml.
In the survey attached to your product order:
Update fields with the following values:
- Name: favorite_color
- Initial Value: {{before.before_order.artifacts.favorite_color}}
- Label: What is your favorite color?
- Placeholder: {{before.before_order.artifacts.favorite_color}}
- Toggle the Disabled switch to the active position.
- Toggle the Substitution switch to the active position.
You have now configured the product order to use the favorite_color artifact from the before_order.yml playbook as a substituted variable.
4.1.3. Configuring the after order product to accept after_data artifact values from the product order Link kopierenLink in die Zwischenablage kopiert!
Use surveys to pass the 'product_order.yml' artifact after_data to after_order.yml using substitutable variables.
Example playbook after_order.yml for after order product
Create a job template on Ansible Tower for the 'after_order.yml' playbook that sets after_data as the *Answer Variable Name.
In the survey attached to your after_order.yml job template:
- Type "Enter your after data" in the Prompt field.
- Enter after_data in the Answer Variable Name field.
- Click .
Enable the after order survey on Automation Services Catalog to use the 'after_data' value passed from after_order.yml.
In the survey attached to your after order:
Update fields with the following values:
- Name: after_data
- Initial Value: {{product.artifacts.after_data}}
- Label: "Enter your after data"
- Placeholder: {{product.artifacts.after_data}}
- Toggle the Disabled switch to the active position.
- Toggle the Substitution switch to the active position.
The playbook will display the value passed for after data when the job template is run.
4.2. Substitute variables reference Link kopierenLink in die Zwischenablage kopiert!
A substitution has the format of {{substitution_express}}. Do not use a space between the curly brackets and the expression.
Substituted values are set in Ansible Tower jobs template surveys. Substituted variables pass from one product in the order process to another, depending on your configuration.
See Surveys in the Ansible Tower User Guide for more information on updating job template surveys.
Follow the table below when including substitutable variables in your surveys.
| Object | Expression | Notes |
|---|---|---|
| Order |
| order.created_at` is the date and time when the order started.
Date format: Example: {{order.approval.reason}} |
| Before order |
| No quotes are needed for the order_process_name if it contains space. Example: {{before.Sample Order.artifacts.ticket_number}} |
| Product |
| Example: {{product.artifacts.after_data}} |
| After order |
| No quotes are needed for the order_process_name if it contains space. Example: {{after.SampleOrder.status}} |