Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

vars-file error #1

@prata

Description

@prata

After a clean pip install of python-packer (which is pretty neat by the by), I noticed that validating json would fail when using a var-file. Packer is actually looking for -var-file, rather than -vars-file.

[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Python shell history and tab completion are enabled.

import packer
packerfile = '/home/prata/code/packer/templates/webserver.json'
exc = []
vars_file = '/home/prata/code/packer/environment/kuei-jin.json'
packer_exec_path = '/opt/packer/packer'
p = packer.Pack(packerfile, exc=exc, vars_file=vars_file, exec_path=packer_exec_path)
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'Pack'
p = packer.Packer(packerfile, exc=exc, vars_file=vars_file, exec_path=packer_exec_path)
p.validate(syntax_only=False)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/packer/init.py", line 124, in validate
return command()
File "/usr/lib/python2.7/site-packages/sh.py", line 1021, in call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/lib/python2.7/site-packages/sh.py", line 486, in init
self.wait()
File "/usr/lib/python2.7/site-packages/sh.py", line 500, in wait
self.handle_command_exit_code(exit_code)
File "/usr/lib/python2.7/site-packages/sh.py", line 516, in handle_command_exit_code
raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_1:

RAN: '/opt/packer/packer validate -vars-file=/home/prata/code/packer/environment/kuei-jin.json /home/prata/code/packer/templates/webserver.json'

Options:

-syntax-only Only check syntax. Do not verify config of the template.
-except=foo,bar,baz Validate all builds other than these
-only=foo,bar,baz Validate only these builds
-var 'key=value' Variable for templates, can be used multiple times.
-var-file=path JSON file containing user variables.

I removed the Usage info and just copied the Options section from the error. Below is my version of packer being used.

[prata@kusanagi packer]$ /opt/packer/packer version
Packer v0.7.5

Your version of Packer is out of date! The latest version
is 0.8.2. You can update by downloading from www.packer.io
[prata@kusanagi packer]$

Would you like me to submit a pull request for this? It's a pretty simple change. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions