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

File provisioner fails to upload directory to a directory #10781

Closed
pravindahal opened this issue Mar 18, 2021 · 3 comments
Closed

File provisioner fails to upload directory to a directory #10781

pravindahal opened this issue Mar 18, 2021 · 3 comments

Comments

@pravindahal
Copy link

pravindahal commented Mar 18, 2021

Overview of the Issue

The documentation suggests that directory upload is possible, however, in my tests, it is not. It fails with Upload failed: scp: /home/ubuntu/: Is a directory, where /home/ubuntu/ is the destination directory.

Reproduction Steps

mkdir data
echo test > data/test
packer build azure.pkr.hcl # see below for azure.pkr.hcl file used

Packer version

1.7.0

Simplified Packer Buildfile

azure.pkr.hcl

variable "image_name" {
  type    = string
  default = "name"
}

locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }

source "azure-arm" "main" {
  subscription_id           = "XXX"
  tenant_id                 = "XXX"

  location                  = "North Europe"

  os_type                   = "Linux"
  image_publisher           = "Canonical"
  image_offer               = "UbuntuServer"
  image_sku                 = "18.04-LTS"
  image_version             = "latest"

  os_disk_size_gb           = 128

  resource_group_name       = "XXX"
  storage_account           = "XXX"

  capture_container_name    = "images"
  capture_name_prefix       = "packer"
}


build {
  sources                   = ["sources.azure-arm.main"]

  provisioner "file" {
    source                  = "./data/"
    destination             = "/home/ubuntu/"
  }

}

Operating system and Environment details

Tested on Windows 10 and Ubuntu 20.04 on WSL 2.0.

Log Fragments and crash.log files

azure-arm.main: output will be in this color.

==> azure-arm.main: Running builder ...
==> azure-arm.main: Getting tokens using device flow
==> azure-arm.main: Getting token for https://management.azure.com/
==> azure-arm.main: Loading auth token from file: /home/pravin/.azure/packer/oauth-d23844a4-14b7-4e42-9e3a-be7fcb83625bmgmt.json
==> azure-arm.main: Auth token found in file: /home/pravin/.azure/packer/oauth-d23844a4-14b7-4e42-9e3a-be7fcb83625bmgmt.json
==> azure-arm.main: Getting tokens using device flow
==> azure-arm.main: Getting token for Vault resource
==> azure-arm.main: Loading auth token from file: /home/pravin/.azure/packer/oauth-d23844a4-14b7-4e42-9e3a-be7fcb83625bvault.json
==> azure-arm.main: Auth token found in file: /home/pravin/.azure/packer/oauth-d23844a4-14b7-4e42-9e3a-be7fcb83625bvault.json
    azure-arm.main: Creating Azure Resource Manager (ARM) client ...
==> azure-arm.main: Warning: You are using Azure Packer Builder to create VHDs which is being deprecated, consider using Managed Images. Learn more https://www.packer.io/docs/builders/azure/arm#azure-arm-builder-specific-options
==> azure-arm.main: WARNING: Zone resiliency may not be supported in North Europe, checkout the docs at https://docs.microsoft.com/en-us/azure/availability-zones/
==> azure-arm.main: Creating resource group ...
==> azure-arm.main:  -> ResourceGroupName : 'pkr-Resource-Group-xjmbretprf'
==> azure-arm.main:  -> Location          : 'North Europe'
==> azure-arm.main:  -> Tags              :
==> azure-arm.main: Validating deployment template ...
==> azure-arm.main:  -> ResourceGroupName : 'pkr-Resource-Group-xjmbretprf'
==> azure-arm.main:  -> DeploymentName    : 'pkrdpxjmbretprf'
==> azure-arm.main: Deploying deployment template ...
==> azure-arm.main:  -> ResourceGroupName : 'pkr-Resource-Group-xjmbretprf'
==> azure-arm.main:  -> DeploymentName    : 'pkrdpxjmbretprf'
==> azure-arm.main:
==> azure-arm.main: Getting the VM's IP address ...
==> azure-arm.main:  -> ResourceGroupName   : 'pkr-Resource-Group-xjmbretprf'
==> azure-arm.main:  -> PublicIPAddressName : 'pkripxjmbretprf'
==> azure-arm.main:  -> NicName             : 'pkrnixjmbretprf'
==> azure-arm.main:  -> Network Connection  : 'PublicEndpoint'
==> azure-arm.main:  -> IP Address          : '13.74.132.127'
==> azure-arm.main: Waiting for SSH to become available...
==> azure-arm.main: Connected to SSH!
==> azure-arm.main: Uploading ./data/ => /home/ubuntu/
==> azure-arm.main: Upload failed: scp: /home/ubuntu/: Is a directory
==> azure-arm.main: Provisioning step had errors: Running the cleanup provisioner, if present...
==> azure-arm.main: Removing the created Deployment object: 'pkrdpxjmbretprf'
==> azure-arm.main:
==> azure-arm.main: Cleanup requested, deleting resource group ...
==> azure-arm.main: Azure token expired. Saving the refreshed token...
==> azure-arm.main: Resource group has been deleted.
Build 'azure-arm.main' errored after 6 minutes 57 seconds: scp: /home/ubuntu/: Is a directory

==> Wait completed after 6 minutes 57 seconds

==> Some builds didn't complete successfully and had errors:
--> azure-arm.main: scp: /home/ubuntu/: Is a directory

==> Builds finished but no artifacts were created.
@sylviamoss
Copy link
Member

sylviamoss commented Mar 18, 2021

Hey there, I was able to reproduce the issue and I'll take some time to figure out what's going on here. Thanks for reporting!
To add more information, the issue only happened with the azure builder. I tested with docker use ubuntu image and the same provisioner definition worked fine.

@ghost
Copy link

ghost commented Apr 30, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-azure#50 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-azure#50.

@ghost ghost closed this as completed Apr 30, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
This issue was closed.
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

3 participants