Commit Graph

53 Commits

Author SHA1 Message Date
Adrien Delorme 0785c2f6fc
build using HCL2 (#8423)
This follows #8232 which added the code to generate the code required to parse
HCL files for each packer component.

All old config files of packer will keep on working the same. Packer takes one
argument. When a directory is passed, all files in the folder with a name
ending with  “.pkr.hcl” or “.pkr.json” will be parsed using the HCL2 format.
When a file ending with “.pkr.hcl” or “.pkr.json” is passed it will be parsed
using the HCL2 format. For every other case; the old packer style will be used.

## 1. the hcl2template pkg can create a packer.Build from a set of HCL (v2) files

I had to make the packer.coreBuild (which is our one and only packer.Build ) a public struct with public fields

## 2. Components interfaces get a new ConfigSpec Method to read a file from an HCL file.

  This is a breaking change for packer plugins.

a packer component can be a: builder/provisioner/post-processor

each component interface now gets a `ConfigSpec() hcldec.ObjectSpec`
which allows packer to tell what is the layout of the hcl2 config meant
to configure that specific component.

This ObjectSpec is sent through the wire (RPC) and a cty.Value is now
sent through the already existing configuration entrypoints:

 Provisioner.Prepare(raws ...interface{}) error
 Builder.Prepare(raws ...interface{}) ([]string, error)
 PostProcessor.Configure(raws ...interface{}) error

close #1768


Example hcl files:

```hcl
// file amazon-ebs-kms-key/run.pkr.hcl
build {
    sources = [
        "source.amazon-ebs.first",
    ]

    provisioner "shell" {
        inline = [
            "sleep 5"
        ]
    }

    post-processor "shell-local" {
        inline = [
            "sleep 5"
        ]
    }
}

// amazon-ebs-kms-key/source.pkr.hcl

source "amazon-ebs" "first" {

    ami_name = "hcl2-test"
    region = "us-east-1"
    instance_type = "t2.micro"

    kms_key_id = "c729958f-c6ba-44cd-ab39-35ab68ce0a6c"
    encrypt_boot = true
    source_ami_filter {
        filters {
          virtualization-type = "hvm"
          name =  "amzn-ami-hvm-????.??.?.????????-x86_64-gp2"
          root-device-type = "ebs"
        }
        most_recent = true
        owners = ["amazon"]
    }
    launch_block_device_mappings {
        device_name = "/dev/xvda"
        volume_size = 20
        volume_type = "gp2"
        delete_on_termination = "true"
    }
    launch_block_device_mappings {
        device_name = "/dev/xvdf"
        volume_size = 500
        volume_type = "gp2"
        delete_on_termination = true
        encrypted = true
    }

    ami_regions = ["eu-central-1"]
    run_tags {
        Name = "packer-solr-something"
        stack-name = "DevOps Tools"
    }
    
    communicator = "ssh"
    ssh_pty = true
    ssh_username = "ec2-user"
    associate_public_ip_address = true
}
```
2019-12-17 11:25:56 +01:00
Adrien Delorme 078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Adrien Delorme 5517d41468 make sure all documentation fields are there
* add missing `temporary_key_pair_name` field for alicloud
* add missing description to `vpc_filter` for aws
* add missing ssh communicator fields for aws
* add links for aws
* update vmware-vmx docs
* manually describe AMI Configuration section for ebsvolume
* display missing required ami_name field for aws
* add missing fields for docker
* add missing fields for openstack
2019-08-26 17:16:54 +02:00
Adrien Delorme 4cb7c30987 Merge remote-tracking branch 'origin/master' into scrape_doc_to_builder_struct_config 2019-08-21 16:44:23 +02:00
Megan Marsh 773e76c1ce remove unused import 2019-08-01 11:35:53 -07:00
Megan Marsh b6f3742425 check container os, not host os, when creating container dir default 2019-08-01 11:31:21 -07:00
Adrien Delorme 696fce9739 docker: rewrap struct comments for documentation generation 2019-06-06 17:34:17 +02:00
Adrien Delorme 4399684372 make fmt autogenerated docs 2019-06-06 16:29:25 +02:00
Adrien Delorme e6cbb013ba add // go:generate struct-markdown to all previously edited files 2019-06-05 16:42:18 +02:00
Adrien Delorme f1917edd34 generate the comments for config struct of builders scraping doc website 2019-06-05 16:42:17 +02:00
Adrien Delorme 2da36b7374 builder/docker: default container dir to "c:/packer-files" on windows 2019-05-22 16:55:26 +02:00
Megan Marsh 70150ffa0f set powershell entrypoint for windows containers 2019-03-28 16:46:07 -07:00
Megan Marsh 3b87f2a519 stop container before committing if windows 2019-03-27 15:25:51 -07:00
Megan Marsh 8f3313d81e Create new docker communicator for windows containers 2019-03-27 15:25:32 -07:00
Adrien Delorme 2718a5ed62 Revert "revert changes to docker entrypoint; since this is a backwards-breaking change it needs to wait for a minor release"
This reverts commit 2a79d64ae0.
2018-12-13 10:23:46 +01:00
Megan Marsh 2a79d64ae0 revert changes to docker entrypoint; since this is a backwards-breaking change it needs to wait for a minor release 2018-12-12 15:30:24 -08:00
Ali Rizvi-Santiago a6af04417e Moved the entrypoint argument for the docker builder in front of the image so it's passed correctly as an argument. 2018-12-10 15:09:56 -06:00
Ali Rizvi-Santiago 2e977019e4 Modified the docker builder's default run_command to specify the shell via the entrypoint command line argument as suggested by @vrubiolo in #6920. 2018-12-04 23:52:17 -06:00
Ali Rizvi-Santiago 310ea6c006 Updated docker's default config to use regular bourne shell instead of bourne again. Closes #6920. 2018-12-04 18:28:48 -06:00
Matthew Hooker 1901c0385f
remove login_email from docker
adds fixer
removes documentation
removes from docker builder and docker-push pp
2017-10-25 10:53:06 -07:00
localghost 5866d4ea24 Move container user inspect to StepConnectDocker. 2017-10-10 22:45:47 +02:00
Matthew Hooker b3661c1f63
builder/docker: set user during exec.
Add `exec_user` option to control what user `docker exec` is run as.
2017-09-28 16:39:23 -07:00
Sergei A Mamonov 07f7183b64 Add docker container dir to template 2017-08-14 09:26:05 -07:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Florian Rey 73c5eac4f0 Handle commit author & message the same way 2016-11-24 13:33:42 +01:00
Florian Rey c925acf502 Introduce docker commit changes 2016-11-24 11:42:34 +01:00
Rickard von Essen b2d9782a9e
Improved support for Amazon EC2 Container Registry - ECR
This adds support for authenticating towards ECR in the docker builder
and docker-push post-processor using them same mechanisms as in the
amazon builders. I.g. access key/secret key, credentials on file,
environment variables, sts tokens or IAM instance roles.
2016-09-04 14:33:47 +02:00
Hao 5139b853fa privilege enabled docker container (#3475)
Issue #2724
2016-04-29 19:12:20 -07:00
Chris Bednarski 5503b7f496 Don't export errors 2015-08-19 13:12:16 -07:00
Chris Bednarski 746b9a8391 Formatting tweaks 2015-08-18 16:55:29 -07:00
Chris Bednarski 1b1bd19c20 Reformat code so we can grep for this more easily 2015-08-18 16:47:12 -07:00
Chris Bednarski 750a9c61de Added discard option for docker builder, also reorganized some error messages 2015-08-18 14:38:32 -07:00
Chris Bednarski f3f3d1fe73 Formatting 2015-07-16 19:34:36 -07:00
georgevicbell 3a681d0c0c Add Pty Bool 2015-07-16 21:22:11 -04:00
Mitchell Hashimoto 84189f7a28 builder/*: properly save interpolation context 2015-06-22 09:22:42 -07:00
Mitchell Hashimoto cab2665119 builder/docker: support custom communicators 2015-06-14 22:09:38 -07:00
Mark Peek 16320372d6 Make some builder config usage more consistent with other builders 2015-06-12 14:02:09 -07:00
Mitchell Hashimoto 819986d19f builder/docker: validate export path is not a dir [GH-2105] 2015-05-29 16:24:29 -07:00
Mitchell Hashimoto 9c7b4b63c5 builder/docker: fix config parsing 2015-05-29 09:19:20 -07:00
Mitchell Hashimoto 4cae87645f builder/docker: fix issue where docker might get nil interp context 2015-05-27 13:03:47 -07:00
Mitchell Hashimoto faf327eed0 builder/docker: convert to new interpolation 2015-05-27 12:55:36 -07:00
Mitchell Hashimoto e4dc5d31d8 builder/docker: support volumes 2014-09-05 15:48:42 -07:00
Mitchell Hashimoto 2e4882f0c3 builder/docker: can login to pull 2014-09-05 15:24:12 -07:00
Mitchell Hashimoto 5cb7355814 builder/docker: change commit to the opt-in, special case build steps
/cc @andytson - Wanted to CC you in here so you could see some changes I
made.

First, I changed commit to opt-in, so you set "commit": true to get
commit behavior. This simplifies the logic a bit. Then, I removed the
skipping for StepExport and StepCommit and put that into the Builder
itself. This simplifies those steps (limits abstraction leakage).
Otherwise, everything looks great!
2014-09-04 18:03:15 -07:00
Andy Thompson 1baa63f060 Add a docker commit step to the docker builder that runs instead of export if export_path not present 2014-07-21 20:42:23 +01:00
Jack Pearkes 0788d96841 builder/docker: include user vars for docker configuration 2014-01-02 14:49:30 -08:00
Mitchell Hashimoto 037a744be5 builder/docker: customize run command [GH-648] 2013-12-27 10:17:45 -07:00
Mitchell Hashimoto 8ec68031d0 builder/docker: ability to disable pull 2013-11-09 17:21:24 -08:00
Mitchell Hashimoto 0287cdd614 builder/docker: config refactor 2013-11-09 17:07:14 -08:00
Mitchell Hashimoto da683afde0 builder/docker: config validation test 2013-11-09 11:47:32 -08:00