A Drone plugin to run packer builds.
pipeline:
build:
image: quay.io/heetch/drone-packer
include_files: [ config/common.json, config/<target> ]
root_dir: src/services/app/delivery/app-pk
target: base.json
variables:
name: packer
version: 33
account
: AWS account ID in which to assume the role. Instance IAM role will be used by defaultuse_ci_role
: IAM role name to use. Defaults toci
. Ignored ifaccount
is not providedroot_dir
: The root directory where the packer files live. When unset, the top level directory will be assumed.target
: Name of target packer template to executevariables
: Optional variables to pass to packer build commandsecret_variables
: List of variables to be read from environmentinclude_files
: List of variable files to include in buildexcept
: List of builders to skiponly
: List of builders to runon_error
: Configure the behaviour of Packer when build fail (default: cleanup)dry_run
: Only run a Packer validate.true
/false
(default: false)
root_dir
is a relative path to repository root.target
must be the name of the target template.target
can be provided as plugin parameter in .drone.yml file or it can be passed as deployment parameter using either drone CLI or github deployment api.variables
is optional and must be a flat dictionary. An intact JSON representation of the dictionary will be passed to packer.include_files
is an optional list of path to JSON files relative to build directory. It can contain<target>
literal string which will be replaced by actual target name as provided to the plugin.except
andonly
, if provided, must be valid Yaml list types.secret_variables
is an optional list of variable names that should be read from environment. Make sure to whitelist the secrets in drone configuration file
Following configuration
pipeline:
build:
image: quay.io/heetch/drone-packer
include_files: [ config/common.json, config/<target> ]
target: base.json
dry_run: false
variables:
name: packer
version: 33
secret_variables: [ vpc_id, subnet_id ]
secrets: [ vpc_id, subnet_id ]
will create a temporary file build_variables.json
containing the variables:
{
"name": "packer",
"version": 33
}
and run the command without line breaks.
packer build --var-file build_variables.json \
--var-file config/common.json \
--var-file config/base.json \
--var 'vpc_id=vpc-id-in-env' \
--var 'subnet_id=subnet-id-in-env' \
base.json