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

Bug: Google Compute Builder failing for newer Debian-based images #3661

Closed
clounie opened this issue Jun 29, 2016 · 12 comments
Closed

Bug: Google Compute Builder failing for newer Debian-based images #3661

clounie opened this issue Jun 29, 2016 · 12 comments

Comments

@clounie
Copy link

clounie commented Jun 29, 2016

With the Google Compute Builder, any builds with a Debian 7 or Debian 8 source_image later than these versions will error, when trying to SSH for provisioning:

  • debian-8-jessie-v20160329
  • debian-7-wheezy-v20160329

I've tried ssh_username of:

  • google
  • debian
  • root (scp starts erroring if you use this)

But none of them work. Is this similar to #788, or was I barking up the wrong tree?

I looked, as well, in the release notes for Google Compute, but didn't see anything directly related/obvious.


Debug Info:

{
  "provisioners": [
    {
        "type": "file",
        "source": "./myTestFile.log",
        "destination": "/etc/myTestFile.log",
        "direction": "upload"
    }
  ],
  "builders": [
    {
      "type": "googlecompute",
      "image_name": "debian-ssh-test-image",
      "project_id": "my-gce-project",
      "zone": "us-east1-d",
      "account_file": "gce-service-account-creds.json",
      "source_image": "debian-8-jessie-v20160418"
    }
  ]
}
@rickard-von-essen
Copy link
Collaborator

@ido #3587 doesn't really change anything for this issue.

@clounie
Copy link
Author

clounie commented Jul 14, 2016

Note that adding the metadata they specify to add in the article for creating a user account at least gets you a successful ssh connection. However, it then has problems actually doing anything on the instance.

Maybe because the only scopes it uses are:

2016/07/14 11:12:30 packer: 2016/07/14 11:12:30 [INFO]   -- Scopes: [https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/devstorage.full_control]

...with no cloud.useraccounts.readonly scope. And thus it doesn't properly setup the user account on the instance? (Well, that and it overrides the sshKeys metadata)

Gist for what I'm talking about: https://gist.github.com/clounie/dce56ad8107a33cf60b3c362e17210cf

@clounie
Copy link
Author

clounie commented Aug 19, 2016

Am I on the right track with any of this? I'd be more than willing to do a PR if it's something that needs to be added/changed in Packer.

@bivald
Copy link

bivald commented Sep 26, 2016

@clounie did you ever get closer to solving this issue? I'm seeing it as well.

Update: I've asked for help on the GCE mailing list as well, https://groups.google.com/forum/#!topic/gce-discussion/mJP4X_TnqDo

@rickard-von-essen
Copy link
Collaborator

This works for me:

{
  "builders": [
    {
      "type": "googlecompute",
      "project_id": "<project>",
      "zone": "europe-west1-b",
      "ssh_username": "debian",
      "source_image": "debian-8-jessie-v20160418"
    }
  ]
}

Try adding "ssh_username": "debian".

@crunk1
Copy link
Contributor

crunk1 commented Sep 26, 2016

I have tried repro'ing this with a few templates. Here are some interesting results:
Packer version: 0.10.1_linux_amd64
Host: Ubuntu 14.04

{
  "provisioners": [
    {
        "type": "file",
        "source": "foo.txt",
        "destination": "/etc/foo.txt",
        "direction": "upload"
    }
  ],
  "builders": [
    {
      "type": "googlecompute",
      "image_name": "debian-ssh-test-image",
      "project_id": "my-gce-project",
      "zone": "us-east1-d",
      "account_file": "creds.json",
      "source_image": "debian-8-jessie-v20160418",
      "ssh_username": "foo"
    }
  ]
}

Result: Build 'googlecompute' errored: scp: /etc/foo.txt: Permission denied
In other words, it looks like the created SSH user does not have root permissions.

I tried it again with the same template, but I modified /etc/foo.txt to be /home/foo/foo.txt.
Result: /home/foo/foo.txt was created.

@crunk1
Copy link
Contributor

crunk1 commented Sep 26, 2016

Update: I have repro'ed that root access is denied on centos-7 as well.

@rickard-von-essen
Copy link
Collaborator

I'm closing this since this seems to be working as it should and mostly be a usage question. Use IRC #packer-tool on Freenode or the mailing list to ask for help on how to use Packer.

See https://www.packer.io/community/

If you are describing a bug or a feature request please reopen and try to add some more details to make it clearer.

@bivald
Copy link

bivald commented Sep 27, 2016

I can confirm that adding "ssh_username": "debian" is working for me. I can sudo using either sudo in each command, or by adding sudo in execute_command (for shell scripts). For file provisioner, I haven't tried it yet but I assume I simply need to use the technique described in the docs:

If you want to upload files to locations that require elevated privileges, we recommend uploading them to temporary locations and then using the shell provisioner to move them into place.

@crunk1
Copy link
Contributor

crunk1 commented Sep 27, 2016

If you want to upload files to locations that require elevated privileges, we recommend uploading them to temporary locations and then using the shell provisioner to move them into place.

I was not aware of that. Good to know.

@bivald
Copy link

bivald commented Sep 28, 2016

@crunk1 It's a fairly new requirement (at least on GCE)

@clounie
Copy link
Author

clounie commented Oct 4, 2016

Follow-up on my end: Looks like something must have changed on GCE's side.

It works with both Packer v0.10.1 and v0.10.2 now, using the same examples that failed for me before.

Thanks for checking it out rickard.

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants