hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.08k stars 3.33k forks source link

Add a `download` command to only download and check the ISO file #6472

Open SkypLabs opened 6 years ago

SkypLabs commented 6 years ago

Hello there,

I would like to see a download command added to packer to only download and check the ISO file without starting to build anything. The idea behind this feature request would be to be able to automatically (using a CI service for example) check if the ISO file used by a template is still available (to avoid dead links).

I look forward to your feedback on this feature.

Cheers.

SwampDragons commented 6 years ago

I like this idea and I don't think it's the first time someone has asked for it. I think I've also seen people suggest adding an option to the null builder to allow it to download ISOs. Definitely worth thinking about and seeing if we can add it to the roadmap.

bronislav commented 5 years ago

I think download is not a clear name for such command. I'd extend this feature request to all builders which has any kind of base of source image. For example, amazon-ebs builder has source_ami parameter and proposed command may validate that image exists. Similar thing can be done with other builders. Also, in most cases there is no sense to download full image and it is enough to issue HEAD http request to check that link is not broken.

bronislav commented 5 years ago

I think this functionality may be introduced as part of the validate command using additional flag.

@SwampDragons, what do you think?

SwampDragons commented 5 years ago

Historically, we've found that expecting network access for the validate command often breaks peoples' pipelines. The idea of adding these network checks behind a flag inside validate is a good one.

vtolstov commented 5 years ago

i'm propose not use download keyword, but something like cache. so all remote resources must be cache inside packer_cache dir for feature use

azr commented 5 years ago

I agree with @vtolstov here, I'm also copy pasting a comment I made before there : https://github.com/hashicorp/packer/issues/7132#issuecomment-448622015

I like the idea of packer build -cache buildfile because changes would be minimal IMO. We would just have to pass a boolean to StepDownload:

https://github.com/hashicorp/packer/blob/e666b60d166db7b4c6185d8b9a5417c6622d68c7/builder/vmware/iso/builder.go#L75-L83

Say: StopAfterCompletion: true or StopAfterCompletion: b.config.Cache which can halt packer execution after StepDownload.Run executed successfully.

bronislav commented 5 years ago

@azr your approach will works only for builders that using downloadable artifacts. But what about other cloud builders like EC2?

I don't think that adding feature which works only for small amount of builders is good approach.

azr commented 5 years ago

@bronislav, packer doesn't really have a state of built EC2 instances and I think caching shouldn't apply here. To do so we would have to start an instance, download stuff to it; then save it then remember the AMI. To me; this is already 2 different buildfiles.

But may be I am missing something and if so please elaborate on what you had in mind. 🙂

bronislav commented 5 years ago

@azr I mean that to build AMI using EC2 builder packer don't need to download anything. Instead it could check using AWS API that the base AMI it is going to use actually exists. Some other builder may use different approach.

azr commented 5 years ago

Right, I should have read the previous messages, sorry.

I also like the idea to sorts of "validate pre conditions". But I think this would require adding a step after validation.

bkmetzler commented 3 years ago

I think this would be best handled by updating the "file" source, and allowing the source to be a remote http(s) address. Would just need to add the checksum verification. This is something I would be able to use.

github-actions[bot] commented 2 years ago

This issue has been synced to JIRA for planning.

JIRA ID: HPR-772