Vsphere_iso Centos 8 Http directory configuration

Team,

Am trying to build the image for centos 8 through Jenkins. During the Packer execution, the HTTP IP and port is getting set as . Any thoughts?

Packer version: “Packer v1.5.6”

JSON:

{	
  "variables": {	
   "vsphere_uid": "Null",	
   "vsphere_passwd": "Null",	
   "vm_superuser_passwd" : "Null",	
   "vsphere_vm_name": "Null",	
   "bastion_host": "",	
   "bastion_user": "",	
   "bastion_password":"Null",	
   "datacenter": "",	
   "cluster": "",	
   "datastore": "",	
   "network": "",	
   "iso_paths": ""	
   },	

  "builders": [	
    {	
      "type": "vsphere-iso",	

      "vcenter_server":      "{{user `vsphere_server` }}",	
      "username":            "{{user `vsphere_uid` }}",	
      "password":            "{{user `vsphere_passwd` }}",	
      "insecure_connection": "true",	
      "datacenter": "{{user `datacenter` }}",	
      "cluster": "{{user `cluster` }}",	
      "datastore": "{{user `datastore` }}",	
      "network": "{{user `network` }}",	
      "vm_name": "{{user `vsphere_vm_name` }}",	

      "guest_os_type": "centos7_64Guest",	

      "ssh_username": "admin",	
      "ssh_password": "{{user `vm_superuser_passwd` }}",	
      "ssh_bastion_host": "{{user `bastion_host` }}",	
      "ssh_bastion_username": "{{user `bastion_user` }}",	
      "ssh_bastion_agent_auth": true,	

      "CPUs":             2,	
      "RAM":              5120,	
      "RAM_reserve_all": false,	

      "convert_to_template": true,	

      "disk_controller_type":  "pvscsi",	
      "disk_size":        102400,	
      "disk_thin_provisioned": true,	
      "network_card": "vmxnet3",	
      "storage": [
         {
           "disk_size": 10000,
           "disk_thin_provisioned": true
         }
       ],
      "iso_paths": [	
        "{{user `iso_paths` }}"	
      ],	
      "iso_checksum": "13675c6f74880e7ff3481b91bdaf925ce81bda8f",	
      "iso_checksum_type": "sha1",		
      "boot_command": [
        "<esc><wait>",
        "vmlinuz initrd=initrd.img",
        "init.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks8.cfg",
        "<enter>"
     ] 
    }	
  ]	
} 

The error is

boot: vmlinuz initrd=initrd.imginit.ks=http://<no value>:<no value>/ks8.cfg
Loading vmlinuz... ok
Loading initrd.imginit.ks=http://<no...failed: No such file or directory

The packer log shows:

