Commit Graph
96 Commits
Author SHA1 Message Date
Megan Marsh ced2e945e3 make period stripping more strict so that users can disable provisiners by adding .old or whatever; this is pretty typical convention. 2020-02-13 12:59:47 -08:00
Megan Marsh 817957fe4f Merge pull request #8616 from hashicorp/packer-plugin-path
add PACKER_PLUGIN_PATH for plugin discovery
2020-01-28 12:09:55 -08:00
Megan Marsh a163ff7388 swap ordering so PACKER_PLUGIN_PATH gets precedence 2020-01-17 12:40:30 -08:00
nywilken c93a076698 config: Update loading of packerconfig to only log when a plugin is loaded
Before this change loading of a packerconfig would display `loaded
plugin ...` for any plugin defined in the packerconfig - even if it
didn't exist on disk. This change updates how plugins defined in
packerconfig are loaded to ensure that only successfully loaded plugins
get the lovely message `loaded plugin ...`. For any plugin that fails to
load Packer will log that it failed to load the plugin and continue
processing any other defined plugins.

* Add a test to ensure loadSingleComponent errors when plugin does not
exists
2020-01-17 13:33:51 -05:00
Megan Marsh 83ecebbf37 add PACKER_PLUGIN_PATH for plugin discovery 2020-01-16 13:13:29 -08:00
nywilken fb76323c4d config: Fix loading external plugins from a packerconfig
This change introduces a loadExternalComponent which can be used for
loading a single plugin path. The function is a combination of
the discoverSingle and discoverExternalComponents functions.
2020-01-15 13:08:30 -05:00
Megan Marsh d95b0122f8 Merge pull request #8542 from TJM/plugin_logs
Parse out -PACKERSPACE- before looking for exec
2020-01-06 14:14:46 -08:00
Tommy McNeely 469a4d2a11 Fix names of range variables to reduce confusion and remove overriden plugin name 2020-01-06 13:19:39 -07:00
Tommy McNeely 72112ccae2 Make the path assignment less confusing 2020-01-06 12:50:12 -07:00
Tommy McNeely 3177a5413c Fix external plugins path was blank 2020-01-02 08:15:32 -07:00
Tommy McNeely 9d85aa36ec Parse out -PACKERSPACE- before looking for exec 2019-12-27 14:23:28 -07:00
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
Megan Marsh 5d5189a9a2 only log when external plugin is used, since this is the much rarer event 2019-12-09 12:10:07 -08:00
Adrien Delorme 5a6dffde9a use port as ints 2019-03-19 15:01:12 +01:00
Matthew Hooker 81522dced0 move packer to hashicorp 2017-04-04 13:39:01 -07:00
Matthew Hooker 79287d7e47 simplify some code 2017-03-28 20:36:20 -07:00
Chris Bednarski 010fa977cf Change to explicit comparison with MagicCookieValue 2016-10-13 18:14:22 -07:00
Chris Bednarski 3935703286 Supress plugin discovery from plugins, which is redundant and noisy in the logs 2016-10-13 16:41:33 -07:00
Mark Peek 1c7a855302 Switch osext package from mitchellh -> kardianos #2842 2015-11-04 12:36:00 -08:00
Mark Peek ba7814b0ed Merge pull request #2846 from markpeek/packer-tmp
Create docker temp files under packer.d when TMPDIR is not set
2015-10-26 17:09:22 -07:00
Chris Bednarski e080e73b04 Add some exit codes and use a constant for -PACKERSPACE- 2015-10-21 16:57:38 -07:00
Chris Bednarski d09a9ab0c7 Implemented internal plugins
- Internal plugins are compiled into the same packer binary and invoked through the plugin command
- Search paths allow disk-based plugins to override and should function as normal
- This should allow for a 94% space savings vs statically compiling all the plugins as separate binaries.. approximately 24mb vs 431mb
2015-10-21 16:57:38 -07:00
Mark Peek 38c81cf3e3 Move ConfigFile() and ConfigDir() from package main to packer 2015-10-16 17:32:36 -07:00
Mitchell Hashimoto e88fa43cfe find proper extension 2015-06-11 16:45:24 -04:00
Mitchell Hashimoto 9514be0df0 lowercase the extension of plugins just in case 2015-06-10 20:24:34 -07:00
Mitchell Hashimoto 03032c26fb ignore non-exe plugins on Windows [GH-2173] 2015-06-10 20:23:39 -07:00
Mitchell Hashimoto 1ee2b014a6 packer: remove Ui/Cache from CoreConfig 2015-05-27 20:09:52 -07:00
Mitchell Hashimoto dc74ec5612 packer: remove Environment 2015-05-25 17:29:10 -07:00
Mitchell Hashimoto 9d89ca8e07 command: build should be converted to new API, compiles 2015-05-23 16:30:45 -07:00
Aneesh Agrawal 63597af8bb Clarify the plugin discovery search & priority orders. 2015-03-11 01:20:30 -04:00