Terraform: Terraform module pull failing on Gitlab repository

Created on 17 Aug 2016  路  14Comments  路  Source: hashicorp/terraform

Hi guys,

I am having some errors pulling a module from a gitlab repository. I am running terraform 0.7.0

nnamdi@worklaptop:~/test/ide/geppetto-workspace/foo-portal$ terraform get -update

Get: git::ssh://git.nnamdi.com:practice/aws-dhcp-options.git (update)
Error loading Terraform: Error downloading modules: error downloading 'ssh://git.nnamdi.com:practice/aws-dhcp-options.git': /usr/bin/git exited with 128: fatal: Not a git repository (or any of the parent directories): .git

But that repository is a valid git repository from which I can clone

nnamdi@worklaptop:~/test/ide/geppetto-workspace/foo-portal$ git clone [email protected]:practice/aws-dhcp-options.git

Cloning into 'aws-dhcp-options'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 14 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (14/14), 6.09 KiB | 0 bytes/s, done.
Resolving deltas: 100% (2/2), done.
Checking connectivity... done.

Does anyone know whats going on here? My module files are laid out in the root of the repository btw.

bug core

Most helpful comment

Okay I figured out the issue. So silly. The git url, when copied from the git UI should be changed slightly to replace the colon (:) with a forward slash (/).

So in the terraform source, the following

[email protected]:cprenzberg/infrastructure-aws-key-pairs.git

should be replaced with

[email protected]/cprenzberg/infrastructure-aws-key-pairs.git

Thanks a lot! Now I am completely satisfied with my terraform project

All 14 comments

Hello! Can you share the exact value (or exact format of the value) for your module source so I can start trying to reproduce this? Can you repro this against a private GitLab repo that is hosted on GitLab.com itself? Just trying to find an easy way for me to repro this.

Also, I saw you posted on #4004 that this was the same problem but I believe that was a different problem and I couldn't reproduce that at all. I'll wait for you to learn more about your source URL to see if I can reproduce this.

One option: have you tried deleting your .terraform/modules directory and doing a terraform get again? It looks like there is a chance it somehow could've gotten corrupted.

I'm seeing a similar issue using terraform 0.7.1 running on travis against a private github repo, using https and a github key:

Error loading Terraform: Error downloading modules: error downloading 'https://user:[email protected]/org/repo': /usr/bin/git exited with 128: Cloning into '.terraform/modules/46dab912acf7df7c11e5ee2d5394c8c7'...

The module source is:

module "cross_project" {
  source = "git::https://user:[email protected]/org/repo//modules/mymodule"
}

The terraform get command runs successfully when run locally.

Is there a version requirement on git command line, or similar? or could this be an SSH host key verification issue?

Git exiting with code 128 just seems like Git itself failed. Terraform doesn't do anything fancy here, it is literally cloning with git clone URL where the URL is shown there in the error message...

Adding an explicit git clone URL to the travis build steps, using the URL shown in the error message, succeeds without any issue.

The travis build is using git version 1.8.5.6.

Hm, can you share debug logs and let me see if that helps me at all.

2016/08/22 21:52:45 [INFO] Terraform version: 0.7.1  55ba6ebd3d0e7800bc3755690ab60f6e4ca8bf94
2016/08/22 21:52:45 [INFO] CLI args: []string{"/tmp/terraform/terraform", "get", "infra"}
2016/08/22 21:52:45 [DEBUG] Detected home directory from env var: /home/travis
2016/08/22 21:52:45 [DEBUG] Detected home directory from env var: /home/travis
2016/08/22 21:52:45 [DEBUG] Attempting to open CLI config file: /home/travis/.terraformrc
2016/08/22 21:52:45 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/08/22 21:52:45 [DEBUG] Detected home directory from env var: /home/travis
2016/08/22 21:52:45 [TRACE] Preserving existing state lineage "7480f155-a3d0-4322-86a1-58da133f6c23"
2016/08/22 21:52:45 [TRACE] Preserving existing state lineage "7480f155-a3d0-4322-86a1-58da133f6c23"
2016/08/22 21:52:45 [WARN] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
Error loading Terraform: Error downloading modules: error downloading 'https://user:[email protected]/org/project': /usr/bin/git exited with 128: Cloning into '.terraform/modules/46dab912acf7df7c11e5ee2d5394c8c7'...

Darn, nothing :( I'll give it a shot locally to try to repro.

Okay I figured out the issue. So silly. The git url, when copied from the git UI should be changed slightly to replace the colon (:) with a forward slash (/).

So in the terraform source, the following

[email protected]:cprenzberg/infrastructure-aws-key-pairs.git

should be replaced with

[email protected]/cprenzberg/infrastructure-aws-key-pairs.git

Thanks a lot! Now I am completely satisfied with my terraform project

Great to hear! Thanks!

Had a similar issue, wanted to use ssh auth. This is a gitlab deployed on-prem, so not sure if if this works the same as the cloud.

git::ssh://git@host/pathstuff/repo.git//networking?ref=0.0.1"

For gitlab and Terraform 0.12.6, the correct syntax for hosted gitlab is git::[email protected]:/whatever.git?ref=someref

Had a similar issue, wanted to use ssh auth. This is a gitlab deployed on-prem, so not sure if if this works the same as the cloud.

git::ssh://git@host/pathstuff/repo.git//networking?ref=0.0.1"

This fixed it for me in the cloud. Thank you!

@danielhoherd Thank you for the suggestion 馃憤

Was this page helpful?
0 / 5 - 0 ratings