YaleUniversity / packer-plugin-goss

Goss Provisioner for Packer
MIT License
136 stars 45 forks source link

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

Closed thatsk closed 3 years ago

thatsk commented 4 years ago
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
thatsk commented 4 years ago

packer file

{
  "variables": {
    "build_number": "{{timestamp}}",
    "centos_arch": "x86_64",
    "iso_base_url": "http://mirror.cs.vt.edu/pub/CentOS",
    "iso_checksum_type": "sha256",
    "username": "root",
    "password": "J@",
    "vm-cpu-num": "4",
    "vm-mem-size": "16384",
    "vm-disk-size": "102400",
    "timeout": "60m",
    "vm-name": "{{user `nodetype` }}",
    "centos_version": "7",
    "ks_file": "centos7.cfg",
    "iso_filename": "Minimal-1908",
    "iso_checksum": "9a2c47d97b9975452f7d582264e9fc16d108ed8252ac6816239a3b58cef5c53d"
  },
"builders": [{
    "type": "vsphere-iso",
    "iso_url": "{{user `iso_base_url`}}/{{user `centos_version`}}/isos/{{user `centos_arch`}}/CentOS-{{user `centos_version`}}-{{user `centos_arch`}}-{{user `iso_filename`}}.iso",
    "iso_checksum": "{{user `iso_checksum`}}",
    "vcenter_server": "{{user `vsphere-server`}}",
    "username": "{{user `vsphere-user`}}",
    "password": "{{user `vsphere-password`}}",
    "insecure_connection": "true",
    "datacenter": "{{user `vsphere-datacenter`}}",
    "cluster": "{{user `vsphere-cluster`}}",
    "network": "{{user `vsphere-network`}}",
    "datastore": "{{user `vsphere-datastore`}}",
    "vm_name": "{{user `vm-name`}}",
    "guest_os_type": "rhel7_64Guest",
    "vm_version" : 11,

    "ssh_username": "{{user `username`}}",
    "ssh_password": "{{user `password`}}",
    "CPUs": "{{user `vm-cpu-num`}}",
    "RAM": "{{user `vm-mem-size`}}",
    "convert_to_template": true,
    "disk_size": "{{user `vm-disk-size`}}",
    "disk_thin_provisioned": true,
    "disk_controller_type": "pvscsi",
    "network_card": "vmxnet3",
    "shutdown_command": "shutdown -P now",
    "boot_wait": "10s",
    "boot_order": "cdrom,ethernet,disk",
   "iso_paths": "[{{user `vsphere-datastore`}}] ISO/{{user `centos7file`}},[{{user `vsphere-datastore`}}] ISO/kickstart.iso"
   }],
  "provisioners": [{
      "type": "shell",
      "script": "scripts/base.sh",
      "timeout": "10m"
    },
    {
      "type": "shell",
      "script": "scripts/vmware-tools.sh",
      "timeout": "10m"
    },
    {
      "type": "shell",
      "script": "scripts/cleanup.sh",
      "timeout": "10m"
    },
    {
    "type": "goss",
    "version": "0.3.2",
    "arch": "amd64",
    "url":"https://github.com/aelsabbahy/goss/releases/download/vVERSION/goss-linux-ARCH",
    "tests": [
      "goss/goss.yaml"
]
    }
 ]
 }
