Skip to content
This repository has been archived by the owner on Nov 12, 2021. It is now read-only.

Packer inspec provisioner test failing with \r error #19

Open
hc-github-team-packer opened this issue Nov 9, 2021 · 1 comment
Open

Comments

@hc-github-team-packer
Copy link

This issue was originally opened by @thompsm in hashicorp/packer#7510 and has been migrated to this repository. The original issue description is below.


Packer inspec provisioner incorrectly determines a files user and owner

  • Packer version 1.3.5 and 1.4.0
  • Host platform RHEL 6, 7, and Amazon Linux 2, using the amazon-ebs builder

This is my provisioners section of my template:

"provisioners": [{
    "type": "inspec",
    "profile": "./file.rb"
 }]

file.rb has:

describe file('/etc/ssh/sshd_config') do
  its('mode') { should cmp '0600' }
  it { should be_owned_by 'root' }
  its('group') { should eq 'root' }
end

The output from packer shows:

    amazon-ebs:
    amazon-ebs: Profile: tests from ./file.rb (tests from ..file.rb)
    amazon-ebs: Version: (not specified)
    amazon-ebs: Target:  ssh://xx.xx@127.0.0.1:59032
    amazon-ebs:
    amazon-ebs:   File /etc/ssh/sshd_config
    amazon-ebs:      ×  should be owned by "root"
    amazon-ebs:      expected `File /etc/ssh/sshd_config.owned_by?("root")` to return true, got false
    amazon-ebs:      ✔  mode should cmp == "0600"
    amazon-ebs:      ×  group should eq "root"
    amazon-ebs:
    amazon-ebs:      expected: "root"
    amazon-ebs:           got: "root\r"
    amazon-ebs:
    amazon-ebs:      (compared using ==)
    amazon-ebs:
    amazon-ebs:
    amazon-ebs: Test Summary: 1 successful, 2 failures, 0 skipped
==> amazon-ebs: Error executing Inspec: Non-zero exit status: exit status 100

If I run the same inspec test file, but directly using the inspec command outside of packer to the same host I get:

Version: (not specified)
Target:  ssh://ec2-user@X.X.X.X:22

  File /etc/ssh/sshd_config
     ✔  should be owned by "root"
     ✔  mode should cmp == "0600"
     ✔  group should eq "root"

Test Summary: 3 successful, 0 failures, 0 skipped
@nywilken
Copy link
Contributor

nywilken commented Nov 9, 2021

With the archival of this repository all open issues will be marked as read-only. If you wish to further discuss this plugin or any of its open issues we invite you to open a discussion on the Packer community forum.

More details on the plugin archiving process for this provisioner can be found on the Plans to Archive Unmaintained Packer Provisioner Plugins blog post.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants