From 8e33bb8aa94985ee52ffc9806a25e2adb74506ca Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Wed, 17 Feb 2016 11:35:29 +0100 Subject: [PATCH] Add possibility to remove user's git config keys --- pillar.example | 4 ++++ users/init.sls | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pillar.example b/pillar.example index 9b0471e..aff4c26 100644 --- a/pillar.example +++ b/pillar.example @@ -115,6 +115,10 @@ users: user.email: buser@example.com "url.https://.insteadOf": "git://" + gitconfig.absent: + - push.default + - color\..+ + google_2fa: True google_auth: ssh: | diff --git a/users/init.sls b/users/init.sls index 3f50158..4e019b9 100644 --- a/users/init.sls +++ b/users/init.sls @@ -491,8 +491,9 @@ users_googleauth-{{ svc }}-{{ name }}: # - require_in: # - sls: users # -{% if 'gitconfig' in user %} {% if salt['cmd.has_exec']('git') %} + +{% if 'gitconfig' in user %} {% for key, value in user['gitconfig'].items() %} users_{{ name }}_user_gitconfig_{{ loop.index0 }}: {% if grains['saltversioninfo'] >= [2015, 8, 0, 0] %} @@ -510,6 +511,18 @@ users_{{ name }}_user_gitconfig_{{ loop.index0 }}: {% endif %} {% endfor %} {% endif %} + +{% if 'gitconfig.absent' in user and grains['saltversioninfo'] >= [2015, 8, 0, 0] %} +{% for key in user.get('gitconfig.absent') %} +users_{{ name }}_user_gitconfig_absent_{{ key }}: + git.config_unset: + - name: '{{ key }}' + - user: {{ name }} + - global: True + - all: True +{% endfor %} +{% endif %} + {% endif %} {% endfor %}