Resolved: Inspec tests failing to run after upgrading to 1.4.3

Hi,

Is anyone else running inspec tests and using packer 1.4.3?

I upgraded from 1.4.1 to 1.4.3 and get the following error when building and ESXi image

2019/09/10 16:59:18 [INFO] (telemetry) Starting provisioner inspec
==> web-page-counter-vmware: Provisioning with Inspec...
2019/09/10 16:59:18 packer: 2019/09/10 16:59:18 SSH proxy: serving on 127.0.0.1:54693
==> web-page-counter-vmware: Executing Inspec: inspec exec ../test/ImageBuild --backend ssh --host 127.0.0.1 --key-files /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/packer-provisioner-inspec.101959433.key --user grazzer --port 54693 --input-file /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/packer-provisioner-inspec.614951636.yml
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 SSH proxy: accepted connection
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 authentication attempt from 127.0.0.1:54694 to 127.0.0.1:54693 as grazzer using none
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 authentication attempt from 127.0.0.1:54694 to 127.0.0.1:54693 as grazzer using publickey
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LANG=en_GB.UTF-8
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL_VERSION=3.3.3
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL=iTerm2
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new exec request: uname -s
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] Opening new ssh session
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] starting remote command: uname -s
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 [INFO] 6 bytes written for 'stdout'
2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 6 bytes written for 'stdout'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LANG=en_GB.UTF-8
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL_VERSION=3.3.3
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL=iTerm2
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new exec request: uname -m
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] Opening new ssh session
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] starting remote command: uname -m
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 7 bytes written for 'stdout'
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 7 bytes written for 'stdout'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LANG=en_GB.UTF-8
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL_VERSION=3.3.3
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL=iTerm2
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new exec request: test -f /etc/debian_version && cat /etc/debian_version
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] Opening new ssh session
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] starting remote command: test -f /etc/debian_version && cat /etc/debian_version
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 11 bytes written for 'stdout'
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 11 bytes written for 'stdout'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LANG=en_GB.UTF-8
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL_VERSION=3.3.3
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new env request: LC_TERMINAL=iTerm2
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 new exec request: test -f /etc/lsb-release && cat /etc/lsb-release
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] Opening new ssh session
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [DEBUG] starting remote command: test -f /etc/lsb-release && cat /etc/lsb-release
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 [INFO] 105 bytes written for 'stdout'
2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] RPC endpoint: Communicator ended with: 0
2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 105 bytes written for 'stdout'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stderr'
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] RPC client: Communicator ended with: 0
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 [INFO] 0 bytes written for 'stdin'
    web-page-counter-vmware: Could not fetch inspec profile in "--input-file".
2019/09/10 16:59:21 packer: 2019/09/10 16:59:21 shutting down the SSH proxy
2019/09/10 16:59:21 [INFO] (telemetry) ending inspec

When I rollback to packer 1.4.2 everything works!

My packer template file is here

All suggestions welcomed.

Thank you,
Graham

A few more details:

Packer 1.4.2 working Inspec call from the logs

web-page-counter-vmware: Executing Inspec: inspec exec ../test/ImageBuild --backend ssh --host 127.0.0.1 --key-files /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/packer-provisioner-inspec.576734145.key --user grazzer --port 49737 --attrs /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/

whereas the call gets transformed in packer 1.4.3 to

==> web-page-counter-vmware: Provisioning with Inspec...
2019/09/10 12:18:23 packer: 2019/09/10 12:18:23 SSH proxy: serving on 127.0.0.1:51134
==> web-page-counter-vmware: Executing Inspec: inspec exec ../test/ImageBuild --backend ssh --host 127.0.0.1 --key-files /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/packer-provisioner-inspec.832976573.key --user grazzer --port 51134 --input-file /var/folders/lm/nxj5y0qs52xb620c8t793x040000gn/T/

Which results in this error -

web-page-counter-vmware: Could not fetch inspec profile in "--input-file" 

Looks like it’s related to https://github.com/hashicorp/packer/pull/7893

Guessing I need to tweak my Inspec profile or inspec stanza…

Updated to latest version of Inspec - inspec_4.16.0-1_amd64.deb - challenge is still there though :neutral_face:

Resloved!

Fundamental misunderstanding on my part of where inspec is being run from.

The --input-file parameter was introduced with inspec 4.x (I think).
I upgraded the inspec binary on the target system…but of course I now realise that Inspec is run on the system where Packer is launched a.k.a. my macbook!

$ inspec version
3.7.11

Your version of InSpec is out of date! The latest version is 4.16.0.

Once I upgraded Inspec on my mac to > 4.X everything worked as expected.

To summarise:

If you get an error like:

Could not fetch inspec profile in "--input-file"

Ensure to check the version of Inspec running on the platform that Packer is launched from is v4.x .

Cheers,
Graham