+ PACKER_LOG=1 packer build '-var-file=vars/centos8-vars.json' -var 'vsphere_vm_name=centos8-template-26-10-20' -var 'vsphere_uid=****' -var 'vsphere_passwd=****' -var 'vm_superuser_passwd=****' -var 'bastion_key=****' -var 'vsphere_env=idev-uat' centos8-without-harden.json 
2020/10/26 06:04:52 [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64] 
2020/10/26 06:04:52 Checking 'PACKER_CONFIG' for a config file path 
2020/10/26 06:04:52 'PACKER_CONFIG' not set; checking the default config file path 2020/10/26 06:04:52 Attempting to open config file: /root/.packerconfig 
2020/10/26 06:04:52 [WARN] Config file doesn't exist: /root/.packerconfig 
2020/10/26 06:04:52 Setting cache directory: /bms/webapps/****/workspace/team_XSE/Admin/Terraform-Vsphere/vsphere-packer/Centos-Vspher-Image-build/packer-generic/packer_cache Running in background, not using a TTY 
2020/10/26 06:04:52 Creating plugin client for path: /bin/packer 
2020/10/26 06:04:52 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-builder-vsphere-iso"} 
2020/10/26 06:04:52 Waiting for RPC address for: /bin/packer 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64] 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Checking 'PACKER_CONFIG' for a config file path 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: 'PACKER_CONFIG' not set; checking the default config file path 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Attempting to open config file: /root/.packerconfig
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: [WARN] Config file doesn't exist: /root/.packerconfig 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Setting cache directory: /bms/webapps/****/workspace/team_XSE/Admin/Terraform-Vsphere/vsphere-packer/Centos-Vspher-Image-build/packer-generic/packer_cache
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: args: []string{"packer-builder-vsphere-iso"} 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Plugin address: unix /tmp/packer-plugin605395048 
2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Waiting for connection... 
2020/10/26 06:04:52 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin605395048 2020/10/26 06:04:52 packer-builder-vsphere-iso plugin: Serving a plugin connection... 
2020/10/26 06:04:52 Build debug mode: false 
2020/10/26 06:04:52 Force build: false 
2020/10/26 06:04:52 On error: 
2020/10/26 06:04:52 Preparing build: vsphere-iso **vsphere-iso: output will be in this color.** 2020/10/26 06:04:52 Waiting on builds to complete... 
2020/10/26 06:04:52 Starting build run: vsphere-iso 
2020/10/26 06:04:52 Running builder: vsphere-iso 
2020/10/26 06:04:52 [INFO] (telemetry) Starting builder vsphere-iso **==> vsphere-iso: Creating VM...** **==> vsphere-iso: Customizing hardware...** **==> vsphere-iso: Mounting ISO images...** 
2020/10/26 06:05:02 packer-builder-vsphere-iso plugin: Creating CD-ROM on controller '&{{{} 200 0xc0003d86a0 <nil> <nil> <nil> 0 <nil>} 0 []}' with iso '[nfs_iso_100] centos/CentOS-8.2.2004-x86_64-minimal.iso' **==> vsphere-iso: Set boot order temporary...** 
2020/10/26 06:05:03 packer-builder-vsphere-iso plugin: No floppy files specified. Floppy disk will not be made. **==> vsphere-iso: Power on VM...** **==> vsphere-iso: Waiting 10s for boot...** **==> vsphere-iso: Typing boot command...** 
2020/10/26 06:05:14 packer-builder-vsphere-iso plugin: Special code '<esc>' found, replacing with: CodeEscape 
2020/10/26 06:05:15 packer-builder-vsphere-iso plugin: Waiting 1 second 
2020/10/26 06:05:32 packer-builder-vsphere-iso plugin: Special code '<enter>' found, replacing with: CodeReturnEnter **==> vsphere-iso: Waiting for IP...** 
2020/10/26 06:05:32 packer-builder-vsphere-iso plugin: [INFO] Waiting for IP, up to total timeout: 30m0s, settle timeout: 5s

Centos 7 and 6 image build is working fine from Jenkins. Anyway am not using http directory configuration there. The kickstart file is able to load using floppy there.

Where is http_directory defined?

I quote:

Packer will create an http server serving http_directory when it is set, a random free port will be selected and the architecture of the directory referenced will be available in your builder.

Hello @Wolfsrudel, Thanks for the reply. Yes i tried with the http_directory "http_directory" : "http", in the JSON and the boot commands referring the correct file (please check below).

Now getting error as No such file or directory. ks8.cfg is present under the http directory.

"boot_command": [
        "<esc><wait>",
        "vmlinuz initrd=initrd.img",
        "init.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks8.cfg",
        "<enter>"
     ] 
➜  root# ls -l centos8.json
-rw-r--r--  1 user  staff  1704 27 Oct 05:33 centos8.json
➜  root# ls -l http/ks8.cfg
-rw-r--r--  1 user  staff  1844 27 Oct 05:42 http/ks8.cfg

Is Packer throwing that error, or the VM? Can you share a few more lines of your debug log?

Hello SwampDragons, Thanks for the reply. The VM console is throwing the error, Unfortunately, am not able to attach the image of it.

