From 846634bfd76f7af06d6d90ba9ea3c6ce5aa37ce6 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 9 Jun 2016 09:13:32 +0100 Subject: [PATCH] Resolve `git.config` error where minion does not have Git installed #115 --- pillar.example | 3 +++ users/init.sls | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pillar.example b/pillar.example index 61ad153..e88ee3d 100644 --- a/pillar.example +++ b/pillar.example @@ -81,6 +81,9 @@ users: options: - "StrictHostKeyChecking yes" + # Using gitconfig without Git installed will result in an error + # https://docs.saltstack.com/en/latest/ref/states/all/salt.states.git.html: + # This state module now requires git 1.6.5 (released 10 October 2009) or newer. gitconfig: user.name: B User user.email: buser@example.com diff --git a/users/init.sls b/users/init.sls index ca44a40..03c9cf3 100644 --- a/users/init.sls +++ b/users/init.sls @@ -416,6 +416,11 @@ users_googleauth-{{ svc }}-{{ name }}: {%- endif %} {% if 'gitconfig' in user %} +{% if not salt['cmd.has_exec']('git') %} +skip_{{ name }}_gitconfig_since_git_not_installed: + test.fail_without_changes: + - name: "Git configuration for user {{ name }} has been skipped because Git is not installed." +{% else %} {% for key, value in user['gitconfig'].items() %} users_{{ name }}_user_gitconfig_{{ loop.index0 }}: {% if grains['saltversioninfo'] >= (2015, 8, 0, 0) %} @@ -433,6 +438,7 @@ users_{{ name }}_user_gitconfig_{{ loop.index0 }}: {% endif %} {% endfor %} {% endif %} +{% endif %} {% endfor %}