community.general.git_config_info module – Read git configuration

Note

This module is part of the community.general collection (version 9.4.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.git_config_info.

New in community.general 8.1.0

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • git

Parameters

Parameter

Comments

name

string

The name of the setting to read.

If not provided, all settings will be returned as config_values.

path

path

Path to a git repository or file for reading values from a specific repo.

If scope is local, this must point to a repository to read from.

If scope is file, this must point to specific git config file to read from.

Otherwise path is ignored if set.

scope

string

Specify which scope to read values from.

If set to global, the global git config is used. path is ignored.

If set to system, the system git config is used. path is ignored.

If set to local, path must be set to the repo to read from.

If set to file, path must be set to the config file to read from.

Choices:

  • "global"

  • "system" ← (default)

  • "local"

  • "file"

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- 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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

config_value

string

When name is set, a string containing the value of the setting in name. If name is not set, empty. If a config key such as push.pushoption has more then one entry, just the first one is returned here.

Returned: success if name is set

Sample: "vim"

config_values

dictionary

This is a dictionary mapping a git configuration setting to a list of its values.

When name is not set, all configuration settings are returned here.

When name is set, only the setting specified in name is returned here. If that setting is not set, the key will still be present, and its value will be an empty list.

Returned: success

Sample: {"alias.remotev": ["remote -v"], "color.ui": ["auto"], "core.editor": ["vim"], "push.pushoption": ["merge_request.create", "merge_request.draft"]}

Authors

  • Guenther Grill (@guenhter)