Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone function breaks after upgrade from 2.7.10 to 2.8.1 #11

Open
nj344170 opened this issue Jun 26, 2019 · 7 comments
Open

Clone function breaks after upgrade from 2.7.10 to 2.8.1 #11

nj344170 opened this issue Jun 26, 2019 · 7 comments

Comments

@nj344170
Copy link

nj344170 commented Jun 26, 2019

Has anyone else had issues cloning a repository after upgrading to Ansible 2.8.1. I can provide more details if so. We had two environments that were working on 2.7.10 but are no longer working on 2.8.1. Thanks

@pablodav
Copy link

I haven't tested it on ansible 2.8 yet, some more details could be useful.

@nj344170
Copy link
Author

I can't reproduce the issue when I run the win_git powershell script on the Windows host itself so it could be something in our ansible environments. I was hoping someone else was on 2.8.1 to see if that was the case. I am getting a error message "Error cloning ssh://XXX to C:\XXX! Msg: Cloning into C:\XXX ...." but haven't been able to extract any useful details from the error variable yet. From what I can tell the git clone actually works but an error is still thrown. I'm not considering this a permanent fix but if I add the below line to the win_git script everything works as it did before.
set GIT_REDIRECT_STDERR=2>&1

@lucassawyer
Copy link

I am experiencing the same problem. I see that same error, and the clone still happens.

@attilastrba
Copy link

I am having the same problem, tried to figure out the reason, but actually the only thing I can see is that the cloning fails but without any error. Running it on the machine works. By forwarding GIT_REDIRECT_STDERR=2>&1. Any idea what could be the problem?

@jimbo8098
Copy link

I've not used the module at all, just inspecting it for use in my own projects, but from the sounds of things the issue is simply that the Windows Git command outputs content to STDERR which is often common during a transaction like this. By setting that environment variable, you throw that output into STDOUT instead.

This, in itself, doesn't appear problematic but looking at these lines:

ansible-win_git/win_git.ps1

Lines 197 to 198 in a592bd1

&git $git_opts | Tee-Object -Variable local_git_output | Out-Null
$Return.rc = $LASTEXITCODE

You can see that the $LASTEXITCODE is retrieved which is the exit from the command cloning the repo but the last exit won't be from that, it'll be from the Out-Null instead since that's the last command to run using the output piped from the Tee-Object and, in turn, the git clone.

This output from Out-Null becomes the rc for the module which is how the Ansible code will determine if something failed or didn't. So, you have a few options:

  1. Set that environment variable to bypass. This must effectively set the exit code so it's interpreted differently within Out-Null
  2. Set ansible to ignore_errors: true. Inadivsable because you won't be able to see if the command failed or not.
  3. Work around it with a powershell script instead which defeats the point in the module for this purpose. Inadvisable since you'd need to be careful with what you do.
  4. Amend the module. I suspect that checking the exit codes from the git command is best. assign the output of the git command to a variable directly then immediately take the last exit code from that. Afterwards, you should be able to Tee-Object etc. as necessary.

All assumptions and untested but they might assist you guys.

@n2qcn
Copy link

n2qcn commented Jan 4, 2022

+1

@matiasgrana
Copy link

Hello,

Foe anyone that it's facing the same error we found the message "fatal: Unable to persist credentials with the 'wincredman' credential store." after add GIT_REDIRECT_STDERR=2>&1.

To solve this we unset the credential.helper and credential.credentialSore and set dpapi before the cloning:

`

  • name: Unset credential.credentialStore of git
    ansible.windows.win_command:
    cmd: "git config --global --unset credential.credentialStore"
    ignore_errors: true

  • name: Unset credential.helper of git
    ansible.windows.win_command:
    cmd: "git config --global --unset credential.helper"
    ignore_errors: true

  • name: Set credential.credentialStore of git
    ansible.windows.win_command:
    cmd: "git config --global credential.credentialStore dpapi"
    ignore_errors: true

  • name: Set credential.helper of git
    ansible.windows.win_command:
    cmd: "git config --global credential.helper dpapi"
    ignore_errors: true
    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants