community.general.git_config_info (8.5.0) — module

Read git configuration

| "added in version" 8.1.0 of community.general"

Authors: Guenther Grill (@guenhter)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

The M(community.general.git_config_info) module reads the git configuration by invoking C(git config).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read a system wide config
  community.general.git_config_info:
    name: core.editor
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Show value of core.editor
  ansible.builtin.debug:
    msg: "{{ result.config_value | default('(not set)', true) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read a global config from ~/.gitconfig
  community.general.git_config_info:
    name: alias.remotev
    scope: global
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read a project specific config
  community.general.git_config_info:
    name: color.ui
    scope: local
    path: /etc
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read all global values
  community.general.git_config_info:
    scope: global
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read all system wide values
  community.general.git_config_info:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read all values of a specific file
  community.general.git_config_info:
    scope: file
    path: /etc/gitconfig

Inputs

    
name:
    description:
    - The name of the setting to read.
    - If not provided, all settings will be returned as RV(config_values).
    type: str

path:
    description:
    - Path to a git repository or file for reading values from a specific repo.
    - If O(scope) is V(local), this must point to a repository to read from.
    - If O(scope) is V(file), this must point to specific git config file to read from.
    - Otherwise O(path) is ignored if set.
    type: path

scope:
    choices:
    - global
    - system
    - local
    - file
    default: system
    description:
    - Specify which scope to read values from.
    - If set to V(global), the global git config is used. O(path) is ignored.
    - If set to V(system), the system git config is used. O(path) is ignored.
    - If set to V(local), O(path) must be set to the repo to read from.
    - If set to V(file), O(path) must be set to the config file to read from.
    type: str

Outputs

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

    '
  returned: success if O(name) is set
  sample: vim
  type: str
config_values:
  description:
  - This is a dictionary mapping a git configuration setting to a list of its values.
  - When O(name) is not set, all configuration settings are returned here.
  - When O(name) is set, only the setting specified in O(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
  type: dict