Code Monkey home page Code Monkey logo

packer-plugin-goss's People

Contributors

azr avatar btassone avatar dependabot[bot] avatar eleanorrigby avatar falcosuessgott avatar fishnix avatar frightenedmonkey avatar gennadyspb avatar jimmidyson avatar jsturtevant avatar p15223971 avatar perithompson avatar petemounce avatar robert-heinzmann-logmein avatar sanikagawhane avatar sarcasticadmin avatar tuxtof avatar vamegh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-goss's Issues

exec: "service": executable file not found in $PATH

Hi,

I use the goss provisioner with the following config:

./packer.json

{
  "provisioners": [
     ...
    {
      "type": "goss",
      "tests": [
        "./build/goss.yaml"
      ]
    }
  ]
}

./build/goss.yaml

---
service:
  chronyd:
    enabled: true
    running: true
  codedeploy-agent:
    enabled: true
    running: true
  sshd:
    enabled: true
    running: true

The goss binary seems to be started with a PATH that does not contain sbin. On the target system:

$ which service
/sbin/service

packer output:

1516721919,,ui,say,==> stag-base: Running goss tests...
1516721919,,ui,message, stag-base: .F.F.F..........
1516721919,,ui,message, stag-base:
1516721919,,ui,message, stag-base: Failures/Skipped:
1516721919,,ui,message, stag-base:
1516721919,,ui,message, stag-base: chronyd: running: Error: exec: "service": executable file not found in $PATH
1516721919,,ui,message, stag-base:
1516721919,,ui,message, stag-base: codedeploy-agent: running: Error: exec: "service": executable file not found in $PATH
1516721919,,ui,message, stag-base:
1516721919,,ui,message, stag-base: sshd: running: Error: exec: "service": executable file not found in $PATH
1516721919,,ui,message, stag-base:
1516721919,,ui,message, stag-base: Total Duration: 0.061s

I could not figure out where PATH is actually used and where it comes from since this is a remote command. Any hints how to debug this issue?

PR Proposal: update to latest Packer SDK and modern plugin support

I wanted to gauge interest in a PR for updating to the latest Packer SDK and enabling modern plugin support for this repository. It would be helpful for various projects if we could use the GoSS provisioner with modern Packer usage.

Please let me know. Alternatively, I can fork this project and perform light maintenance it if there is no further interest. Thanks!

Feature request - set up goss in server-mode

It would be really useful if the provisioner had a mode whereby it set up goss to run in server mode to be used as a health-check.

Parameters that I think would be necessary:

  • output format (default to JSON?)
  • path (built-in default is /healthz)
  • the usual networking bits like port and bind address

This would be a bit more involved, since it would probably also need to create a service definition file, which on modern ubuntu would be a systemd unit file, on macOS a LaunchAgent, and so on.

Is that something you'd be interested in a PR for?

build procedure

Hello,
While I mentioned problems building the provisioner in another issue, I figured it may be good to create a separate one and document it. I'm wondering what the proper steps are, considering that the usual 'go get' fails to find hcldec:

~ # go version
go version go1.13.7 linux/amd64
~ # go get github.com/YaleUniversity/packer-provisioner-goss
package github.com/hashicorp/hcl/v2/hcldec: cannot find package "github.com/hashicorp/hcl/v2/hcldec" in any of:
	/usr/local/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOROOT)
	/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOPATH)
~ # go build github.com/YaleUniversity/packer-provisioner-goss
/go/src/github.com/YaleUniversity/packer-provisioner-goss/packer-provisioner-goss.go:12:2: cannot find package "github.com/hashicorp/hcl/v2/hcldec" in any of:
	/usr/local/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOROOT)
	/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOPATH)
go build $GOPATH/src/github.com/YaleUniversity/packer-provisioner-goss
/go/src/github.com/YaleUniversity/packer-provisioner-goss/packer-provisioner-goss.go:12:2: cannot find package "github.com/hashicorp/hcl/v2/hcldec" in any of:
	/usr/local/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOROOT)
	/go/src/github.com/hashicorp/hcl/v2/hcldec (from $GOPATH)

However, the build executes if go is executed inside the source dir:

~ # cd $GOPATH/src/github.com/YaleUniversity/packer-provisioner-goss
/go/src/github.com/YaleUniversity/packer-provisioner-goss # go build
go: downloading github.com/hashicorp/packer v1.5.1
go: downloading github.com/hashicorp/hcl v1.0.0
[...]

