Closed thatsk closed 3 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"
]
}
]
}
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
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
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
let me know if i done anything wrong. Or is it not supported for vsphere-iso or vsphere-clone builder?
does it need go binary into container ?
i'm using alpine container as my os with by default packer installed in it
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
check if you are using executable of right OS.
Thanks @EleanorRigby. Closing old issues, reopen if still interested 👍
PACKER bUILD LOG:-