community.general.git_config_info 模块 – 读取 git 配置
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅要求了解详细信息。
要在 playbook 中使用它,请指定:community.general.git_config_info。
community.general 8.1.0 中的新增功能
概要
- community.general.git_config_info 模块通过调用 - git config读取 git 配置。
要求
执行此模块的主机需要满足以下要求。
- git 
参数
| 参数 | 注释 | 
|---|---|
| 要读取的设置的名称。 如果未提供,则所有设置都将作为  | |
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持: 完全 此操作不会修改状态。 | 可以在  | |
| 支持: 不适用 此操作不会修改状态。 | 当处于差异模式时,将返回有关已更改的内容(或在  | 
示例
- name: Read a system wide config
  community.general.git_config_info:
    name: core.editor
  register: result
- name: Show value of core.editor
  ansible.builtin.debug:
    msg: "{{ result.config_value | default('(not set)', true) }}"
- name: Read a global config from ~/.gitconfig
  community.general.git_config_info:
    name: alias.remotev
    scope: global
- name: Read a project specific config
  community.general.git_config_info:
    name: color.ui
    scope: local
    path: /etc
- name: Read all global values
  community.general.git_config_info:
    scope: global
- name: Read all system wide values
  community.general.git_config_info:
- name: Read all values of a specific file
  community.general.git_config_info:
    scope: file
    path: /etc/gitconfig
返回值
常见的返回值记录在这里,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
