Commit Graph

97 Commits

Author SHA1 Message Date
zhsj ef9713b348
Replace kardianos/osext.Executable with os.Executable (#10048)
os.Executable is available since go1.8
https://github.com/kardianos/osext/blob/master/osext_go18.go
2020-10-06 10:59:32 +02:00
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
Matt Hollingsworth 816f722e3b Fix typo in log statement 2015-01-31 09:41:01 -05:00
Mitchell Hashimoto c51cd3e39c remove command configs 2014-10-27 20:59:13 -07:00
Mitchell Hashimoto 779b6d1719 packer/rpc, packer/plugin: remove Command interfaces 2014-10-27 20:40:24 -07:00
Mitchell Hashimoto 96b0ec5395 Start putting commands in command/, modify core 2014-10-27 20:21:13 -07:00
Mitchell Hashimoto 6e4191829b Fix plugin loading from CWD [GH-1521] 2014-10-14 15:45:45 -07:00
Mitchell Hashimoto d4fcbfafa8 Mechanisms to disable checkpoint 2014-09-08 14:20:13 -07:00
Mitchell Hashimoto 25868e1a13 ConfigDir 2014-09-08 13:38:35 -07:00
Mitchell Hashimoto 60182afb0b Automatically discover plugins 2014-09-02 15:29:37 -07:00
Jack Pearkes 7d4efdc236 post-processor/vagrant-cloud: initial commit 2014-06-16 15:53:37 -04:00
Rickard von Essen cdaa9d5a8e Added support for Parallels Desktop for Mac [GH-223]
Added builder plugins: builder-parallels-iso and builder-parallels-pvm.
2014-05-01 20:29:22 +02:00
Florian Noeding b879ec85cc implemented null buider
The null builder is not really a bulider, it just setups a SSH
connection and runs the provisioners. It can be used to debug
provisioners without incurring high wait times. It does not create any
kind of image or artifact.
2014-03-24 11:26:10 +01:00
Mitchell Hashimoto 2af91addf9 Merge pull request #796 from Jimdo/puppet-server
Add puppet server provisioner
2014-02-24 09:49:27 -08:00
Mitchell Hashimoto 1502eed147 Add chef client provisioner to default list 2014-02-24 08:34:32 -08:00
Jan Brauer ee50657097 Merge remote-tracking branch 'upstream/master' into puppet-server 2014-02-18 09:41:10 +01:00
Jan Brauer 646f4a6dd3 Implement puppet-server provisioner
This closely modeled after the same provisioner
in Vagrant.
2014-01-08 12:50:24 +01:00
Matthew McKeen 3d60bfb312 Add docker-import post-processor.
Implemented initial working version
of Docker image importing code. #774
2014-01-02 14:49:14 -08:00
Matthew McKeen a0e533db41 Rename docker post processor to docker-push.
Implement login to a docker registry, error handling
2014-01-01 22:30:28 -08:00
Matthew McKeen 8bdb723264 Do some forward porting of the old work of
mitchellh/packer's docker branch. #774
2014-01-01 21:18:09 -08:00
Mitchell Hashimoto b994b8c09e Add vmware-vmx plugin 2013-12-26 14:55:06 -07:00