community.general.bitbucket_pipeline_known_host 模块 – 管理 Bitbucket pipeline 已知主机

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,有关详细信息,请参阅要求

要在 playbook 中使用它,请指定:community.general.bitbucket_pipeline_known_host

概要

  • 管理 “SSH 密钥” 菜单下的 Bitbucket pipeline 已知主机。

  • 主机指纹将自动检索,但如果出现错误,可以使用 key 字段手动指定它。

要求

在执行此模块的主机上需要以下要求。

  • paramiko

参数

参数

注释

client_id

字符串

OAuth 消费者密钥。

如果未设置,将使用环境变量 BITBUCKET_CLIENT_ID

client_secret

字符串

OAuth 消费者密钥。

如果未设置,将使用环境变量 BITBUCKET_CLIENT_SECRET

key

字符串

公钥。

name

字符串 / 必需

已知主机的 FQDN。

password

字符串

在 community.general 4.0.0 中添加

应用密码。

如果未设置,将使用环境变量 BITBUCKET_PASSWORD

repository

字符串 / 必需

仓库名称。

state

字符串 / 必需

指示记录的所需状态。

选择

  • "absent"

  • "present"

user

别名: username

字符串

在 community.general 4.0.0 中添加

用户名。

如果未设置,将使用环境变量 BITBUCKET_USERNAME

username 自 community.general 6.0.0 起是 user 的别名。在此之前,它是 workspace 的别名。

workspace

字符串 / 必需

仓库所有者。

注意: username 曾经是此选项的别名。自 community.general 6.0.0 起,它是 user 的别名。

属性

属性

支持

描述

check_mode

支持: 完全

可以在 check_mode 中运行,并返回已更改的状态预测,而无需修改目标。

diff_mode

支持:

在 diff 模式下,将返回有关已更改的内容(或可能需要在 check_mode 中更改的内容)的详细信息。

说明

注意

  • 支持检查模式。

  • Bitbucket OAuth 消费者密钥和密钥可以从 Bitbucket 个人资料 -> 设置 -> 访问管理 -> OAuth 获取。

  • Bitbucket 应用密码可以在 Bitbucket 个人资料 -> 个人设置 -> 应用密码 中创建。

  • 如果同时传递了 OAuth 和基本身份验证凭据,则 OAuth 凭据优先。

示例

- name: Create known hosts from the list
  community.general.bitbucket_pipeline_known_host:
    repository: 'bitbucket-repo'
    workspace: bitbucket_workspace
    name: '{{ item }}'
    state: present
  with_items:
    - bitbucket.org
    - example.com

- name: Remove known host
  community.general.bitbucket_pipeline_known_host:
    repository: bitbucket-repo
    workspace: bitbucket_workspace
    name: bitbucket.org
    state: absent

- name: Specify public key file
  community.general.bitbucket_pipeline_known_host:
    repository: bitbucket-repo
    workspace: bitbucket_workspace
    name: bitbucket.org
    key: '{{lookup("file", "bitbucket.pub") }}'
    state: absent

作者

  • Evgeniy Krysanov (@catcombo)