Template customization para Debian Squeeze en vSphere 5.0U1

(English version right at the bottom of the post)

Con la release de vSphere 5.0U1, Ubuntu ha vuelto a estar soportado en la lista de Guests para personalizar sus templates. Lamentablemente, Debian Squeeze se ha quedado fuera y no se pueden personalizar… O si?

Quien haya intentado personalizar una debian, puede haber llegado como mucho a esta situación:

root@debian-template:/tmp# cat /var/log/vmware-imc/toolsDeployPkg.log 
## Starting deploy pkg operation
libDeployPkg.so loaded successfully
Found DeployPkg_DeployPackageFromFile
Deploying /tmp/50096cf0/imcEC6B.tmp
Initializing deployment module. 

Cleaning old state file from tmp directory. 

EXIT STATE INPROGRESS 

Setting deploy error: Error removing lock /tmp/.vmware-deploy.INPROGRESS (No such file or directory) 

EXIT STATE Done 

Setting deploy error: Error removing lock /tmp/.vmware-deploy.Done (No such file or directory) 

EXIT STATE ERRORED 

Setting deploy error: Error removing lock /tmp/.vmware-deploy.ERRORED (No such file or directory) 

Setting deploy error: Success. 

Deploying cabinet file /tmp/50096cf0/imcEC6B.tmp. 

Transitioning from state (null) to state INPROGRESS. 

ENTER STATE INPROGRESS 

Reading cabinet file /tmp/50096cf0/imcEC6B.tmp. 

Creating directory /tmp
Creating directory /tmp/.vmware
Creating directory /tmp/.vmware/linux
Creating directory /tmp/.vmware/linux/deploy
Extracting package files. 

Launching deployment /usr/bin/perl -I/tmp/.vmware/linux/deploy/scripts /tmp/.vmware/linux/deploy/scripts/Customize.pl /tmp/.vmware/linux/deploy/cust.cfg. 

Command to exec : /usr/bin/perl 

sizeof ProcessInternal is 56

Returning, pending output
Returning, pending output
Saving output
Saving output
Saving output
Returning, pending output
Returning, pending output
Process exited normally after 0 seconds, returned 252
Saving output
Saving output
Saving output
Saving output
Saving output
No more output
No more output
Customization command output: INFO: Opening file name /tmp/.vmware/linux/deploy/cust.cfg. 
DEBUG: [NETWORK] 
DEBUG: FOUND CATEGORY = NETWORK 
DEBUG: NETWORKING = yes 
DEBUG: ADDED KEY-VAL :: NETWORK|NETWORKING = yes 
DEBUG: BOOTPROTO = dhcp 
DEBUG: ADDED KEY-VAL :: NETWORK|BOOTPROTO = dhcp 
DEBUG: HOSTNAME = NewTemplate1 
DEBUG: ADDED KEY-VAL :: NETWORK|HOSTNAME = NewTemplate1 
DEBUG: DOMAINNAME = local.domain 
DEBUG: ADDED KEY-VAL :: NETWORK|DOMAINNAME = local.domain 
DEBUG:  
DEBUG: Empty line. Ignored. 
DEBUG: [NIC-CONFIG] 
DEBUG: FOUND CATEGORY = NIC-CONFIG 
DEBUG: NICS = NIC1 
DEBUG: ADDED KEY-VAL :: NIC-CONFIG|NICS = NIC1 
DEBUG:  
DEBUG: Empty line. Ignored. 
DEBUG: [NIC1] 
DEBUG: FOUND CATEGORY = NIC1 
DEBUG: MACADDR = 00:50:56:a3:65:73 
DEBUG: ADDED KEY-VAL :: NIC1|MACADDR = 00:50:56:a3:65:73 
DEBUG: ONBOOT = yes 
DEBUG: ADDED KEY-VAL :: NIC1|ONBOOT = yes 
DEBUG: BOOTPROTO = static 
DEBUG: ADDED KEY-VAL :: NIC1|BOOTPROTO = static 
DEBUG: IPADDR = ip.nueva.de-la.vm 
DEBUG: ADDED KEY-VAL :: NIC1|IPADDR = ip.nueva.de-la.vm 
DEBUG: NETMASK = 255.255.255.0 
DEBUG: ADDED KEY-VAL :: NIC1|NETMASK = 255.255.255.0 
DEBUG: GATEWAY = ip.del.gateway 
DEBUG: ADDED KEY-VAL :: NIC1|GATEWAY = ip.del.gateway 
DEBUG:  
DEBUG: Empty line. Ignored. 
DEBUG:  
DEBUG: Empty line. Ignored. 
DEBUG: [DNS] 
DEBUG: FOUND CATEGORY = DNS 
DEBUG: DNSFROMDHCP=no 
DEBUG: ADDED KEY-VAL :: DNS|DNSFROMDHCP = no 
DEBUG: SUFFIX|1 = local.domain 
DEBUG: ADDED KEY-VAL :: DNS|SUFFIX|1 = local.domain 
DEBUG: NAMESERVER|1 = ip.del.servidor.dns1 
DEBUG: ADDED KEY-VAL :: DNS|NAMESERVER|1 = ip.del.servidor.dns1 
DEBUG: NAMESERVER|2 = ip.del.servidor.dns2 
DEBUG: ADDED KEY-VAL :: DNS|NAMESERVER|2 = ip.del.servidor.dns2 
DEBUG: NAMESERVER|3 = ip.del.servidor.dns3 
DEBUG: ADDED KEY-VAL :: DNS|NAMESERVER|3 = ip.del.servidor.dns3 
DEBUG:  
DEBUG: Empty line. Ignored. 
DEBUG: [DATETIME] 
DEBUG: FOUND CATEGORY = DATETIME 
DEBUG: TIMEZONE = Europe/Madrid 
DEBUG: ADDED KEY-VAL :: DATETIME|TIMEZONE = Europe/Madrid 
DEBUG: UTC = yes 
DEBUG: ADDED KEY-VAL :: DATETIME|UTC = yes 
DEBUG: Reading issue file ...  
DEBUG: Command: cat /etc/issue 
DEBUG: Result: Debian GNU/Linux 6.0 n l

 
DEBUG: Debian GNU/Linux 6.0 n l

 
DEBUG: Reading issue file ...  
DEBUG: Command: cat /etc/issue 
DEBUG: Result: Debian GNU/Linux 6.0 n l

 
DEBUG: Debian GNU/Linux 6.0 n l

 
DEBUG: Command: cat /etc/issue 
DEBUG: Result: Debian GNU/Linux 6.0 n l

 
INFO: Detected distribution: Debian Linux Distribution 
DEBUG: Reading issue file ...  
DEBUG: Command: cat /etc/issue 
DEBUG: Result: Debian GNU/Linux 6.0 n l

 
DEBUG: Debian GNU/Linux 6.0 n l

 
INFO: Detected distribution flavour: Debian 
DEBUG: Command: hostname 2>/dev/null 
DEBUG: Result: debian-template
 
