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 和 update 设置为 no,否则此参数是必需的 | |
| 要使用的 hg 可执行文件的路径。如果未提供,将使用解析二进制路径的正常机制。 | |
| 丢弃未提交的更改。运行  选择 
 | |
| 删除未跟踪的文件。运行  选择 
 | |
| 仓库地址。 | |
| hg 命令中等效的  | |
| 如果  选择 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:无 | 可以在  | |
| 支持:无 | 当处于 diff 模式时,将返回有关已更改内容(或可能需要在  | 
说明
注意
- 此模块不支持推送功能。请参阅 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
