第 2 章 更新 playbook 的 set_stats 字段来支持与 Automation Services Catalog 集成
您可以更新 playbook,将信息传递给 Automation Services Catalog,并在您的订购进程工作流中的产品中支持可替换变量。
2.1. 编写为 Automation Services Catalog 返回值的 playbook
您可以编写 playbook,以将值返回到 Automation Services Catalog。带有 expose_to_cloud_redhat_com_ 前缀的 set_stats 参数会将值返回到 Automation Services Catalog。然后,您可以使用可替换变量通过额外的 playbook 传递这些值。
使用以下的 playbook 示例来了解有关 set_stats 值的信息,并将值返回到 Automation Services Catalog,并在您的订购进程的后续 playbook 中使用它们作为可替换的值。
before order playbook 示例
此 before order playbook 返回给 Automation Services Catalog set_stats 值,用于热门颜色:
# This playbook prints a simple debug message and set_stats
- name: Echo Hello, world!
hosts: localhost
gather_facts: yes
tasks:
- debug:
msg: "Hello, world!"
- set_stats:
data:
expose_to_cloud_redhat_com_favorite_color: "orange"product order playbook 示例
该 playbook 将可替换值传递给 Automation Services Catalog 作为工件值。
# This playbook prints a simple debug message with given information
- name: Echo Hello, world!
hosts: localhost
gather_facts: yes
tasks:
- debug:
msg: "Hello, {{favorite_color}} world!"
- set_stats:
data:
expose_to_cloud_redhat_com_after_data: "{{favorite_color}}"after order playbook 示例
以下的 after order playbook 包含了由 product playbook 传递的工件 after_data 值。
# This playbook prints a simple debug message with given information
- name: Echo Hello, world!
hosts: localhost
gather_facts: yes
tasks:
- debug:
msg: "{{after_data}}"
~