Can you specify a path in a git repo for the Inspec provisioner?

I would like to reference an inspec profile in a folder in the git repo. Something similar to what you can do in Kitchen:

  inspec_tests:
    - name: profile-name
      git: https://user@github.com/org/my_repo.git
      relative_path: inspec/sdp-base

Yes, you can. I have for example:

{
  "variables": {
    "github_token": "{{ env `GITHUB_TOKEN` }}"
  },
  "builders": [...],
  "provisioners": [
  {
      "type": "inspec",
      "profile": "https://{{ user `github_token` }}@github.com/<org>/<repo>",
      "extra_arguments": [
        "--no-distinct-exit",
        "--chef-license",
        "accept-silent",
        "--input-file",
        "inputs.yml",
        "--sudo"
      ]
    }
  ]
}

The github token is passed to allow authentication, since the repo is private, but the https:// path works fine, just as if you were passing it from the cli.

2 Likes

What is the path in your example? Are you saying I could use this?

"profile": "https://{{ user github_token }}@github.com/<org>/<repo>/<path>"

And just add path at the end of the git url?

My apologies, I just realised I misread your original post – your question was referring to the relative path of a profile, rather than just the ability to execute the Inspec provisioner.

No, I don’t think that will work, the repository needs to contain the profile at the top level, according to the documentation.

If your profile is on a sub path in a repository, you may be able to have a workaround where you have a provisioner which first get and unpack a tarball of the repository where your profile resides with a shell-local provisioner, then pass the correct path to Inspec.

Ok, thanks. I’ll give that a shot.