thatsk commented 4 years ago
root@2d3b461589cb:medium # ls -la ~/.packer.d/plugins
total 28608
drwxr-xr-x    2 root     root            37 May 29 11:30 .
drwxr-xr-x    3 root     root            73 May 29 11:24 ..
-rwxr-xr-x    1 root     root      29290720 May 29 11:30 packer-provisioner-goss
thatsk commented 4 years ago
root@2d3b461589cb:medium # ls -la
total 20
drwxr-xr-x    4 root     root           105 May 29 11:28 .
drwxr-xr-x    7 root     root            75 May 29 11:22 ..
-rw-r--r--    1 root     root           800 May 29 11:22 README.md
drwxr-xr-x    2 root     root            23 May 29 11:28 goss
-rw-r--r--    1 root     root          4462 May 29 11:22 ks.cfg
-rw-r--r--    1 root     root          3794 May 29 11:32 packer.json
drwxr-xr-x    2 root     root            98 May 29 11:22 scripts
-rw-r--r--    1 root     root           350 May 29 11:22 variables.json
thatsk commented 4 years ago
root@2d3b461589cb:medium # env
ANSIBLE_CONFIG=/root/ansible.cfg
PACKER_ZIPFILE=packer_1.5.6_linux_amd64.zip
HOSTNAME=2d3b461589cb
PYTHON_VERSION=3.9.0b1
OSARCH=amd64
TERRAFORM_VERSION=0.12.13
HISTTIMEFORMAT=%d/%m/%y %T
TERRAFORM_ZIPFILE=terraform_0.12.13_linux_amd64.zip
PWD=/root/packer/centos7/medium
OSNAME=linux
PACKER_PLUGIN_PATH=/root/.packer.d/plugins
HOME=/root
LANG=C.UTF-8
GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568
TERRAFORM_DEST=/usr/local/bin
PACKER_DEST=/usr/local/bin
TERM=xterm
SHLVL=1
PYTHON_PIP_VERSION=20.1.1
PYTHON_GET_PIP_SHA256=b3153ec0cf7b7bbf9556932aa37e4981c35dc2a2c501d70d91d2795aa532be79
PS1=\u@\h:\W \$
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/eff16c878c7fd6b688b9b4c4267695cf1a0bf01b/get-pip.py
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PACKER_VERSION=1.5.6
OLDPWD=/root/packer/centos7
_=/usr/bin/env
thatsk commented 4 years ago

let me know if i done anything wrong. Or is it not supported for vsphere-iso or vsphere-clone builder?

thatsk commented 4 years ago

does it need go binary into container ?

thatsk commented 4 years ago

i'm using alpine container as my os with by default packer installed in it

thatsk commented 4 years ago
FROM python:3.9-rc-alpine
# Env setup
ENV PACKER_VERSION=1.5.6 \
    OSNAME=linux \
    OSARCH=amd64 \
    PACKER_DEST=/usr/local/bin \
    ANSIBLE_CONFIG=/root/ansible.cfg \
    TERRAFORM_VERSION=0.12.13 \
    TERRAFORM_DEST=/usr/local/bin \
    PACKER_PLUGIN_PATH=/usr/local/packer_plugin
ENV PACKER_ZIPFILE=packer_${PACKER_VERSION}_${OSNAME}_${OSARCH}.zip
ENV TERRAFORM_ZIPFILE=terraform_${TERRAFORM_VERSION}_${OSNAME}_${OSARCH}.zip
ADD https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_ZIPFILE} ${PACKER_DEST}/
ADD https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TERRAFORM_ZIPFILE} ${TERRAFORM_DEST}/
ADD https://github.com/YaleUniversity/packer-provisioner-goss/releases/download/v1.0.0/packer-provisioner-goss-v1.0.0-linux-amd64 /usr/local
ADD bigsudo/ /root
WORKDIR /root
RUN unzip ${PACKER_DEST}/${PACKER_ZIPFILE} && mv /root/packer ${PACKER_DEST} && \
    rm -rf ${PACKER_DEST}/${PACKER_ZIPFILE} && \
    unzip ${TERRAFORM_DEST}/${TERRAFORM_ZIPFILE} && mv /root/terraform ${TERRAFORM_DEST} && \
    rm -rf ${TERRAFORM_DEST}/${TERRAFORM_ZIPFILE} && \
    mkdir -p ${PACKER_PLUGIN_PATH} && \
    mv /usr/local/packer-provisioner-goss-v1.0.0-linux-amd64 ${PACKER_PLUGIN_PATH}/packer-provisioner-goss && chmod +x ${PACKER_PLUGIN_PATH}/packer-provisioner-goss
EleanorRigby commented 4 years ago

check if you are using executable of right OS.

fishnix commented 3 years ago

Thanks @EleanorRigby. Closing old issues, reopen if still interested 👍