DEBUG: Command: hostname -f 2>/dev/null 
DEBUG: Result: debian-template.local.domain
 
DEBUG: opening file /etc/hostname. 
DEBUG: Match found   : Line = debian-template
 
DEBUG: Actual String : debian-template 
INFO: OLD HOST NAME = debian-template 
INFO: Customizing Network settings ...  
INFO: Erasing DHCP leases 
DEBUG: Command: pkill dhclient 
DEBUG: Result:  
DEBUG: Command: rm -f /var/lib/dhcp/* 
DEBUG: Result:  
DEBUG: Host name is NewTemplate1 
DEBUG: opening file for writing (/etc/hostname). 
DEBUG: Command: chmod 644 /etc/hostname 
DEBUG: Result:  
INFO: Customizing NICS ...  
DEBUG: Command: modprobe pcnet32 2> /dev/null 
DEBUG: Result:  
DEBUG: Command: ifconfig eth0 2> /dev/null 
DEBUG: Result: eth0      Link encap:Ethernet  HWaddr 00:50:56:a3:65:73  
          inet addr:ip.vieja.de-la.vm  Bcast:ip.de.broadcast  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

 
INFO: Customizing NICS. { NIC1 } 
INFO: Customizing NIC NIC1 
DEBUG: Command: /sbin/ifconfig -a 
DEBUG: Result: eth0      Link encap:Ethernet  HWaddr 00:50:56:a3:65:73  
          inet addr:ip.vieja.de-la.vm  Bcast:ip.de.broadcast  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

 
INFO: NIC suffix = eth0 
INFO: Query config for ^(NIC1|IPv6ADDR|) 
INFO: Query config for ^(NIC1|IPv6NETMASK|) 
INFO: Query config for ^NIC1(|IPv6GATEWAY|) 
INFO: Configuring ipv4 route (gateway settings) for eth0. 
INFO: Configuring default route ip.del.gateway 
DEBUG: Command: mv /etc/network/interfaces /etc/network/interfaces.BeforeVMwareCustomization 
DEBUG: Result:  
DEBUG: opening file for writing (/etc/network/interfaces). 
INFO: Customizing Hosts file ...  
DEBUG: Old hostname=[debian-template] 
DEBUG: Old FQDN=[debian-template.local.domain] 
DEBUG: New hostname=[NewTemplate1] 
DEBUG: New FQDN=[NewTemplate1.local.domain] 
DEBUG: opening file /etc/hosts. 
DEBUG: Line (inp): 127.0.0.1	localhost
 
DEBUG: Line (inp): ip.vieja.de-la.vm	debian-template.local.domain	debian-template
 
DEBUG: Line (inp): 
 
DEBUG: Line (inp): # The following lines are desirable for IPv6 capable hosts
 
DEBUG: Line (inp): ::1     ip6-localhost ip6-loopback
 
DEBUG: Line (inp): fe00::0 ip6-localnet
 
DEBUG: Line (inp): ff00::0 ip6-mcastprefix
 
DEBUG: Line (inp): ff02::1 ip6-allnodes
 
DEBUG: Line (inp): ff02::2 ip6-allrouters
 
DEBUG: Static ip entry added 
DEBUG: Line (out): 127.0.0.1	localhost
 
DEBUG: Line (out): 
 
DEBUG: Line (out): # The following lines are desirable for IPv6 capable hosts
 
DEBUG: Line (out): ::1     ip6-localhost ip6-loopback
 
DEBUG: Line (out): fe00::0 ip6-localnet
 
DEBUG: Line (out): ff00::0 ip6-mcastprefix
 
DEBUG: Line (out): ff02::1 ip6-allnodes
 
DEBUG: Line (out): ff02::2 ip6-allrouters
 
DEBUG: Line (out): 
ip.nueva.de-la.vm	NewTemplate1.local.domain NewTemplate1
 
DEBUG: opening file for writing (/etc/hosts). 
DEBUG: Command: chmod 644 /etc/hosts 
DEBUG: Result:  
INFO: Customizing DNS ...  
DEBUG: opening file /etc/nsswitch.conf. 
DEBUG: opening file for writing (/etc/nsswitch.conf). 
DEBUG: Command: chmod 644 /etc/nsswitch.conf 
DEBUG: Result:  
INFO: Query config for ^(DNS|SUFFIX|) 
DEBUG: Match Found : DNS|SUFFIX|1 
DEBUG: 0 
INFO: Query config for ^(DNS|NAMESERVER|) 
DEBUG: Match Found : DNS|NAMESERVER|1 
DEBUG: 0 
DEBUG: Match Found : DNS|NAMESERVER|2 
DEBUG: 1 
DEBUG: Match Found : DNS|NAMESERVER|3 
DEBUG: 2 
DEBUG: opening file for writing (/etc/resolv.conf). 
DEBUG: Command: chmod 644 /etc/resolv.conf 
DEBUG: Result:  
INFO: Query config for ^(DNS|SUFFIX|) 
DEBUG: Match Found : DNS|SUFFIX|1 
DEBUG: 0 


Aqui FALLA estrepitosamente.

ERROR: Fatal error occoured during customization !! Customization halted. 
ERROR: Error : Could not create file /etc/dhcp3/dhclient.conf! at /tmp/.vmware/linux/deploy/scripts/Utils.pm line 475.
INFO: Return code is 252. 


Customization process returned with error. 

Deployment result = 252 

Setting generic error status in vmx. 

Transitioning from state INPROGRESS to state ERRORED. 

ENTER STATE ERRORED 

EXIT STATE INPROGRESS 

Setting deploy error: Deployment failed. The forked off process returned error code. 

Deployment failed. The forked off process returned error code. 

Wait before set enable-nics stats in vmx.

Trying to connect network interfaces, attempt 1
Got VMX response 'queryNicsSupported'
Got VMX response 'disconnected'
Got VMX response 'connected'
The network interfaces are connected on 1 second
Launching cleanup. 

Command to exec : /bin/rm 

sizeof ProcessInternal is 56

Returning, pending output
Returning, pending output
Process exited normally after 0 seconds, returned 0
No more output
No more output
Customization command output: 

Deploy error: Deployment failed. The forked off process returned error code. 

Package deploy failed in DeployPkg_DeployPackageFromFile
## Closing log

Bien. Hasta aqui llega el log de la personalización. Sin embargo, podemos ver que lo ha hecho todo bien, se ha quedado justo al final:

root@debian-template:/tmp# cat /etc/resolv.conf 
search	local.domain
nameserver	ip.del.servidor.dns1
nameserver	ip.del.servidor.dns2
nameserver	ip.del.servidor.dns3
root@debian-template:/tmp# cat /etc/hostname 
NewTemplate1root@debian-template:/tmp# cat /etc/network
network/  networks  
root@debian-template:/tmp# cat /etc/network/interfaces
iface lo inet loopback
auto lo

auto eth0
iface eth0 inet static
address ip.nueva.de-la.vm
netmask 255.255.255.0
up route add default gw ip.del.gateway

Bueno, pues si no ha encontrado /etc/dhcp3, habrá que dárselo. Adelante con el HOWTO Customize Debian guest on ESXi (vCenter 5.0U1)

Como personalizar plantillas Debian Squeeze en ESXi

1. Convertir la plantilla Debian a VM por un momento.
2. VM Settings > pestaña Options > Elegimos Ubuntu Linux (XXbit) como opción de Guest OS (una pequeña mentirijilla)
3. Arrancamos la VM y entrando como root, hacemos

ln -s /etc/dhcp /etc/dhcp3

4. Reconvertimos la VM a Template.
5. Desplegar el Guest Debian usando una personalizacion de plantilla.
6 (opcional). Cambiamos el sistema operativo a Debian linux en la maquina que acabamos de desplegar.

English version

Customizing Debian Guest Templates on ESXi 5.0U1 and vCenter/vSphere 5.0U1
1. Convert your Debian Guest Template to VM for a while
2. VM Settings > Options Tab > Choose Ubuntu Linux (XXbit) as the installed Guest OS (this is just a little lie)
3. Power on the VM and login as root to execute the following:

ln -s /etc/dhcp /etc/dhcp3

4. Convert the VM back to Template
5. Deploy your Debian Template with guest customizations without a problem.
6 (optional). Change the Guest OS setting in the options tab of the newly created VM back to Debian Linux.