community.general.git_config – Read and write git configuration¶
Note
This plugin is part of the community.general collection (version 1.3.6).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.git_config
.
Synopsis¶
The
git_config
module changes git configuration by invoking ‘git config’. This is needed if you don’t want to use ansible.builtin.template for the entire git config file (e.g. because you need to change justuser.email
in /etc/.git/config). Solutions involving ansible.builtin.command are cumbersome or don’t work correctly in check mode.
Parameters¶
Examples¶
- name: Add a setting to ~/.gitconfig
community.general.git_config:
name: alias.ci
scope: global
value: commit
- name: Add a setting to ~/.gitconfig
community.general.git_config:
name: alias.st
scope: global
value: status
- name: Remove a setting from ~/.gitconfig
community.general.git_config:
name: alias.ci
scope: global
state: absent
- name: Add a setting to ~/.gitconfig
community.general.git_config:
name: core.editor
scope: global
value: vim
- name: Add a setting system-wide
community.general.git_config:
name: alias.remotev
scope: system
value: remote -v
- name: Add a setting to a system scope (default)
community.general.git_config:
name: alias.diffc
value: diff --cached
- name: Add a setting to a system scope (default)
community.general.git_config:
name: color.ui
value: auto
- name: Make etckeeper not complaining when it is invoked by cron
community.general.git_config:
name: user.email
repo: /etc
scope: local
value: 'root@{{ ansible_fqdn }}'
- name: Read individual values from git config
community.general.git_config:
name: alias.ci
scope: global
- name: Scope system is also assumed when reading values, unless list_all=yes
community.general.git_config:
name: alias.diffc
- name: Read all values from git config
community.general.git_config:
list_all: yes
scope: global
- name: When list_all is yes and no scope is specified, you get configuration from all scopes
community.general.git_config:
list_all: yes
- name: Specify a repository to include local settings
community.general.git_config:
list_all: yes
repo: /path/to/repo.git
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Matthew Gamble (@djmattyg007)
Marius Gedminas (@mgedmin)