diff --git a/Makefile b/Makefile index 4cc3f79..5fb4a99 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,9 @@ files: git log --oneline --decorate --color > CHANGELOG test: + @install -d var + @echo "Looking up latest Amazon Linux AMI" + aws ec2 describe-images --owners amazon --filters 'Name=virtualization-type,Values=hvm' 'Name=root-device-type,Values=ebs' 'Name=architecture,Values=x86_64' 'Name=is-public,Values=true' 'Name=name,Values=amzn-ami-hvm-*-gp2' --query 'Images[*].{aws_source_ami:ImageId,created:CreationDate,description:Description}' |jq 'sort_by(.created)[-1]' |tee var/amazon-linux.json pip install tox==1.7.1 tox @@ -37,4 +40,4 @@ prepare: python scripts/make-release.py publish: - python setup.py sdist upload \ No newline at end of file + python setup.py sdist upload diff --git a/packer.py b/packer.py index a50758f..0a68826 100644 --- a/packer.py +++ b/packer.py @@ -115,7 +115,8 @@ def inspect(self, mrf=True): result = self.packer_cmd() if mrf: - result.parsed_output = self._parse_inspection_output(result.stdout) + result.parsed_output = self._parse_inspection_output( + result.stdout.decode('utf-8')) else: result.parsed_output = None return result diff --git a/tester.py b/tester.py index b537f08..ba60adb 100644 --- a/tester.py +++ b/tester.py @@ -7,14 +7,14 @@ only = [] # vars = {"variable1": "y", "variable2": "value"} vars = {} -vars_file = '/x' +var_file = 'packer/var/amazon-linux.json' p = packer.Installer('packer_executables/', 'packer_0.7.5_linux_amd64.zip') # If we installed packer using the provided installer, it will return # packer's executable path. We can use it below: # packer_exec = p.install() packer_exec = 'packer' -p = packer.Packer(packerfile, exc=exc, only=only, vars=vars, +p = packer.Packer(packerfile, exc=exc, only=only, vars=vars, var_file=var_file, exec_path=packer_exec) # print(p.version()) # validation = p.validate(syntax_only=True) diff --git a/tests/resources/packerfile.json b/tests/resources/packerfile.json index 36e6493..e83e79a 100644 --- a/tests/resources/packerfile.json +++ b/tests/resources/packerfile.json @@ -5,7 +5,7 @@ "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_secret_key": "{{env `AWS_ACCESS_KEY`}}", "aws_source_ami": "", - "instance_type": "m3.large", + "instance_type": "t2.large", "virtualbox_source_image": "", "insecure_private_key": "./keys/insecure_private_key" }, @@ -80,4 +80,4 @@ "format": "tar.gz" } ] -} \ No newline at end of file +} diff --git a/tests/test_packer.py b/tests/test_packer.py index 424e01d..d327a8d 100644 --- a/tests/test_packer.py +++ b/tests/test_packer.py @@ -7,24 +7,25 @@ TEST_RESOURCES_DIR = 'tests/resources' TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'packerfile.json') TEST_BAD_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'badpackerfile.json') +TEST_VARFILE = 'var/amazon-linux.json') class TestBase(testtools.TestCase): def test_build(self): - p = packer.Packer(TEST_PACKERFILE) + p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE) p.build() def test_fix(self): - p = packer.Packer(TEST_PACKERFILE) + p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE) p.fix() def test_inspect(self): - p = packer.Packer(TEST_PACKERFILE) + p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE) p.inspect() def test_validate(self): - p = packer.Packer(TEST_PACKERFILE) + p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE) p.validate() def test_version(self):