第 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}}"
~
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.