packer.py - python library for interacting with hashicorp packer CLI executable.
Project follows semantic versioning , v0.x.x API should be considered unstable, API will change frequently, please plan accordingly.
packer.py can be installed via pip:
$ pip install packer.pyBelow is the packer.py equivalent of running packer CLI commands
>>> from packerpy import PackerExecutable
>>>
>>> PackerExecutable().validate('/path/to/good_template.json')
(0, '1521843453,,ui,say,Template validated successfully.\n', '')
>>>
>>> PackerExecutable().validate('/path/to/bad_template.json')
(1, "1521843610,,ui,error,Template validation failed. Errors are shown below.\\n\n1521843610,,ui,error,Errors validating build 'amazon-ebs'. 1 error(s) occurred:\\n\\n* Bad script 'setup_things.sh': stat setup_things.sh: no such file or directory\n", '')
>>>
>>> PackerExecutable().validate('/path/to/bad_template.json', syntax_only=True)
(0, '1521843659,,ui,say,Syntax-only check passed. Everything looks okay.\n', '')
>>>
>>> PackerExecutable(config={'stdout': None }).version()
1521843095,,version,0.10.2
1521843095,,version-prelease,
1521843095,,version-commit,141440147f75b5d1ca500c133a5f879c226f2b10
1521843095,,ui,say,Packer v0.10.2
1521843095,,ui,say,
1521843095,,ui,say,Your version of Packer is out of date! The latest version\nis 1.2.1. You can update by downloading from www.packer.io
(0, None, '')
>>>
>>> PackerExecutable(config={'executable_path': '/path/to/packer_1.2.1' , 'stdout': None }).version()
1521848321,,version,1.2.1
1521848321,,version-prelease,
1521848321,,version-commit,3d5592d04
1521848321,,ui,say,Packer v1.2.1
(0, None, '')- build
- inspect
- validate
- version
packer.py is licensed under the Apache license 2.0. See LICENSE for the full license text.