Am I missing something obvious? Thanks!

release 0.2.0 is out of sync with the current codebase

Hi @fishnix,

I just tried the 0.2.0 release that you put up and it doesn't seem like any of the changes have been applied to it.

I made a new release here:

https://github.com/vamegh/packer-provisioner-goss/releases/tag/v0.2.0

using the following script:

#!/usr/bin/env bash

package=$1
if [[ -z "$package" ]]; then
  echo "usage: $0 <package-name>"
  exit 1
fi
package_split=(${package//\// })
package_name=${package_split[-1]}

platforms=("windows/amd64" "windows/386" "darwin/amd64" "darwin/386" "linux/amd64" "linux/386")

for platform in "${platforms[@]}"
do
    platform_split=(${platform//\// })
    GOOS=${platform_split[0]}
    GOARCH=${platform_split[1]}
    output_name=$package_name'-'$GOOS'-'$GOARCH
    if [ $GOOS = "windows" ]; then
        output_name+='.exe'
    fi

    env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package
    if [ $? -ne 0 ]; then
        echo 'An error has occurred! Aborting the script execution...'
        exit 1
    fi
done

From: https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04

These now support all of the new features, if you could can you please update the binaries for the release to match the current state of the code.

Packer API Version 5 fix instructions

Since this project seems a state I have a fix for the Packer API Version 5 error if anyone needs it.

The error is:

error initializing provisioner โ€˜gossโ€™: Incompatible API version with plugin. Plugin version: 4, Ours: 5

My fix: pedroMMM#4

packer builder vsphere-iso & builder vsphere-clone is not picking up goss provisioner

root@2d3b461589cb:medium # PACKER_LOG=1  packer build -force -var-file=variables.json -var "nodetype=centos7-medium"  packer.json

PACKER bUILD LOG:-

2020/05/29 11:34:21 [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:21 [DEBUG] Discovered plugin: goss = /root/.packer.d/plugins/packer-provisioner-goss
2020/05/29 11:34:21 using external provisioners [goss]
2020/05/29 11:34:21 [DEBUG] Discovered plugin: goss = /root/.packer.d/plugins/packer-provisioner-goss
2020/05/29 11:34:21 using external provisioners [goss]
2020/05/29 11:34:21 Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:21 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:21 Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:21 [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:21 Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value:
2020/05/29 11:34:21 Deleting kv.Value: {{timestamp}}
2020/05/29 11:34:21 Deleting kv.Value: CentOS-7-x86_64-Minimal-2003.iso
2020/05/29 11:34:21 Deleting kv.Value: x86_64
2020/05/29 11:34:21 Deleting kv.Value: 7
2020/05/29 11:34:21 Deleting kv.Value: 1.mobitv
2020/05/29 11:34:21 Deleting kv.Value: centos01p1v
2020/05/29 11:34:21 Deleting kv.Value: inn
2020/05/29 11:34:21 Deleting kv.Value: http://mirror.cs.vt.edu/pub/CentOS
2020/05/29 11:34:21 Deleting kv.Value: 9a2c47d97b9975452f7d582264e9fc16d108ed8252ac6816239a3b58cef5c53d
2020/05/29 11:34:21 Deleting kv.Value: sha256
2020/05/29 11:34:21 Deleting kv.Value: Minimal-1908
2020/05/29 11:34:21 Deleting kv.Value: centos7.cfg
2020/05/29 11:34:21 Deleting kv.Value: centos7-medium
2020/05/29 11:34:21 Deleting kv.Value: Jhf
2020/05/29 11:34:21 Deleting kv.Value: 10.76.96.177
2020/05/29 11:34:21 Deleting kv.Value: puitv
2020/05/29 11:34:21 Deleting kv.Value: INV
2020/05/29 11:34:21 Deleting kv.Value: insl
2020/05/29 11:34:21 Deleting kv.Value: 60m
2020/05/29 11:34:21 Deleting kv.Value: root
2020/05/29 11:34:21 Deleting kv.Value: 4
2020/05/29 11:34:21 Deleting kv.Value: 102400
2020/05/29 11:34:21 Deleting kv.Value: 16384
2020/05/29 11:34:21 Deleting kv.Value: Dev
2020/05/29 11:34:21 Deleting kv.Value: DEV
2020/05/29 11:34:21 Deleting kv.Value: vxhsttv-01
2020/05/29 11:34:21 Deleting kv.Value: VM-68 Network
2020/05/29 11:34:21 Deleting kv.Value: !Devops
2020/05/29 11:34:21 Deleting kv.Value: inv
2020/05/29 11:34:21 Deleting kv.Value: devops
2020/05/29 11:34:21 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:21 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-vsphere-iso"}
2020/05/29 11:34:21 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:21 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin979597640
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: args: []string{"packer-builder-vsphere-iso"}
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Plugin address: unix /tmp/packer-plugin979597640
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Waiting for connection...
2020/05/29 11:34:21 packer-builder-vsphere-iso plugin: Serving a plugin connection...
2020/05/29 11:34:21 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:21 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2020/05/29 11:34:21 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:22 packer-provisioner-shell plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:22 packer-provisioner-shell plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:22 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2020/05/29 11:34:22 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin913396845
2020/05/29 11:34:22 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin913396845
2020/05/29 11:34:22 packer-provisioner-shell plugin: Waiting for connection...
2020/05/29 11:34:22 packer-provisioner-shell plugin: Serving a plugin connection...
2020/05/29 11:34:22 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:22 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2020/05/29 11:34:22 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:22 packer-provisioner-shell plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:22 packer-provisioner-shell plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:22 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2020/05/29 11:34:22 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin292266517
2020/05/29 11:34:22 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin292266517
2020/05/29 11:34:22 packer-provisioner-shell plugin: Waiting for connection...
2020/05/29 11:34:22 packer-provisioner-shell plugin: Serving a plugin connection...
2020/05/29 11:34:22 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:22 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2020/05/29 11:34:22 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:22 packer-provisioner-shell plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:22 packer-provisioner-shell plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:22 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2020/05/29 11:34:22 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin350724319
2020/05/29 11:34:22 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin350724319
2020/05/29 11:34:22 packer-provisioner-shell plugin: Waiting for connection...
2020/05/29 11:34:22 packer-provisioner-shell plugin: Serving a plugin connection...
2020/05/29 11:34:22 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:22 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2020/05/29 11:34:22 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:22 packer-provisioner-shell plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:22 packer-provisioner-shell plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:22 packer-provisioner-shell plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:22 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2020/05/29 11:34:22 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin328007896
2020/05/29 11:34:22 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin328007896
2020/05/29 11:34:22 packer-provisioner-shell plugin: Waiting for connection...
2020/05/29 11:34:22 packer-provisioner-shell plugin: Serving a plugin connection...
2020/05/29 11:34:22 Creating plugin client for path: /usr/local/bin/packer
2020/05/29 11:34:22 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell-local"}
2020/05/29 11:34:22 Waiting for RPC address for: /usr/local/bin/packer
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Attempting to open config file: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Setting cache directory: /root/packer/centos7/medium/packer_cache
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: args: []string{"packer-provisioner-shell-local"}
2020/05/29 11:34:22 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin957704393
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Plugin address: unix /tmp/packer-plugin957704393
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Waiting for connection...
2020/05/29 11:34:22 packer-provisioner-shell-local plugin: Serving a plugin connection...
2020/05/29 11:34:22 Creating plugin client for path: /root/.packer.d/plugins/packer-provisioner-goss
2020/05/29 11:34:22 Starting plugin: /root/.packer.d/plugins/packer-provisioner-goss []string{"/root/.packer.d/plugins/packer-provisioner-goss"}
2020/05/29 11:34:22 Build debug mode: false
2020/05/29 11:34:22 Force build: true
2020/05/29 11:34:22 On error:
2020/05/29 11:34:22 Waiting on builds to complete...
==> Builds finished but no artifacts were created.
Failed to initialize build 'vsphere-iso': error initializing provisioner 'goss': fork/exec /root/.packer.d/plugins/packer-provisioner-goss: exec format error

==> Builds finished but no artifacts were created.
2020/05/29 11:34:22 [INFO] (telemetry) Finalizing.
2020/05/29 11:34:22 waiting for all plugin processes to complete...
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited
2020/05/29 11:34:22 /usr/local/bin/packer: plugin process exited

Issue when using HCL2 for packer templates

Hello,

as reported in PR #37 there is an issue with using packer-provisioner-goss with HCL2 packer config.

This issue happens even when I put anything into goss block, but also when I use empty goss block like this:

provisioner "goss" {
}

Error reported error looks following:

Error: Failed preparing provisioner-block "goss" ""

  on default.pkr.hcl line 98:
  (source code not available)

2 errors occurred:
	* unknown configuration key: "download_path"; raws is []interface
{}{map[string]interface {}{"packer_build_name":"ubuntu-18-04",
"packer_builder_type":"openstack"}, map[string]interface {}{"arch":interface
{}(nil), "download_path":interface {}(nil), "format":interface {}(nil),
"format_options":interface {}(nil), "goss_file":interface {}(nil),
"inspect":interface {}(nil), "password":interface {}(nil),
"remote_folder":interface {}(nil), "remote_path":interface {}(nil),
"retry_timeout":interface {}(nil), "skip_install":interface {}(nil),
"skip_ssl":interface {}(nil), "sleep":interface {}(nil), "tests":interface
{}(nil), "url":interface {}(nil), "use_sudo":interface {}(nil),
"username":interface {}(nil), "vars_env":interface {}(nil),
"vars_file":interface {}(nil), "vars_inline":interface {}(nil),
"version":interface {}(nil)}, map[string]interface {}(nil)} 

 and ctx data is map[interface {}]interface {}(nil)
	* unknown configuration key: "skip_install"; raws is []interface
{}{map[string]interface {}{"packer_build_name":"ubuntu-18-04",
"packer_builder_type":"openstack"}, map[string]interface {}{"arch":interface
{}(nil), "download_path":interface {}(nil), "format":interface {}(nil),
"format_options":interface {}(nil), "goss_file":interface {}(nil),
"inspect":interface {}(nil), "password":interface {}(nil),
"remote_folder":interface {}(nil), "remote_path":interface {}(nil),
"retry_timeout":interface {}(nil), "skip_install":interface {}(nil),
"skip_ssl":interface {}(nil), "sleep":interface {}(nil), "tests":interface
{}(nil), "url":interface {}(nil), "use_sudo":interface {}(nil),
"username":interface {}(nil), "vars_env":interface {}(nil),
"vars_file":interface {}(nil), "vars_inline":interface {}(nil),
"version":interface {}(nil)}, map[string]interface {}(nil)} 

 and ctx data is map[interface {}]interface {}(nil)

goss_file vs tests is confusing

so, as far as I understand, tests only copies the given files to the machine, but the tests that are actually execute is whatever is defined on goss_file, right?

so, even if tests is an array, I can only run 1 suite.

maybe we can remove goss_file and run all the suites given on tests?

if you agree, I can work on a patch for it...

thanks for the project BTW :)

packer validate breaks with unknown configuration key

Hello,

I'm trying to move from packer-provisioner-goss 1.4.0 to 3.0.3, and packer 1.6.x to 1.7.2. It seems that there are two config options that do not pass packer's validate function:

2 errors occurred:
	* unknown configuration key: '"downloadPath"'
	* unknown configuration key: '"skipInstall"'

To see if anything else causes issues, I used the sample config, and the above two options seem to be the only ones. The errors above are a result of using this in packer.json:

         {
            "type": "goss",
            "format": "tap",
            "tests": [
                "{{ template_dir }}/goss/build.yml"
            ],
	    "arch": "amd64",
    	    "downloadPath": "/tmp/goss-VERSION-linux-ARCH",
    	    "inspect": "{{user `inspect_mode`}}",
	    "password": "",
	    "skipInstall": false,
	    "url":"https://github.com/aelsabbahy/goss/releases/download/vVERSION/goss-linux-ARCH",
	    "username": "",
	    "version": "0.3.2",
            "goss_file": "build.yml"
        },

Am I missing something by any chance? Thanks!

Add dependabot for github workflow and go dependencies

Just opening up an issue here so I don't forget. Not high on my list of priorities but we're in the middle of taking care of this on the majority of OSS repositories.

Those who normally contribute, please let me know if you foresee any issues with a Go version/packages update.

Running into issue while Testing Windows AMI

I am trying to create a Microsoft Windows Server 2016 Base AMI and use Goss for testing it. The same configuration worked fine when I launched Amazon Linux base AMI. However it fails provisioning Goss when I use it for Windows. Am I missing something for Windows server tests using Goss (below scenario).

My Template:

{
  "sensitive-variables": ["aws_access_key", "aws_secret_key", "token", "winrm_username_env", "winrm_password_env"],

  "builders": [{
      "type"                : "amazon-ebs",
      "access_key"          : "{{ user `aws_access_key` }}",
      "secret_key"          : "{{ user `aws_secret_key` }}",
      "token"               : "{{ user `token`}}",
      
      "region"              : "{{ user `region` }}",
      "instance_type"       : "t2.micro",
      "source_ami"          : "ami-xxx",
      "ami_name"            : "windows-ami-packer--{{timestamp}}",
      "winrm_username"      : "{{ user `winrm_username_env`}}",
      "user_data_file"      : "C:/Users/name/Desktop/packer-build-windows-ami/scripts/bootstrap_win.txt",
      "communicator"        : "winrm",
      "tags":{
        "Name": "windows-image- {{timestamp}}"
        }

  }],

  "provisioners": [
    {
      "type"                : "windows-restart"
    },

    {
      "script": "C:/Users/name/Desktop/packer-build-windows-ami/scripts/scripts.ps1",
      "type": "powershell"
    },

    {
      "type": "powershell",
      "environment_vars": ["WINRMUSER={{ user `winrm_username_env`}}", "WINRMPASS={{ user `winrm_password_env`}}"],
      "inline": [
        "net user $Env:WINRMUSER $Env:WINRMPASS"
      ] 
    },
    {
      "type": "goss",
      "tests": [
        "C:/Users/name/Desktop/packer-build-windows-ami/goss/goss.yaml"
      ]
    }
  ]
}

Error:

==> amazon-ebs: Provisioning with Powershell...
==> amazon-ebs: Provisioning with powershell script: C:\Users\name\AppData\Local\Temp\powershell-provisioner014273411
    amazon-ebs: The command completed successfully.
    amazon-ebs:
==> amazon-ebs: Provisioning with Goss
==> amazon-ebs: Configured to run on Linux
    amazon-ebs: Creating directory: /tmp/goss
==> amazon-ebs: Provisioning step had errors: Running the cleanup provisioner, if present...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' errored after 8 minutes 33 seconds: Error creating remote directory: http response error: 401 - invalid content type

==> Wait completed after 8 minutes 33 seconds

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error creating remote directory: http response error: 401 - invalid content type

No test error details during packer build

Im running a packer build on MacOs, targeting a vSphere instance.

In my goss.yaml a deliberately misspelled a version to fail the test.

When building the template, the process fails as expected, but I'm not getting the goss output:

    vsphere-clone: goss version v0.3.9
==> vsphere-clone: Uploading goss tests...
    vsphere-clone: Creating directory: /tmp/goss
    vsphere-clone: Uploading goss/goss.yml
==> vsphere-clone: 
==> vsphere-clone: 
==> vsphere-clone: 
==> vsphere-clone: Running goss tests...
==> vsphere-clone: Running GOSS render command: cd /tmp/goss &&  /tmp/goss-0.3.9-linux-amd64    render > /tmp/goss-spec.yaml
==> vsphere-clone: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vsphere-clone: Power off VM...
==> vsphere-clone: Destroying VM...
Build 'vsphere-clone' errored after 5 minutes 26 seconds: Error running Goss: goss non-zero exit status

So I know the tests failed, but it does not tell me where or what...
I've tried use the format, format_options keys, but nothing helps..

How do I get the usual output like from the goss validate command in the packer output?

Installation instructions?

Hi there - this looks incredibly useful. I'm trying to get it to work on macOS.

I wonder if you would be willing to accept a PR that improves the README to illustrate how to get up and running?

It looks like packer needs a (platform-specific) binary of the plugin in one of several search paths: https://www.packer.io/docs/extending/plugins.html

That implies there's a platform specific build available for macOS. How're you publishing releases? Happy to try to augment that if it's simple.

Passing ENV variable to goss plugin

is there a way to set env variable in the context where the goss binary is downloaded ?
I want to set proxy env variable to let curl || wget to connect on internet

File error: open ./goss.yaml: no such file or directory

Hi,

I use the goss provisioner with the following config:

./packer.json

{
  "provisioners": [
     ...
    {
      "type": "goss",
      "tests": [
        "./build/base2.yaml"
      ]
    }
  ]
}

The goss yaml seems to be uploaded, but for some reason goss is started and falls back to the goss.yaml file.

packer output:

1516710066,,ui,say,==> stag-base2: Provisioning with Goss
1516710066,,ui,message, stag-base2: Installing Goss from%!(PACKER_COMMA) https://github.com/aelsabbahy/goss/releases/download/v0.3.2/goss-linux-amd64
1516710066,,ui,message, stag-base2: Downloading Goss to /tmp/goss-0.3.2-linux-amd64
1516710066,,ui,message, stag-base2: % Total % Received % Xferd Average Speed Time Time Time Current
1516710066,,ui,message, stag-base2: Dload Upload Total Spent Left Speed
1516710066,,ui,message, stag-base2: 100 606 0 606 0 0 606 0 --:--:-- --:--:-- --:--:-- 3482
1516710076,,ui,message, stag-base2: 100 7970k 100 7970k 0 0 885k 0 0:00:09 0:00:09 --:--:-- 688k
1516710076,,ui,message, stag-base2: goss version v0.3.2
1516710076,,ui,say,==> stag-base2: Uploading goss tests...
1516710076,,ui,message, stag-base2: Creating directory: /tmp/goss
1516710076,,ui,message, stag-base2: Uploading ./build/base2.yaml
1516710076,,ui,say,==> stag-base2: Running goss tests...
1516710076,,ui,message, stag-base2: File error: open ./goss.yaml: no such file or directory
1516710076,,ui,say,==> stag-base2: Terminating the source AWS instance...
1516710132,,ui,say,==> stag-base2: Cleaning up any extra volumes...
1516710132,,ui,say,==> stag-base2: No volumes to clean up%!(PACKER_COMMA) skipping
1516710132,,ui,say,==> stag-base2: Deleting temporary security group...
1516710132,,ui,say,==> stag-base2: Deleting temporary keypair...
1516710132,,ui,error,Build 'stag-base2' errored: Error running Goss: goss non-zero exit status
1516710132,,error-count,1

It seems to me (not familiar with go), that the --gossfile flag is never set, so goss.yaml is always assumed.

Install Documentation: additional info

In the steps for installing the plugin, it should be noted that if the plugin is placed at ~/.packer.d/plugins/packer-provisioner-goss, then it requires to also have user executable permissions. Otherwise, packer throws an error of

error initializing provisioner 'goss': fork/exec /usr/bin/packer-provisioner-goss: no such file or directory

which is easily discernable as requiring the permission change, but still absent from the install steps in the doc. I am not sure how best to word this absent step for installation, so I am opening an issue instead of a PR.

Packer is grumpy about repo name.

$ packer init ./config.pkr.hcl
Error: Invalid plugin type

  on ./config.pkr.hcl line 3, in packer:
   3:         goss = {
   4:             version = ">= 3.1.4"
   5:             source = "github.com/YaleUniversity/packer-provisioner-goss"
   6:         }

Plugin source "github.com/yaleuniversity/packer-provisioner-goss" has a type
with the prefix "packer-", which isn't allowed because it would be redundant to
name a Packer plugin with that prefix. If you are the author of this plugin,
rename it to not include the prefix.

$ packer --version
1.8.5

Plugin version 1.0.0 incompatible with Packer 1.6.0+

Using the latest Packer (1.6.0), I run into this when trying to use the Goss plugin:

$ packer --version
1.6.0

$ packer build ...
...
error initializing provisioner 'goss': Incompatible API version with plugin.
Plugin version: 4, Ours: 5

I may take a stab at fixing this myself, but wanted to open the issue first anyways.

goss should run from path instead of DownloadPath

To make it easier to use the skipInstall flag, the "installed" version of goss should just be called goss, DownloadPath should be added to PATH and goss validate should be executed without path information.

Ability to download goss cli from somewhere else rather than github.com

I've got a use case where the baseUrl needs to be different in getDownloadUrl function, we use Artifactory remote repo as proxy in between github and our environment. Could it be parameterized instead of hardcoded to be downloaded from github.com?

return fmt.Sprintf("https://github.com/goss-org/goss/releases/download/v%s/%s", p.config.Version, filename)

From end-users perspective, you just pass an arg:

Example:

  provisioner "goss" {
    goss_file     = "goss.yaml"
    retry_timeout = "5s"
    sleep         = "2s"
    tests         = ["goss.yaml"]
    goss_cli    = "https://prod.artifactory.com/artifactory"
  }

Packer throwing error while provisioning goss during cicd.

When trying to use Goss provision as below in template.json for Packer , I am getting the below error: Any thoughts / suggestions- how to fix it. TIA

Code:


{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "token": ""
  },
  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "token": "{{user `token`}}",
      "region": "us-east-1",
      "source_ami_filter": {
        "filters": {
          "virtualization-type": "hvm",
          "name": "amzn2-ami-hvm-2.0.*.1-x86_64-ebs",
          "root-device-type": "ebs"
        },
        "owners": [
          "amazon"
        ],
        "most_recent": true
      },
      "instance_type": "t2.micro",
      "ssh_username": "{{user `ssh_username`}}",
      "ami_name": "packer-example {{timestamp}}",
    "tags":{
    "Name": "nginx-ami-packer - {{timestamp}}"
    }
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "script": "nginx.sh" 
    },
    {
      "type": "goss",
      "tests": [
        "goss/goss.yaml"
      ]
    }
  ]
}

Error:

Tor-Ranopriyo-MBP13:packer-ami ranopriyoneogy$ packer build -var-file=vars.json template.json
Error: Failed to initialize build "amazon-ebs"

error initializing provisioner 'goss': Unknown provisioner goss



==> Wait completed after 375 microseconds

==> Builds finished but no artifacts were created.

binary release

Hello,

Are there any plans to bring back the binaries for new releases? This would cut down on an additional step when preparing packer stack.

Thanks!

Rename repository to support packer init

In order to use this plugin with packer init, the repository name must be packer-plugin-goss.

Further information here: https://developer.hashicorp.com/packer/docs/plugins/install-plugins#installation-guides

This will allow us to include the plugin in required_plugins like this:

packer {
  required_plugins {
    goss = {
      version = "~> 3.1"
      source  = "github.com/YaleUniversity/goss"
    }
  }
}

With the current repo name, we get the following error when running packer init:

$ packer init .
Failed getting the "github.com/yaleuniversity/goss" plugin:
1 error occurred:
        * GET https://api.github.com/repos/yaleuniversity/packer-plugin-goss/git/matching-refs/tags: 404 Not Found []

This issue should resolve and supercede #65

Need automated build for binaries

Opening for comments, not looking for PRs at this time for this Issue.

I would like to setup a github action to automatically build and deploy this project on release. In other projects, I'm using wangyoucao577/go-release-action and would like to continue using the same action but it will result in compressed binaries that would need to be uncompressed after download.

Would this cause a problem for where you are using this provisioner?

Provisioner type not found error when using packer with goss

I am using packer version 1.4.4 on windows. I have put the packer-provisioner-goss file in APPDATA/packer.d/plugins and also in the directory where packer is installed however I get this error:

  • building
    Failed to initialize build 'googlecompute': provisioner type not found: goss
    googlecompute output will be in this color.

==> Builds finished but no artifacts were created.

How can this issue be resolved.

[Feature Request] Add support for usage of required_plugins

In new packer versions it is possible to define required plugin in packer configuration file. This eliminates need to download the plugin locally and execute manual steps to download, chmod, etc. So this simplify whole process very much and allows users to keep exact dependency version directly in repositories.

When I try to use it I use following config:

packer {
  required_version = ">= 1.7.0, < 1.8"
  required_plugins {
    goss = {
      version = "= 3.1.2"
      source  = "github.com/YaleUniversity/packer-provisioner-goss"
    }
  }
}

But it fails with this error:

$ packer init --upgrade default.pkr.hcl
Error: Invalid plugin type

  on default.pkr.hcl line 43, in packer:
  43:     goss = {
  44:       version = "= 3.0.0"
  45:       source  = "github.com/YaleUniversity/packer-provisioner-goss"
  46:     }

Plugin source "github.com/yaleuniversity/packer-provisioner-goss" has a type
with the prefix "packer-", which isn't allowed because it would be redundant to
name a Packer plugin with that prefix. If you are the author of this plugin,
rename it to not include the prefix.

It looks like the repository has to be renamed in order to allow this feature to work -- source: https://www.packer.io/docs/plugins#source-addresses.

Would it be possible to rename this repository to provide this? I think when renaming github repository, also the old name is preserved and redirected to new repository so this change is not that backwards incompatible.

Here is working example by using my fork https://github.com/Lirt/packer-plugin-goss/releases/tag/v3.1.2:

packer {
    required_version = ">= 1.7.0, < 1.8"
    required_plugins {
        goss = {
        version = "= 3.1.2"
        source  = "github.com/lirt/goss"
        }
    }
}
  • Repository needs to be renamed.
  • Release artifacts must have proper naming, be zipped and have SHA256SUMS file.

Set HTTP_PROXY gets ignored for goss binary download

We are running our packer CI in an environment where you need an http_proxy to connect to the internet (or most other services for that matter)
The provisioner doesnt seem to care about the proxy being set.
Thus the download from github just fails.

==> vsphere: Provisioning with Goss
    vsphere: Installing Goss from, https://github.com/aelsabbahy/goss/releases/download/v0.3.13/goss-linux-amd64
    vsphere: Downloading Goss to /tmp/goss-0.3.13-linux-amd64
==> vsphere:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
==> vsphere:                                  Dload  Upload   Total   Spent    Left  Speed
==> vsphere:   0     0    0     0    0     0      0      0 --:--:--  0:02:10 --:--:--     0curl: (7) Failed to connect to github.com port 443: Connection timed out
==> vsphere: --2020-12-02 14:52:58--  https://github.com/aelsabbahy/goss/releases/download/v0.3.13/goss-linux-amd64
==> vsphere: Resolving github.com (github.com)... 140.82.121.4
==> vsphere: Connecting to github.com (github.com)|140.82.121.4|:443... failed: Connection timed out.
==> vsphere: Retrying.
==> vsphere:
==> vsphere: --2020-12-02 14:55:10--  (try: 2)  https://github.com/aelsabbahy/goss/releases/download/v0.3.13/goss-linux-amd64

Update plugin protocol

With the recent release of packer v1.7.0 here they state:

core: The API that the Packer core uses to communicate with community plugins has changed; maintainers of community plugins will need to upgrade their plugins in order to make them compatible with v1.7.0. An upgrade guide will be available on our guides page https://www.packer.io/guides.

When using packer v1.7.0 with the current version of this provisioner, I get the following error:

Error: Failed to initialize build "amazon-ebs"

error initializing provisioner 'goss': The protocol of this plugin (protocol
version 4 and lower) was deprecated, please use a newer version of this
plugin.Or use an older version of Packer (pre 1.7) with this plugin.

Can you update the plugin protocol?

Please re-add arm64 binaries to release

I saw that these were removed in 6a7f1a0 (#57) but we would like to use the linux arm64 binaries in some multi-arch docker images we're building. Would you be open to re-adding linux/arm64 binaries back in to the release again? ๐Ÿ™

Provision with Packer and Chef

Hey all,

To be clear I git cloned this repo, downloaded the binary and saved it as ~/.packer.d/plugins/packer-provisioner-goss with 0755 permissions.

This is a sample goss/goss.yml file, my real one looks similar obviously:

{
  "builders": [
    {
      "type": "googlecompute",
      "project_id": "foo",
      "zone": "us-west2-b",
      "machine_type": "n1-standard-2",
      "preemptible": true,
      "ssh_username": "ubuntu",
      "source_image_family": "ubuntu-1804-lts"
    }
  ],
  "provisioners": [
    {
      "type": "chef-solo",
      "version": "14.7.17",
      "cookbook_paths": [
        "cookbooks"
      ],
      "chef_environment": "myenv",
      "data_bags_path": "data_bags/myenv",
      "environments_path": "environments",
      "roles_path": "roles/myenv",
      "run_list": [
        "role[foo]"
      ]
    },
    {
      "type": "goss",
      "retry_timeout": "5m",
      "sleep": "5s",
      "tests": [
        "goss/goss.yml"
      ]
    }
  ]
}

I then run the following:

packer build

I come back with an error of:

Remote command exited with '1': chmod +x 

Any ideas? I highly appreciate it,
Montana Mendy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.