packer#
Packer CLI related helpers.
- 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:
Install Packer: 官方安装文档
- Packer Releases: Packer 的所有历史版本的
pre-compiled binary 的下载地址. 同时也可以查到所有历史版本.
- Packer change log:
Packer 的所有版本的变更日志.
- 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.read this link to know more about /usr/local/bin folder: https://iboysoft.com/wiki/macos-usr-local-bin.html