mschuchard.general.packer_fmt (1.0.1) — module

Module to manage Packer template and config canonical formatting.

| "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

Rewrites all Packer configuration files to a canonical format. Both configuration files (.pkr.hcl) and variable files (.pkrvars.hcl) are updated. JSON files (.json) are not modified. The given content must be in Packer's HCL2 configuration language; JSON is not supported.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# rewrite Packer files in /path/to/packer_dir to canonical format
- name: Rewrite packer files in /path/to/packer_dir to canonical format
  mschuchard.general.packer_fmt:
    config_dir: /path/to/packer_dir
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# verify canonical formatting of Packer files in /path/to/packer_dir
- name: Verify canonical formatting of packer files in /path/to/packer_dir
  mschuchard.general.packer_fmt:
    config_dir: /path/to/packer_dir
    check: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# recursively rewrite Packer files in current directory to canonical format
- name: Recursively rewrite packer files in current directory to canonical format
  mschuchard.general.packer_fmt:
    recursive: true

Inputs

    
check:
    default: false
    description: Check if the input is formatted. Exit status will be 0 if all input is
      properly formatted, and non-zero otherwise.
    required: false
    type: bool

recursive:
    default: false
    description: Also process files in subdirectories. By default only the given directory
      (or current directory) is processed.
    required: false
    type: bool

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

Outputs

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