community.general.hg 模块 – 管理 Mercurial (hg) 仓库

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.general

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

概要

  • 管理 Mercurial (hg) 仓库。支持 SSH、HTTP/S 和本地地址。

参数

参数

注释

clone

boolean

如果 false,如果本地不存在仓库,则不克隆它。

选择

  • false

  • true ←(默认)

dest

path

仓库应克隆到的绝对路径。除非 clone 和 update 设置为 no,否则此参数是必需的

executable

string

要使用的 hg 可执行文件的路径。如果未提供,将使用解析二进制路径的正常机制。

force

boolean

丢弃未提交的更改。运行 hg update -C

选择

  • false ←(默认)

  • true

purge

boolean

删除未跟踪的文件。运行 hg purge

选择

  • false ←(默认)

  • true

repo

别名:name

string / 必填

仓库地址。

revision

别名:version

string

hg 命令中等效的 -r 选项,可以是变更集、修订号、分支名称甚至是标签。

update

boolean

如果 false,则不从原始仓库检索新修订

选择

  • false

  • true ←(默认)

属性

属性

支持

描述

check_mode

支持:

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

diff_mode

支持:

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

说明

注意

  • 此模块不支持推送功能。请参阅 https://github.com/ansible/ansible/issues/31156

  • 如果任务似乎挂起,请首先验证远程主机是否在 known_hosts 中。SSH 会提示用户授权与远程主机的首次联系。要避免此提示,一种解决方案是在调用 hg 模块之前,使用以下命令将远程主机公钥添加到 /etc/ssh/ssh_known_hosts 中:ssh-keyscan remote_host.com >> /etc/ssh/ssh_known_hosts。

  • 截至 2018 年 12 月 1 日,Bitbucket 已停止支持 TLSv1 和 TLSv1.1 连接。因此,如果底层系统仍使用低于 2.7.9 的 Python 版本,您将遇到签出 bitbucket 仓库的问题。请参阅 https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01

示例

- name: Ensure the current working copy is inside the stable branch and deletes untracked files if any.
  community.general.hg:
    repo: https://bitbucket.org/user/repo1
    dest: /home/user/repo1
    revision: stable
    purge: true

- name: Get information about the repository whether or not it has already been cloned locally.
  community.general.hg:
    repo: git://bitbucket.org/user/repo
    dest: /srv/checkout
    clone: false
    update: false

作者

  • Yeukhon Wong (@yeukhon)