如何将 GCP 项目载入 Ansible Tower 以获取其中的 运行 剧本?

How to onboard a GCP project into Ansible Tower for running playbooks in it?

我已经成功使用 Ansible 引擎配置 GCP 资源,使用带有 gcp 模块的 ansible 剧本。

现在我正在尝试使用 Ansible Tower 这样做,我对 Ansible tower 完全陌生。

我无法理解如何在 Ansible Tower 中为 GCP 创建清单。在塔中,我们可以提供我们的 yaml 运行 所在的主机。我将如何确定 GCP 的主机 IP?用例:

  1. 我想提供一个 GCP 计算引擎。
  2. 我想提供一个 Bigquery 数据集和表。

在这两种情况下,我在 ansible tower 中的主机应该是什么?有人可以帮忙吗?

创建一个 Credential 以连接到 GCP,如下所示

- Name: GCP Credentials
- Description: GCP Credentials
- Organization: Default
- Credential Type: Google Compute Engine
- Service Account Email Address: *This will be filled when upload json file*
- Project: *This will be filled when upload json file*
- Service Account Json File: yourfile.json
- RSA Private Key: *This will be filled when upload json file*

如下创建Inventory并保存

- Name: GCP Inventory
- Description: GCP Inventory
- Organization: Default

然后,在 InventorySources 选项卡中单击带有以下信息的 Create a new source 按钮:

- Name: GCP Source
- Description: GCP Source
- Source: Google Compute Engine
- Credential: GCP Credentials

InventorySources 选项卡中,单击新源的“开始同步过程”选项。这将更新您的 Hosts。有了这一切,您只需要在 localhost 上使用使用此凭据和库存的模板执行您的剧本。