packer#

Packer CLI related helpers.

class packer_ami_workflow.packer.OSEnum(value)[source]#

An enumeration.

class packer_ami_workflow.packer.ArchEnum(value)[source]#

An enumeration.

class packer_ami_workflow.packer.PlatformEnum(value)[source]#

An enumeration.

packer_ami_workflow.packer.temp_cwd(path: Union[str, Path])[source]#

Temporarily set the current working directory (CWD) and automatically switch back when it’s done.

Example:

with temp_cwd(Path("/path/to/target/working/directory")):
    # do something
class packer_ami_workflow.packer.PackerInstaller(version: str, platform: PlatformEnum, dir_workspace: Path)[source]#

An installer to install Packer on MacOS or Linux.

Reference:

Parameters:
  • version – The version of Packer to install. For example, “1.11.0”.

  • platform – The platform to install Packer on. For example, “PlatformEnum.linux_amd64”.

  • dir_workspace – The working directory for this installation task.

Usage example:

from pathlib import Path
import packer_ami_workflow.api as paw

packer_installer = paw.PackerInstaller(
    version="1.11.0",
    platform=paw.PlatformEnum.macOS_arm64,
    # platform=paw.PlatformEnum.linux_amd64,
    dir_workspace=Path(__file__).absolute().parent,
)
packer_installer.install()
property dir_tmp: Path#

A temporary directory to store the downloaded zip file and the unzipped binary.

move_to_usr_local_bin()[source]#

Copy the pre-compiled binary to /usr/local/bin/packer.

install()[source]#

Install packer pre-compiled binary.