mschuchard.general.packer_build (1.0.1) — module

Module to manage Packer template and config artifact builds.

| "added in version" 1.0.0 of mschuchard.general"

Authors: Matthew Schuchard (@mschuchard)

Install collection

Install with ansible-galaxy collection install mschuchard.general:==1.0.1


Add to requirements.yml

  collections:
    - name: mschuchard.general
      version: 1.0.1

Description

Will execute multiple builds in parallel as defined in the template. The various artifacts created by the template will be outputted.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# build packer templates in /path/to/packer_dir
- name: Build packer templates and configs in /path/to/packer_dir
  mschuchard.general.packer_build:
    config_dir: /path/to/packer_dir
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# build only the null.this and null.that builds in the packer templates without parallelization and with timestamp display logging
- name: Build only the null.this and null.that builds in the packer templates without parallelization and with timestamp display logging
  mschuchard.general.packer_build:
    config_dir: /path/to/packer_dir
    only:
    - null.this
    - null.that
    parallel_builds: 1
    timestamp_ui: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# build everything except the null.this and null.that builds in the packer templates without cleanup and remove any existing artifacts
- name: Build everything except the null.this and null.that builds in the packer templates without cleanup and remove any existing artifacts
  mschuchard.general.packer_build:
    config_dir: /path/to/packer_dir
    excepts:
    - null.this
    - null.that
    on_error: abort
    force: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# build the packer template artifacts with vars and var files
- name: Build the packer template artifacts with vars and var files
  mschuchard.general.packer_build:
    config_dir: /path/to/packer_dir
    var:
    - var_name: var_value
    - var_name_other: var_value_other
    var_file:
    - one.pkrvars.hcl
    - two.pkrvars.hcl

Inputs

    
var:
    default: []
    description: Variables for templates.
    required: false
    type: list

only:
    default: []
    description: Build only the specified builds.
    required: false
    type: list

debug:
    default: false
    description: Debug mode enabled for builds.
    required: false
    type: bool

force:
    default: false
    description: Force a build to continue if artifacts exist, deletes existing artifacts.
    required: false
    type: bool

excepts:
    default: []
    description: Run all builds and post-processors other than these.
    required: false
    type: list

on_error:
    default: ''
    description: If the build fails do clean up (default), abort, ask, or run-cleanup-provisioner
    required: false
    type: str

var_file:
    default: []
    description: HCL2 files containing user variables.
    required: false
    type: list

config_dir:
    default: cwd
    description: Location of the directory or file containing the Packer template(s) and/or
      config(s).
    required: false
    type: str

timestamp_ui:
    default: false
    description: Enable prefixing of each ui output with an RFC3339 timestamp.
    required: false
    type: bool

parallel_builds:
    default: 0
    description: Number of builds to run in parallel. 0 means no limit.
    required: false
    type: int

Outputs

command:
  description: The raw Packer command executed by Ansible.
  returned: always
  type: str