+ PACKER_LOG=1 packer build '-var-file=vars/centos8-vars.json' -var 'vsphere_vm_name=centos8-template-27-10-20' -var 'vsphere_uid=****' -var 'vsphere_passwd=****' -var 'vm_superuser_passwd=****' -var 'bastion_key=****' -var 'vsphere_env=idev' centos8-without-harden.json
2020/10/27 05:43:24 [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/10/27 05:43:24 Checking 'PACKER_CONFIG' for a config file path
2020/10/27 05:43:24 'PACKER_CONFIG' not set; checking the default config file path
2020/10/27 05:43:24 Attempting to open config file: /root/.packerconfig
2020/10/27 05:43:24 [WARN] Config file doesn't exist: /root/.packerconfig
2020/10/27 05:43:24 Setting cache directory: /bms/webapps/****/workspace/team_XSE/Admin/Terraform-Vsphere/vsphere-packer/Centos-Vspher-Image-build/packer-generic/packer_cache
Running in background, not using a TTY
2020/10/27 05:43:24 Creating plugin client for path: /bin/packer
2020/10/27 05:43:24 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-builder-vsphere-iso"}
2020/10/27 05:43:24 Waiting for RPC address for: /bin/packer
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: [INFO] Packer version: 1.5.6 [go1.14.2 linux amd64]
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Checking 'PACKER_CONFIG' for a config file path
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Attempting to open config file: /root/.packerconfig
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Setting cache directory: /bms/webapps/****/workspace/team_XSE/Admin/Terraform-Vsphere/vsphere-packer/Centos-Vspher-Image-build/packer-generic/packer_cache
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: args: []string{"packer-builder-vsphere-iso"}
2020/10/27 05:43:24 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin345388987
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Plugin address: unix /tmp/packer-plugin345388987
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Waiting for connection...
2020/10/27 05:43:24 packer-builder-vsphere-iso plugin: Serving a plugin connection...
2020/10/27 05:43:24 Build debug mode: false
2020/10/27 05:43:24 Force build: false
2020/10/27 05:43:24 On error: 
2020/10/27 05:43:24 Preparing build: vsphere-iso
vsphere-iso: output will be in this color.

2020/10/27 05:43:24 Waiting on builds to complete...
2020/10/27 05:43:24 Starting build run: vsphere-iso
2020/10/27 05:43:24 Running builder: vsphere-iso
2020/10/27 05:43:24 [INFO] (telemetry) Starting builder vsphere-iso
==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mounting ISO images...
2020/10/27 05:43:34 packer-builder-vsphere-iso plugin: Creating CD-ROM on controller '&{{{} 200 0xc000428ae0 <nil> <nil> <nil> 0 <nil>} 0 []}' with iso '[nfs_iso_100] centos/CentOS-8.2.2004-x86_64-minimal.iso'
2020/10/27 05:43:35 packer-builder-vsphere-iso plugin: No floppy files specified. Floppy disk will not be made.
2020/10/27 05:43:35 packer-builder-vsphere-iso plugin: Found available port: 8476 on IP: 0.0.0.0
==> vsphere-iso: Starting HTTP server on port 8476
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: HTTP server is working at http://172.17.0.2:8476/
2020/10/27 05:43:46 packer-builder-vsphere-iso plugin: Special code '<esc>' found, replacing with: CodeEscape
==> vsphere-iso: Typing boot command...
2020/10/27 05:43:46 packer-builder-vsphere-iso plugin: Waiting 1 second
2020/10/27 05:44:02 packer-builder-vsphere-iso plugin: Special code '<enter>' found, replacing with: CodeReturnEnter
2020/10/27 05:44:02 packer-builder-vsphere-iso plugin: [INFO] Waiting for IP, up to total timeout: 30m0s, settle timeout: 5s
==> vsphere-iso: Waiting for IP...

Ok so you can see the IP etc that the http server exists at here:

==> vsphere-iso: HTTP server is working at http://172.17.0.2:8476/

My recommendation is to connect to the console and via the emergency shell verify whether you can actually connect to that server; otherwise it seems like there’s likely some kind of firewall issue you’re hitting.

Centos 7 and 6 image build is working fine from Jenkins. Anyway am not using http directory configuration there. The kickstart file is able to load using floppy there.

Is there a reason you aren’t just also using floppies for the centos8 image?

That IP looks eerily like a Docker supplied IP address. If you are running Packer from a Docker container on a build node you will probably need to supply --net=host to your docker run since the HTTP port is random and you need to have the vSphere server communicate with the HTTP server on whichever host you are running Packer from.

It is also possible but SwampDragons would know for sure, that Packer accidentally used a Docker IP instead of your host’s “real” LAN IP address if you didn’t specify a network interface that Packer should use for communicating with vSphere and listening to requests.

@espoelstra, Thanks for your response. I’ve tried using the “net=host” option in the docker and it’s able to get the host IP, anyway the results are same.

Error:

Json file:

image

Http dir in the workspace:
image

I have tried the floppy method with centos 8, anyway was facing issues while loading the file. And noticed in the following threat, they mentioned Centos 8 don’t have floppy drive so i started trying the other options and ended with the same error.

Try setting your http_directory to {template_dir}} instead of just http.

You could also try using the cd_files functionality instead of floppy or http.

Have tried this… No luck

Json:


Error:

Remove the http out of the init.ks because it’s implemented in the {{template_dir}} already.
Actually you’ve got /http/http.

Judging from the output you pasted for SwampDragons it appears the server should have been running, can you access that IP from your local machine or is it restricted to a network that only vSphere + Jenkins can communicate on?

If you ran a curl http://the.node.ip:port/ks8.cfg from your machine or Jenkins while Packer was running the http server you should be able to see if the file got linked by the http_server instance correctly.

@Wolfsrudel, @SwampDragons, @espoelstra Thanks a lot for your help to identify the issue. The issue was with the network, the http server which was holding the KS file was not reachable from the image(VM). After we set up a dedicated http server within the network, the image build is working like a charm.

1 Like