saltstack-formulas / users-formula

Configure users via pillar
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
99 stars 361 forks source link

Do not try to run git config when git is not available #169

Closed rhertzog closed 6 years ago

rhertzog commented 6 years ago

The state will not fail gracefully, instead you will get an error like this one:

      ID: users_rhertzog_user_gitconfig_0
Function: git.config_set
    Name: alias.br
  Result: False
 Comment: State 'git.config_set' was not found in SLS 'users'
          Reason: 'git' __virtual__ returned False
 Changes:

And since pillar data can't be (easily) tuned according to minion's status, we really need this check here.

My tests with Salt 2017.7.3 have shown that cmd.has_exec() is reliable for this, contrary the what the comment was implying.

aboe76 commented 6 years ago

@rhertzog could you specify the salt version for this? to be sure it works

something like:

{% if grains['saltversioninfo'] >= [2017, 7, 3,0] %}
{% endif %}
rhertzog commented 6 years ago

@aboe76 I don't think that such a test makes sense. If the command was not working in some old version, then it might have been fixed with a point release of that old version. And we would need correct information of what version broke because otherwise adding a supplementary test is just causing more troubles than anything else.

Besides I don't see how you would want to hook that test, it would mean to duplicate the content:

if good-version
  if has_exec
   state
  endif
else
  state
endif

... which I find really ugly.

aboe76 commented 6 years ago

@rhertzog I think you are correct,