Création d’un Custom ISO VMware vSphere ESXi 6
Pourquoi créer un ISO personnalisé ?
Pour déployer un maximum d’hyperviseur en une journée ? Pour ne pas perdre son temps à regarder la jauge de progression de l’installeur ? Pour s’éviter les tâches répétitives ? Ou simplement éviter les erreurs de configuration ? etc …
Dans cet article, je vais vous montrez comment créer un ISO personnalisé avec des kickstarts directement injectés dans l’iso de VMware vSphere ESXi, le tout avec un menu de boot permettant de démarrer une installation sur le kickstart désiré.
Pour ceux qui ne savent pas ce qu’est un kickstart, il s’agit d’un simple fichier texte contenant une liste d’éléments dont chacun est identifié par un mot-clé. Ce fichier permet d’automatiser l’installation et la configuration d’un système d’exploitation de type Linux.
L’avantage d’une solution comme celle-ci est d’avoir dans un seul média d’installation permettant la configuration complète de tous vos hyperviseurs. Cela permet un provisionnement rapide sans le moindre effort. (Sans faire appel aux fonctionnalités avancés comme « host profile » et donc pas besoin de licence entreprise plus)
Les prérequis :
- Une VM sous une distribution Linux
- Un média original de VMware vSphere ESXi
- Le package vmtar et mkisofs
1) Création des répertoires de base
Création de deux dossiers « vmware-original » et « vmware-modif » à la racine /
vmware-original : Répertoire permettant de stocker les ISOs originaux de VMware vSphere ESXi
vmware-modif : Répertoire permettant de stocker les fichiers ISOs personnalisés.
Création de trois dossiers « isolinux », « ks » et « working » dans /var/tmp :
isolinux : Répertoire stockant le fichier du menu de boot
ks : Répertoire stockant le(s) fichier(s) kickstart à injecter dans l’iso personnalisé.
working : Répertoire de travail stockant les fichiers temporaires pendant la construction du média personnalisé.
2) Copie du fichier ISO original VMware vSphere ESXi et affectation des droits
Téléchargez un iso de VMware vSphere ESXi 6.0 et le copier dans le répertoire « vmware-original »
Appliquez des droits 755 sur le fichier iso de vSphere ESXi
Confirmez la position des droits 755 pour le compte root avec un « ls –l »
3) Création d’un fichier de menu « isolinux.cfg »
Allez dans le répertoire /var/tmp/isolinux.
Création d’un fichier « isolinux.cfg »
Contenu du fichier isolinux.cfg :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
DEFAULT menu.c32 MENU TITLE VMware-VMvisor-Installer-6.0.0.update01-3029758 Boot Menu NOHALT 1 PROMPT 0 TIMEOUT 300 LABEL --- INSTALLATION CUSTOM VNEWS.FR--- LABEL ESX01 KERNEL mboot.c32 APPEND -c boot.cfg ks=file:///etc/vmware/weasel/ks-01.cfg MENU LABEL ESX01 LABEL ESX02 KERNEL mboot.c32 APPEND -c boot.cfg ks=file:///etc/vmware/weasel/ks-02.cfg MENU LABEL ESX02 LABEL ESX03 KERNEL mboot.c32 APPEND -c boot.cfg ks=file:///etc/vmware/weasel/ks-03.cfg MENU LABEL ESX03 LABEL ---INSTALLATION VMWARE--- LABEL install KERNEL mboot.c32 APPEND -c boot.cfg MENU LABEL VMware-VMvisor-Installer-6.0.0.update01-3029758 ^Installer LABEL hddboot LOCALBOOT 0x80 MENU LABEL ^Boot from local disk |
Enregistrez les modifications apportées au fichier isolinux.cfg sous vi (:wq!)
4) Création d’un mot de passe root encrypté pour les kickstarts
Générez un mot de passe chiffré à l’aide de la commande openssl ci-dessous.
Entrez deux fois le mot de passe en clair pour obtenir le mot de passe encrypté.
Conservez le mot de passe encrypté, il sera utilisé lors de la création des fichiers de kickstart.
5) Création des fichiers de kickstart
Allez dans le répertoire /var/temp/ks
Création des fichiers ks-xx.cfg :
Dans notre exemple 3 fichiers de kickstart et donc 3 hyperviseurs ESXi à installer: ks-01.cfg, ks-02.cfg et ks-03.cfg
Ci-dessous mon fichier KS que j’utilise souvent (à adapter en fonction des besoins de chacun) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
# +---------------------------------------------------------------------------+ # Kickstart for ESXi 6.0 # Version: 1.0 # By Philippe LIMA # +---------------------------------------------------------------------------+ #INSTALL PARAMETERS # +---------------------------------------------------------------------------+ # | Accept License agreement # +---------------------------------------------------------------------------+ accepteula # +---------------------------------------------------------------------------+ # | Disk Partitioning # | Clear all partitions in first detected disk and overwrite any VMFS # | partitions on the specified drives. # +---------------------------------------------------------------------------+ clearpart --firstdisk --overwritevmfs # +---------------------------------------------------------------------------+ # | Installation media location # | New installation on first disk and overwrite an existing VMFS datastore # +---------------------------------------------------------------------------+ install --firstdisk --overwritevmfs # +---------------------------------------------------------------------------+ # | Keyboard Locales # +---------------------------------------------------------------------------+ keyboard French # +---------------------------------------------------------------------------+ # | Root password and Authication format # | Default is shadow password enabled, MD5-based passwords enabled # | Encrypted Root Password in MD5 format # +---------------------------------------------------------------------------+ rootpw --iscrypted $1$Vb7dryyp$j3w4raXYUXdrCVVAvRGvN. # +---------------------------------------------------------------------------+ # | Set default Management Interface # | addvmportgroup set to "0" to disable the creation of default guest VM Network # | Set the network to DHCP on the first network adapter # | Exemple DHCP : network --bootproto=dhcp --device=vmnic0 # +---------------------------------------------------------------------------+ network --bootproto=static --device=vmnic0 --ip=10.10.0.101 --netmask=255.255.255.0 --gateway=10.10.0.254 --hostname=esx01.demo.local --nameserver=10.10.0.11,10.10.0.12 --addvmportgroup=0 --vlanid=0 # +---------------------------------------------------------------------------+ # | Reboot after installation # +---------------------------------------------------------------------------+ reboot --noeject # +---------------------------------------------------------------------------+ # | Specifies script to run before the kickstart configuration is evaluated # +---------------------------------------------------------------------------+ %pre --interpreter=busybox # +---------------------------------------------------------------------------+ # | Specifies script to run after ESXi is installed and before reboot # +---------------------------------------------------------------------------+ %post --interpreter=busybox --ignorefailure=true # +---------------------------------------------------------------------------+ # | Specifies script to run after ESXi installation and after first reboot # | Most of the shell command will enabled after the first reboot # +---------------------------------------------------------------------------+ %firstboot --interpreter=busybox # +---------------------------------------------------------------------------+ # | Script Variable for use in script # | Variable can only be define after the first reboot and when the full bshell # | is in place # +---------------------------------------------------------------------------+ # | Licence # +---------------------------------------------------------------------------+ license="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" # +---------------------------------------------------------------------------+ # | Vswitch # +---------------------------------------------------------------------------+ #vswitch0 - Management# port_vswitch0="256" mtu_vswitch0="1500" cdp_vswitch0="listen" uplink_vswitch0="vmnic0,vmnic4" #Policy# failback_vswitch0="yes" failure_vswitch0="link" # portid, mac, iphash, explicit balancing_vswitch0="mac" notify_vswitch0="yes" #security# forged_vswitch0="no" mac_vswitch0="no" promiscuous_vswitch0="no" #vswitch1 - Stockage1# port_vswitch1="256" mtu_vswitch1="1500" cdp_vswitch1="listen" uplink_vswitch1="vmnic1,vmnic5" #Policy# failback_vswitch1="yes" failure_vswitch1="link" balancing_vswitch1="mac" notify_vswitch1="yes" #security# forged_vswitch1="no" mac_vswitch1="no" promiscuous_vswitch1="no" #vswitch2 - VMotion # port_vswitch2="256" mtu_vswitch2="1500" cdp_vswitch2="listen" uplink_vswitch2="vmnic2,vmnic6" #Policy# failback_vswitch2="yes" failure_vswitch2="link" balancing_vswitch2="mac" notify_vswitch2="yes" #security# forged_vswitch2="no" mac_vswitch2="no" promiscuous_vswitch2="no" #vswitch3 - VM # port_vswitch3="256" mtu_vswitch3="1500" cdp_vswitch3="listen" uplink_vswitch3="vmnic3,vmnic7" #Policy# failback_vswitch3="yes" failure_vswitch3="link" balancing_vswitch3="mac" notify_vswitch3="yes" #security# forged_vswitch3="no" mac_vswitch3="no" promiscuous_vswitch3="no" #vswitch4 - Isolated # port_vswitch4="256" mtu_vswitch4="1500" cdp_vswitch4="listen" #Policy# failback_vswitch4="yes" failure_vswitch4="link" balancing_vswitch4="mac" notify_vswitch4="yes" #security# forged_vswitch4="no" mac_vswitch4="no" promiscuous_vswitch4="no" # +---------------------------------------------------------------------------+ # | Portgroup Vmotion # +---------------------------------------------------------------------------+ name_vmk_vmotion1="vmk-vmotion" vlan_vmk_vmotion1="" ip_vmk_vmotion1="10.10.20.11" ip_mask_vmotion1="255.255.255.0" mtu_vmk_vmotion1="1500" vmk_vmotion1="vmk1" # +---------------------------------------------------------------------------+ # | Portgroup stockage iSCSI # +---------------------------------------------------------------------------+ name_vmk_stockage1="vmk-stockage1" vlan_vmk_stockage1="" ip_vmk_stockage1="10.10.10.11" ip_mask_stockage1="255.255.255.0" mtu_vmk_stockage1="1500" vmk_stockage1="vmk2" vmnic_active1="vmnic1" name_vmk_stockage2="vmk-stockage2" vlan_vmk_stockage2="" ip_vmk_stockage2="10.10.10.12" ip_mask_stockage2="255.255.255.0" mtu_vmk_stockage2="1500" vmk_stockage2="vmk3" vmnic_active2="vmnic5" # +---------------------------------------------------------------------------+ # | Portgroup stockage Nfs # +---------------------------------------------------------------------------+ name_vmk_nfs1="NFS" vlan_vmk_nfs1="" ip_vmk_nfs1="10.10.30.11" ip_mask_nfs1="255.255.255.0" mtu_vmk_nfs1="9000" vmk_nfs1="vmk4" # +---------------------------------------------------------------------------+ # | Portgroup VM # +---------------------------------------------------------------------------+ name_vm1="pg_lan01" vlan_vm1="" name_vm2="pg_lan02" vlan_vm2="" # +---------------------------------------------------------------------------+ # | Portgroup isolated # +---------------------------------------------------------------------------+ name_isolated ="pg_isolated" vlan_isolated="" # +---------------------------------------------------------------------------+ # | Portgroup FaultTolerance # +---------------------------------------------------------------------------+ #name_vmk_ft1="FT" #vlan_vmk_ft1="" #ip_vmk_ft1="10.10.40.11" #ip_mask_ft1="255.255.255.0" #mtu_vmk_ft1="9000" #vmk_ft1="vmk5" # +---------------------------------------------------------------------------+ # | Portgroup Replication # +---------------------------------------------------------------------------+ #name_vmk_rep1="REP" #vlan_vmk_rep1="" #ip_vmk_rep1="10.10.50.11" #ip_mask_rep1="255.255.255.0" #mtu_vmk_rep1="9000" #vmk_rep1="vmk6" # +---------------------------------------------------------------------------+ # | VMkernel routes # +---------------------------------------------------------------------------+ #ip_vmk_subnet="255.255.255.0" #ip_vmk_gw="10.10.0.x" # +---------------------------------------------------------------------------+ # IPv6 for VMkernel interfaces 1=enable, 0=Disable | false=disable or true=enable # +---------------------------------------------------------------------------+ enable_ipv6="0" enable1_ipv6="false" # +---------------------------------------------------------------------------+ # | San Server # +---------------------------------------------------------------------------+ ip_san1="10.10.10.1" #ip_san2="10.10.10.X" port_san="3260" alias_iscsi="esxi01" #chap_user="" #chap_password="" # +---------------------------------------------------------------------------+ # | Nfs Server # +---------------------------------------------------------------------------+ #ip_nfs1="10.10.30.1" #share_nfs1="/vol/share" #datastore_nfs1="Vol_NFS" # +---------------------------------------------------------------------------+ # | Storage Array Type Plug-In (SATP) # +---------------------------------------------------------------------------+ #VMW_SATP_EQL / VMW_SATP_MSA / VMW_SATP_ALUA / VMW_SATP_DEFAULT_AP / VMW_SATP_SVC #VMW_SATP_INV / VMW_SATP_EVA / VMW_SATP_ALUA_CX / VMW_SATP_SYMM / VMW_SATP_CX #VMW_SATP_LSI / VMW_SATP_DEFAULT_AA / VMW_SATP_LOCAL psa_stap1="VMW_SATP_EQL" psa_stap2="" # +---------------------------------------------------------------------------+ # | Path Selection Plug-in (PSP) # +---------------------------------------------------------------------------+ #VMW_PSP_MRU Most Recently Used Path Selection #VMW_PSP_RR Round Robin Path Selection #VMW_PSP_FIXED Fixed Path Selection psa_psp1="VMW_PSP_RR" psa_psp2="" # +---------------------------------------------------------------------------+ # | Ntp Server # +---------------------------------------------------------------------------+ ip_srv_ntp="ntp.demo.local" ip_srv_ntp1="0.vmware.pool.ntp.org" ip_srv_ntp2="1.vmware.pool.ntp.org" # +---------------------------------------------------------------------------+ # | Firewall # +---------------------------------------------------------------------------+ FIREWALL_SERVICES="syslog sshClient ntpClient updateManager httpClient netdump" # +---------------------------------------------------------------------------+ # | SNMP # +---------------------------------------------------------------------------+ #snmp_enable="true" #snmp_communities="public" #snmp_port="161" #snmp_target="10.10.0.xx/public" # +---------------------------------------------------------------------------+ # | Syslog # +---------------------------------------------------------------------------+ syslog_loghost="vcenter.demo.local" syslog_port_udp="514" syslog_port_ssl="1514" syslog_port_tcp="514" # +---------------------------------------------------------------------------+ # | maintenance mode # +---------------------------------------------------------------------------+ maitenance_enable="true" # +---------------------------------------------------------------------------+ # | Enable HV (Hardware Virtualization to run nested 64bit Guests + Hyper-V VM) # +---------------------------------------------------------------------------+ #grep -i "vhv.enable" /etc/vmware/config || echo "vhv.enable = \"TRUE\"" >> /etc/vmware/config # +---------------------------------------------------------------------------+ # | Enable & Start remote ESXi Shell (SSH) # | Enable & Start ESXi Local Shell (TSM) # +---------------------------------------------------------------------------+ vim-cmd hostsvc/enable_ssh vim-cmd hostsvc/start_ssh vim-cmd hostsvc/enable_esx_shell vim-cmd hostsvc/start_esx_shell # +---------------------------------------------------------------------------+ # Suppress Shell Warning in Host # +---------------------------------------------------------------------------+ esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1 # +---------------------------------------------------------------------------+ # Idle time before disconnect local and remote CLI # +---------------------------------------------------------------------------+ esxcli system settings advanced set -o /UserVars/ESXiShellTimeOut -i 1 # +---------------------------------------------------------------------------+ # Idle time before disconnect interactive ESXi Shell session # +---------------------------------------------------------------------------+ esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600 # +---------------------------------------------------------------------------+ # Change the default ESXi Admins group "ESX Admins" to a custom one "Demo Admins" for AD # +---------------------------------------------------------------------------+ #vim-cmd hostsvc/advopt/update Config.HostAgent.plugins.hostsvc.esxAdminsGroup string "Demo Admins" # +---------------------------------------------------------------------------+ # Users that will have full access to DCUI even if they don't have admin permssions on ESXi host # +---------------------------------------------------------------------------+ #vim-cmd hostsvc/advopt/update DCUI.Access string root,philippe # +---------------------------------------------------------------------------+ # Block VM guest BPDU packets, global configuration # +---------------------------------------------------------------------------+ esxcli system settings advanced set -o /Net/BlockGuestBPDU -i 1 # +---------------------------------------------------------------------------+ # copy SSH authorized keys & overwrite existing # +---------------------------------------------------------------------------+ #wget http://xxxx.xxx.xxx/esxi6/id_dsa.pub -O /etc/ssh/keys-root/authorized_keys # +---------------------------------------------------------------------------+ # disable SSH keys - uncomment the next section # +---------------------------------------------------------------------------+ # sed -i 's/AuthorizedKeysFile*/#AuthorizedKeysFile/g' /etc/ssh/sshd_config ##-------------------------------------------------------------------------- ## Create SSH Banner ##-------------------------------------------------------------------------- /bin/cat > /etc/banner.new <<SSHEOF ${INDENTATION:-}DEMO.LOCAL PHILIPPE LIMA ${INDENTATION:-}ESXi 6.0 ${INDENTATION:-}========================================= ${INDENTATION:-}WARNING: UNAUTHORIZED USE IS PROHIBITED ${INDENTATION:-}----------------------------------------- ${INDENTATION:-}Property of NWare, and should only ${INDENTATION:-}be accessed by authorized NWare employees. ${INDENTATION:-}Do not attempt to login unless you are an ${INDENTATION:-}authorized user. ${INDENTATION:-}Any authorized or unauthorized access and use, ${INDENTATION:-}will be monitored and anyone using this system ${INDENTATION:-}expressly consents to such monitoring. If such ${INDENTATION:-}monitoring reveals possible envidence of criminal ${INDENTATION:-}activity, such evidence will be provided to law ${INDENTATION:-}enforcement personnel and can result in criminal ${INDENTATION:-}or civil prosecution. ${INDENTATION:-}----------------------------------------- SSHEOF # +---------------------------------------------------------------------------+ # copy new banner file to overwrite /etc/issue # +---------------------------------------------------------------------------+ cp /etc/banner.new /etc/issue # +---------------------------------------------------------------------------+ # | Rename local datastore # +---------------------------------------------------------------------------+ vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)-local" # +---------------------------------------------------------------------------+ # | Assign License # +---------------------------------------------------------------------------+ vim-cmd vimsvc/license --set ${license} ######################################################################### ## vSwitch configuration ## ######################################################################### # +---------------------------------------------------------------------------+ # | Create vSwitchs # +---------------------------------------------------------------------------+ esxcli network vswitch standard add --ports ${port_vswitch0} --vswitch-name vSwitch0 esxcli network vswitch standard add --ports ${port_vswitch1} --vswitch-name vSwitch1 esxcli network vswitch standard add --ports ${port_vswitch2} --vswitch-name vSwitch2 esxcli network vswitch standard add --ports ${port_vswitch3} --vswitch-name vSwitch3 esxcli network vswitch standard add --ports ${port_vswitch4} --vswitch-name vSwitch4 # +---------------------------------------------------------------------------+ # | Config MTU in vSwitchs # +---------------------------------------------------------------------------+ esxcli network vswitch standard set --mtu ${mtu_vswitch0} --vswitch-name vSwitch0 esxcli network vswitch standard set --mtu ${mtu_vswitch1} --vswitch-name vSwitch1 esxcli network vswitch standard set --mtu ${mtu_vswitch2} --vswitch-name vSwitch2 esxcli network vswitch standard set --mtu ${mtu_vswitch3} --vswitch-name vSwitch3 esxcli network vswitch standard set --mtu ${mtu_vswitch4} --vswitch-name vSwitch4 # +---------------------------------------------------------------------------+ # | Config CDP in vSwitchs # +---------------------------------------------------------------------------+ #esxcli network vswitch standard set --cdp-status ${cdp_vswitch1} --vswitch-name vSwitch1 #esxcli network vswitch standard set --cdp-status ${cdp_vswitch1} --vswitch-name vSwitch1 # +---------------------------------------------------------------------------+ # | Link vmnics in vSwitchs # +---------------------------------------------------------------------------+ esxcli network vswitch standard uplink add --uplink-name vmnic0 --vswitch-name vSwitch0 esxcli network vswitch standard uplink add --uplink-name vmnic4 --vswitch-name vSwitch0 esxcli network vswitch standard uplink add --uplink-name vmnic1 --vswitch-name vSwitch1 esxcli network vswitch standard uplink add --uplink-name vmnic5 --vswitch-name vSwitch1 esxcli network vswitch standard uplink add --uplink-name vmnic2 --vswitch-name vSwitch2 esxcli network vswitch standard uplink add --uplink-name vmnic6 --vswitch-name vSwitch2 esxcli network vswitch standard uplink add --uplink-name vmnic3 --vswitch-name vSwitch3 esxcli network vswitch standard uplink add --uplink-name vmnic7 --vswitch-name vSwitch3 # +---------------------------------------------------------------------------+ # | Create PortsGroups in vSwitchs # +---------------------------------------------------------------------------+ esxcli network vswitch standard portgroup add --portgroup-name ${name_vmk_stockage1} --vswitch-name vSwitch1 esxcli network vswitch standard portgroup add --portgroup-name ${name_vmk_stockage2} --vswitch-name vSwitch1 esxcli network vswitch standard portgroup add --portgroup-name ${name_vmk_vmotion1} --vswitch-name vSwitch2 esxcli network vswitch standard portgroup add --portgroup-name ${name_vm1} --vswitch-name vSwitch3 esxcli network vswitch standard portgroup add --portgroup-name ${name_vm2} --vswitch-name vSwitch3 esxcli network vswitch standard portgroup add --portgroup-name ${name_isolated} --vswitch-name vSwitch4 # +---------------------------------------------------------------------------+ # | Config Vlans in PortGroups # +---------------------------------------------------------------------------+ # esxcli network vswitch standard portgroup set --portgroup-name ${name_vmk_stockage1} --vlan-id ${vlan_vmk_stockage1} # esxcli network vswitch standard portgroup set --portgroup-name ${name_vmk_stockage2} --vlan-id ${vlan_vmk_stockage2} # esxcli network vswitch standard portgroup set --portgroup-name ${name_vmk_vmotion1} --vlan-id ${vlan_vmk_vmotion1} # esxcli network vswitch standard portgroup set --portgroup-name ${name_vmk_vmotion2} --vlan-id ${vlan_vmk_vmotion2} # esxcli network vswitch standard portgroup set --portgroup-name ${name_vm1} --vlan-id ${vlan_vm1} # esxcli network vswitch standard portgroup set --portgroup-name ${name_vm2} --vlan-id ${vlan_vm2} # esxcli network vswitch standard portgroup set --portgroup-name ${name_isolated} --vlan-id ${vlan_isolated} # +---------------------------------------------------------------------------+ # | Tunning NIC policies in vSwitchs # +---------------------------------------------------------------------------+ ## Configure active and standby uplinks for vSwitchX # Exemple : esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic1 --standby-uplinks vmnic2 --vswitch-name vSwitch0 esxcli network vswitch standard policy failover set --active-uplinks ${uplink_vswitch0} --vswitch-name vSwitch0 esxcli network vswitch standard policy failover set --active-uplinks ${uplink_vswitch1} --vswitch-name vSwitch1 esxcli network vswitch standard policy failover set --active-uplinks ${uplink_vswitch2} --vswitch-name vSwitch2 esxcli network vswitch standard policy failover set --active-uplinks ${uplink_vswitch3} --vswitch-name vSwitch3 ## Configure failure detection + load balancing for vSwitchX # Exemple : esxcli network vswitch standard policy failover set --failback no --failure-detection link --load-balancing mac --notify-switches no --vswitch-name vSwitch1 # esxcli network vswitch standard policy failover set --failback yes --failure-detection beacon --load-balancing portid --notify-switches yes --vswitch-name vSwitch0 # --load-balancing [portid, iphash, mac, explicit] esxcli network vswitch standard policy failover set --failback ${failback_vswitch0} --failure-detection ${failure_vswitch0} --load-balancing ${balancing_vswitch0} --notify-switches ${notify_vswitch0} --vswitch-name vSwitch0 esxcli network vswitch standard policy failover set --failback ${failback_vswitch1} --failure-detection ${failure_vswitch1} --load-balancing ${balancing_vswitch1} --notify-switches ${notify_vswitch1} --vswitch-name vSwitch1 esxcli network vswitch standard policy failover set --failback ${failback_vswitch2} --failure-detection ${failure_vswitch2} --load-balancing ${balancing_vswitch2} --notify-switches ${notify_vswitch2} --vswitch-name vSwitch2 esxcli network vswitch standard policy failover set --failback ${failback_vswitch3} --failure-detection ${failure_vswitch3} --load-balancing ${balancing_vswitch3} --notify-switches ${notify_vswitch3} --vswitch-name vSwitch3 esxcli network vswitch standard policy failover set --failback ${failback_vswitch4} --failure-detection ${failure_vswitch4} --load-balancing ${balancing_vswitch4} --notify-switches ${notify_vswitch4} --vswitch-name vSwitch4 ## Configure security for vSwitchX # Exemple: esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change no --allow-promiscuous no --vswitch-name vSwitch0 # esxcli network vswitch standard policy security set --allow-forged-transmits no --allow-mac-change no --allow-promiscuous no --vswitch-name vSwitch1 esxcli network vswitch standard policy security set --allow-forged-transmits ${forged_vswitch0} --allow-mac-change ${mac_vswitch0} --allow-promiscuous ${promiscuous_vswitch0} --vswitch-name vSwitch0 esxcli network vswitch standard policy security set --allow-forged-transmits ${forged_vswitch1} --allow-mac-change ${mac_vswitch1} --allow-promiscuous ${promiscuous_vswitch1} --vswitch-name vSwitch1 esxcli network vswitch standard policy security set --allow-forged-transmits ${forged_vswitch2} --allow-mac-change ${mac_vswitch2} --allow-promiscuous ${promiscuous_vswitch2} --vswitch-name vSwitch2 esxcli network vswitch standard policy security set --allow-forged-transmits ${forged_vswitch3} --allow-mac-change ${mac_vswitch3} --allow-promiscuous ${promiscuous_vswitch3} --vswitch-name vSwitch3 esxcli network vswitch standard policy security set --allow-forged-transmits ${forged_vswitch4} --allow-mac-change ${mac_vswitch4} --allow-promiscuous ${promiscuous_vswitch4} --vswitch-name vSwitch4 ## Configure Shaping for vSwitchX #esxcli network vswitch standard policy shaping set --enabled ${shaping_vswitch0} --avg-bandwidth ${avg_vswitch0} --peak-bandwidth ${peak_vswitch0} --burst-size ${burst_vswitch0} --vswitch-name vSwitch0 #esxcli network vswitch standard policy shaping set --enabled ${shaping_vswitch1} --avg-bandwidth ${avg_vswitch1} --peak-bandwidth ${peak_vswitch1} --burst-size ${burst_vswitch1} --vswitch-name vSwitch1 #esxcli network vswitch standard policy shaping set --enabled ${shaping_vswitch2} --avg-bandwidth ${avg_vswitch2} --peak-bandwidth ${peak_vswitch2} --burst-size ${burst_vswitch2} --vswitch-name vSwitch2 #esxcli network vswitch standard policy shaping set --enabled ${shaping_vswitch3} --avg-bandwidth ${avg_vswitch3} --peak-bandwidth ${peak_vswitch3} --burst-size ${burst_vswitch3} --vswitch-name vSwitch3 #esxcli network vswitch standard policy shaping set --enabled ${shaping_vswitch4} --avg-bandwidth ${avg_vswitch4} --peak-bandwidth ${peak_vswitch4} --burst-size ${burst_vswitch4} --vswitch-name vSwitch4 # +---------------------------------------------------------------------------+ # | Setting vmkernel(s) # +---------------------------------------------------------------------------+ ## Create vmkernel Vmotion # Exemple: esxcli network ip interface add --interface-name vmk1 --portgroup-name vmk-vmotion esxcli network ip interface add --interface-name ${vmk_vmotion1} --mtu ${mtu_vmk_vmotion1} --portgroup-name ${name_vmk_vmotion1} esxcli network ip interface ipv4 set --interface-name ${vmk_vmotion1} --ipv4 ${ip_vmk_vmotion1} --netmask ${ip_mask_vmotion1} --type static /usr/bin/vim-cmd internalsvc/refresh_network #esxcli network ip interface add --interface-name ${vmk_vmotion2} --mtu ${mtu_vmk_vmotion2} --portgroup-name ${name_vmk_vmotion2} #esxcli network ip interface ipv4 set --interface-name ${vmk_vmotion2} --ipv4 ${ip_vmk_vmotion2} --netmask ${ip_mask_vmotion2} --type static # /usr/bin/vmware-vim-cmd internalsvc/refresh_network ## Create vmkernel Storage Iscsi esxcli network ip interface add --interface-name ${vmk_stockage1} --mtu ${mtu_vmk_stockage1} --portgroup-name ${name_vmk_stockage1} esxcli network ip interface ipv4 set --interface-name ${vmk_stockage1} --ipv4 ${ip_vmk_stockage1} --netmask ${ip_mask_stockage1} --type static /usr/bin/vim-cmd internalsvc/refresh_network esxcli network ip interface add --interface-name ${vmk_stockage2} --mtu ${mtu_vmk_stockage2} --portgroup-name ${name_vmk_stockage2} esxcli network ip interface ipv4 set --interface-name ${vmk_stockage2} --ipv4 ${ip_vmk_stockage2} --netmask ${ip_mask_stockage2} --type static /usr/bin/vim-cmd internalsvc/refresh_network ## Create vmkernel Storage NFS # esxcli network ip interface add --interface-name ${vmk_nfs1} --mtu ${mtu_vmk_nfs1} --portgroup-name ${name_vmk_nfs1} # esxcli network ip interface ipv4 set --interface-name ${vmk_nfs1} --ipv4 ${ip_vmk_nfs1} --netmask ${ip_mask_nfs1} --type static # /usr/bin/vim-cmd internalsvc/refresh_network ## Create vmkernel FaultTolerance # Exemple: esxcli network ip interface add --interface-name vmk6 --portgroup-name FT #esxcli network ip interface add --interface-name ${vmk_ft1} --mtu ${mtu_vmk_ft1} --portgroup-name ${name_vmk_ft1} #esxcli network ip interface ipv4 set --interface-name ${vmk_ft1} --ipv4 ${ip_vmk_ft1} --netmask ${ip_mask_ft1} --type static # /usr/bin/vim-cmd internalsvc/refresh_network ## Create vmkernel Replication # Exemple: esxcli network ip interface add --interface-name vmk6 --portgroup-name vmk-replication #esxcli network ip interface add --interface-name ${vmk_rep1} --mtu ${mtu_vmk_rep1} --portgroup-name ${name_vmk_rep1} #esxcli network ip interface ipv4 set --interface-name ${vmk_rep1} --ipv4 ${ip_vmk_rep1} --netmask ${ip_mask_rep1} --type static # /usr/bin/vim-cmd internalsvc/refresh_network # +---------------------------------------------------------------------------+ # Configure VMkernel traffic type (Management, VMotion, faultToleranceLogging, vSphereReplication) # +---------------------------------------------------------------------------+ esxcli network ip interface tag add -i vmk0 -t Management esxcli network ip interface tag add -i vmk1 -t VMotion #esxcli network ip interface tag add -i vmk2 -t VMotion #esxcli network ip interface tag add -i vmk5 -t faultToleranceLogging #esxcli network ip interface tag add -i vmk6 -t vSphereReplication # +---------------------------------------------------------------------------+ # Configure VMkernel routes # +---------------------------------------------------------------------------+ #esxcli network ip route ipv4 add -n ${ip_vmk_subnet} -g ${ip_vmk_gw} # +---------------------------------------------------------------------------+ # | Setting iSCSI # +---------------------------------------------------------------------------+ ## Enable software iSCSI on the ESXi host esxcli iscsi software set --enabled=true ## Show adapter list esxcli iscsi adapter list ## Value vmhba vmhba=$(esxcli iscsi adapter list | grep -i iscsi_vmk | cut -d ' ' -f 1) ## Set manual override fail-over policy so each iSCSI VMkernel portgroup had one active physical vmnic esxcli network vswitch standard portgroup policy failover set -p ${name_vmk_stockage1} -a ${vmnic_active1} /usr/bin/vim-cmd internalsvc/refresh_network esxcli network vswitch standard portgroup policy failover set -p ${name_vmk_stockage2} -a ${vmnic_active2} /usr/bin/vim-cmd internalsvc/refresh_network ## Configure Multipathing # # Bond each of the VMkernel NICs to the software iSCSI HBA esxcli iscsi networkportal add -A ${vmhba} -n ${vmk_stockage1} /usr/bin/vim-cmd internalsvc/refresh_network esxcli iscsi networkportal add -A ${vmhba} -n ${vmk_stockage2} /usr/bin/vim-cmd internalsvc/refresh_network ## Setting iSCSI name esxcli iscsi adapter set --adapter=${vmhba} --name=iqn.1998-01.com.vmware:${alias_iscsi} echo InitiatorName=iqn.1998-01.com.vmware:${alias_iscsi} > /etc/vmware/vmkiscsid/initiatorname.iscsi ## Setting iscsi Dynamic Target (Group IP Adresse) esxcli iscsi adapter discovery sendtarget add --address=${ip_san1}:${port_san} --adapter=${vmhba} #esxcli iscsi adapter discovery sendtarget add --address=${ip_san2}:${port_san} --adapter=${vmhba} ## Setting iscsi Static Target (Group IP Adresse) #esxcli iscsi adapter discovery statictarget add --address=${ip_san1}:${port_san} --adapter=${vmhba} #esxcli iscsi adapter discovery statictarget add --address=${ip_san2}:${port_san} --adapter=${vmhba} ## Setting CHAP iscsi #esxcli iscsi adapter discovery sendtarget auth chap set --adapter=${vmhba} --address=${ip_san1} -l required -N ${chap_user} -S ${chap_password} #esxcli iscsi adapter discovery sendtarget auth chap set --adapter=${vmhba} --address=${ip_san2} -l required -N ${chap_user} -S ${chap_password} ## Perform rediscovery and rescan all storage devices esxcli iscsi adapter discovery rediscover esxcli storage core adapter rescan --adapter ${vmhba} # +---------------------------------------------------------------------------+ # | Setting NFS # +---------------------------------------------------------------------------+ ## MOUNT NFS DATASTORE ## setting NFS Read-write #esxcli storage nfs add --host=${ip_nfs} --share=${share_nfs} --volume-name=${datastore_nfs1} ## setting NFS Read only # esxcli storage nfs add --host=${ip_nfs} --readonly --share=${share_nfs} --volume-name=${datastore_nfs1} ## Advanced Configuration Tunning NFS Netapp #esxcli system settings advanced set --option /Net/TcpipHeapSize --int-value 32 #esxcli system settings advanced set --option /Net/TcpipHeapMax --int-value 512 #esxcli system settings advanced set --option /NFS/HeartbeatMaxFailures --int-value 10 #esxcli system settings advanced set --option /NFS/HeartbeatFrequency --int-value 12 #esxcli system settings advanced set --option /NFS/HeartbeatTimeout --int-value 10 #esxcli system settings advanced set --option /NFS/MaxVolumes --int-value 256 # +---------------------------------------------------------------------------+ # | Setting Round Robin to correct SATP hardware EQUALOGIC # +---------------------------------------------------------------------------+ # esxcli storage nmp satp set --satp VMW_SATP_SYMM --default-psp VMW_PSP_RR # esxcli storage nmp satp set --satp VMW_SATP_DEFAULT_AA --default-psp VMW_PSP_RR esxcli storage nmp satp set --satp ${psa_stap1} --default-psp ${psa_psp1} esxcli storage core claimrule load esxcli storage core claimrule run ## Set PSP Round Robin (RR) for all EQL devices and set the IOPs value to 3 # -d = Device to set round robin properties # -I = Number of I/O operations to send along one path for this device before the PSP switches to the next path # -t = Type of round robin path switching to enable for this device. (bytes, default, iops) EQL_DEVICES=$(esxcli storage nmp device list | grep 'EQLOGIC iSCSI Disk' | awk {'print $NF'} | sed -e 's/[()]//g') for i in ${EQL_DEVICES}; do esxcli storage nmp device set -d $i -P ${psa_psp1}; esxcli storage nmp psp roundrobin deviceconfig set -d $i -t iops -I 3 ; done; # Ajout d'une nouvelle regle SATP avec un LoadBalancing en RoundRobin repartit avec 1 iops sur chaque chemin # Par défaut repartion de 1000 iops par chemin # esxcli storage nmp satp rule add -s “SATP_DEMO” -V “Vendor/Model” -M “ModelDEMO” -P “VMW_PSP_RR” -O “iops=1" # esxcli storage nmp satp rule add -s ${psa_stap1} -V “EQLOGIC” -M “PS4100” -P ${psa_psp1} -O “iops=3" # +---------------------------------------------------------------------------+ # | Setting Round Robin to correct SATP hardware NIMBLE # +---------------------------------------------------------------------------+ # esxcli storage nmp satp set --satp VMW_SATP_SYMM --default-psp VMW_PSP_RR # esxcli storage nmp satp set --satp VMW_SATP_DEFAULT_AA --default-psp VMW_PSP_RR # esxcli storage nmp satp set --satp ${psa_stap2} --default-psp ${psa_psp2} # esxcli storage core claimrule load # esxcli storage core claimrule run ## Set PSP Round Robin (RR) for all NIMBLE devices and set the IOPs value to 0 # -d = Device to set round robin properties # -I = Number of I/O operations to send along one path for this device before the PSP switches to the next path # -t = Type of round robin path switching to enable for this device. (bytes, default, iops) # NIMBLE_DEVICES=$(esxcli storage nmp device list | grep 'Nimble iSCSI Disk' | awk {'print $NF'}| sed -e 's/[()]//g') # for i in ${NIMBLE_DEVICES}; do # esxcli storage nmp device set -d $i -P ${psa_psp2}; # esxcli storage nmp psp roundrobin deviceconfig set -d $i -t bytes -B 0; # esxcli storage nmp psp roundrobin deviceconfig set -d $i -t iops -I 0 ; # done; # Ajout d'une nouvelle regle SATP avec un LoadBalancing en RoundRobin repartit avec 1 iops sur chaque chemin # Par défaut repartion de 1000 iops par chemin # esxcli storage nmp satp rule add -s “SATP_DEMO” -V “Vendor/Model” -M “ModelDEMO” -P “VMW_PSP_RR” -O “iops=1" # esxcli storage nmp satp rule add -s ${psa_stap2} -V “Nimble” -M “CSxxxx” -P ${psa_psp2} -O “iops=0" # +---------------------------------------------------------------------------+ # | NTP Configuration # | No ESXCLI command exists for adding and starting an NTP server # +---------------------------------------------------------------------------+ cat > /etc/ntp.conf << _NTP_CONFIG_ restrict default kod nomodify notrap noquerynopeer restrict 127.0.0.1 server ${ip_srv_ntp} server ${ip_srv_ntp1} server ${ip_srv_ntp2} _NTP_CONFIG_ /sbin/chkconfig ntpd on # +---------------------------------------------------------------------------+ # | FIREWALL Configuration # +---------------------------------------------------------------------------+ # enable firewall esxcli network firewall set --default-action false --enabled yes # Services Firewall to enable by default #FIREWALL_SERVICES="syslog sshClient ntpClient updateManager httpClient netdump" for SERVICE in ${FIREWALL_SERVICES} do esxcli network firewall ruleset set --ruleset-id ${SERVICE} --enabled yes done # +---------------------------------------------------------------------------+ # | Configuration Hosts file /etc/hosts # +---------------------------------------------------------------------------+ #cat >> /etc/hosts << __HOSTS__ #10.10.0.101 esx01.demo.local esx01 #10.10.0.102 esx02.demo.local esx02 #10.10.0.103 esx03.demo.local esx03 #__HOSTS__ # +---------------------------------------------------------------------------+ # | SNMP Configuration # +---------------------------------------------------------------------------+ #cat > /etc/vmware/snmp.xml << __SNMP__ #<config><snmpSettings><enable>${snmp_enable}</enable><communities>${snmp_communities}</communities><port>${snmp_port}</port><targets>${snmp_target}</targets></snmpSettings></config> #__SNMP__ # +---------------------------------------------------------------------------+ # | Syslog Configuration # +---------------------------------------------------------------------------+ # Send log to the remote host # The logs will use the default transport (UDP) and port (514) #esxcli system syslog config set --default-rotate=20 --default-size=2048 --loghost ${syslog_loghost} # Choose the remote host and protocol #esxcli system syslog config set --default-rotate 20 --default-size=2048 --loghost tcp://${syslog_loghost}:${syslog_port_tcp},udp://${syslog_loghost}:${syslog_port_udp},ssl://${syslog_loghost}:${syslog_port_ssl} # Save the local copy of logs to /scratch/logs and send another copy to the remote host. #esxcli system syslog config set --logdir='/scratch/logs' --loghost tcp://${syslog_loghost}:${syslog_port_tcp} ##### Change the individual syslog rotation count ##### #esxcli system syslog config logger set --id=hostd --rotate=20 --size=2048 #esxcli system syslog config logger set --id=vmkernel --rotate=20 --size=2048 #esxcli system syslog config logger set --id=fdm --rotate=20 --size=2048 #esxcli system syslog config logger set --id=vpxa --rotate=20 --size=2048 ##### Change host syslog (vcenter with syslog collector or Log Insight) ##### #esxcli system syslog config set --loghost='tcp://10.10.0.100:514' #esxcli system syslog config set --loghost='udp://10.10.0.100:514' #esxcli system syslog config set --loghost='ssl://10.10.0.100:1514' #esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true #esxcli network firewall refresh # +---------------------------------------------------------------------------+ # | Disabling Delayed ACK # | To disable delayed_ack = 0 # | To enable delayed_ack = 1 # +---------------------------------------------------------------------------+ #vmhba=$(esxcli iscsi adapter list | grep -i iscsi_vmk | cut -d ' ' -f 1) #vmkiscsi-tool -W -a delayed_ack=0 -j $vmhba #vmkiscsi-tool -W -a delayed_ack=0 -j vmhbaXX #vmkiscsi-tool -W -a delayed_ack=1 -j vmhbaXX #Check parameters #vmkiscsi-tool -W vmhbaXX # +---------------------------------------------------------------------------+ # | Disabling Large receive offload (LRO) # | LRO works in a similar way to Delayed ACK, by aggregating packets into a buffer before the received data is sent to the TCP stack. # | With iSCSI storage this inserts latency into the process, potentially reducing performance # | LRO value 0 (disabled) / LRO value 1 (enable) # | server reboot is required # +---------------------------------------------------------------------------+ #esxcfg-advcfg -s 0 /Net/TcpipDefLROEnabled # or #esxcli system settings advanced set -o /Net/UseHwTSO -i 1 #esxcli system settings advanced set -o /Net/UseHwTSO -i 0 # +---------------------------------------------------------------------------+ # | backup ESXi configuration to persist changes # +---------------------------------------------------------------------------+ /sbin/auto-backup.sh # +---------------------------------------------------------------------------+ # | Enter maintenance mode # +---------------------------------------------------------------------------+ esxcli system maintenanceMode set -e ${maitenance_enable} # +---------------------------------------------------------------------------+ # | Copy %first boot script logs to local datastore # +---------------------------------------------------------------------------+ cp /var/log/hostd.log "/vmfs/volumes/$(hostname -s)-local/firstboot-hostd.log" cp /var/log/esxi_install.log "/vmfs/volumes/$(hostname -s)-local/firstboot-esxi_install.log" # +---------------------------------------------------------------------------+ # Disable IPv6 for VMkernel interfaces # +---------------------------------------------------------------------------+ esxcli system module parameters set -m tcpip4 -p ipv6=${enable_ipv6} esxcli network ip set --ipv6-enabled=${enable1_ipv6} # +---------------------------------------------------------------------------+ # | Needed for configuration changes that could not be performed in esxcli # +---------------------------------------------------------------------------+ esxcli system shutdown reboot -d 60 -r "rebooting after host configurations" ##-------------------------------------------------------------------------- ## End of kickstart Script ##-------------------------------------------------------------------------- |
6) Automatiser la création de l’iso via un script Bash (esxi_factory_6.0.sh)
Ce script va permettre d’automatiser la création de l’iso personnalisé.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# +----------------------------------+ # Esxi_factory_6.0.sh # Version: 1.0 # By Philippe LIMA # +----------------------------------+ echo "[ ---------- Set variables ---------- ]" CLIENT="MEDIA-NAME" MEDIAversion="_esxi-6.0.0" MEDIAoutput=/vmware-modif MEDIAinput=/vmware-original/VMware-VMvisor-Installer-6.0.0.update01-3029758.x86_64.iso WORKINGdir="/var/tmp/working" ISOLINUXPath="/var/tmp/isolinux/isolinux.cfg" KICKPath="/var/tmp/ks/*.cfg" echo "[ ---------- Check & Clean working folder ---------- ]" cd $WORKINGdir umount $WORKINGdir/ori_distro rm -rf * echo "[ ---------- Create working folder ---------- ]" mkdir ${WORKINGdir}/ori_distro echo "[ ---------- Mount VMware ISO on working folder ---------- ]" mount -o loop ${MEDIAinput} ${WORKINGdir}/ori_distro echo "[ ---------- Copy VMware ISO on working folder ---------- ]" cp -prvf ${WORKINGdir}/ori_distro ${WORKINGdir}/distro echo "[ ---------- Create working weaselin folder ---------- ]" mkdir ${WORKINGdir}/ie echo "[ ---------- Extract weaselin to tar format ---------- ]" vmtar -x ${WORKINGdir}/distro/weaselin.t00 -o ${WORKINGdir}/weaselin.tar echo "[ ---------- Extract weaselin to working folders ---------- ]" cd ${WORKINGdir}/ie && tar xvf ${WORKINGdir}/weaselin.tar echo "[ ---------- Copy KS files ---------- ]" cp -vf ${KICKPath} ./etc/vmware/weasel/ chmod 777 ./etc/vmware/weasel/*.cfg echo "[ ---------- Recreate weaselin package ---------- ]" tar cvf weaselin.tar * vmtar -c weaselin.tar -o weaselin.t00 cp -vf weaselin.t00 ${WORKINGdir}/distro/weaselin.t00 echo "[ ---------- Copy ISOLINUX files ---------- ]" cd ${WORKINGdir}/distro cp -vf ${ISOLINUXPath} isolinux.cfg echo "[ ---------- Create Custom ISO---------- ]" mkisofs -l -J -R -r -T -input-charset UTF-8 -no-iso-translate -o ${MEDIAoutput}/${CLIENT}${MEDIAversion}.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${WORKINGdir}/distro echo "[ ---------- Custom ISO creation is done ---------- ]" |
7) Création de l’iso personnalisé via le script bash (esxi_factory_6.0.sh)
Lancez le script de création de l’iso personnalisé (esxi_factory_6.0.sh) présent à la racine (/) de notre système Linux par la commande :
1 |
./esxi_factory_6.0.sh |
Notre script va commencer par :
- Remplir les variables
- Néttoyer le répertoire de travail si il existe déjà
- Créer le répertoire de travail
- Monter l’iso original de vSphere ESXi dans le répertoire de travail
- Copier le contenu du média dans le répertoire de travail
- Créer un répertoire de travail pour l’archive weaselin
- Extraire l’archive weaselin dans ce répertoire de travail
- Copier les fichiers de kicktart dans le répertoire de travail de l’archive weaselin
- Packager de nouveau l’archive weaselin
- Copier le fichier isolinux.cfg
- Créer le nouveau fichier ISO personnalisé
Vérifiez la création du nouveau fichier ISO à la racine dans /vmware-modif
Vous pouvez récupérer le fichier via un logiciel comme WINSCP
8) Démarrage sur l’iso personnalisé
Il est possible de tester le média personnalisé dans une VM afin de simuler l’installation des hyperviseurs ESXi et ainsi vérifier que les kickstarts sont correctes.
Choisir le nom de l’hyperviseur à installer puis presser Entrer.
Lancement de l’installation. (vous pouvez prendre une pause café)
Le reboot s’effectue tout seul et donc pas obligé de presser la touche Entrer.
A la fin de l’installation (et au retour de la pause café), nous avons déjà un aperçu de la personnalisation de l’ESXi
Pour les plus motivés, il est aussi possible de générer les fichiers de kickstart de façon automatisé (par script) afin de ne pas modifier les variables de chaque fichier kickstart pour chaque ESXi. Sur peu d’hyperviseur cela ne pose pas de problème par contre sur une centaine d’ESXi cela peut vite devenir long et fastidieux.
Maintenant, vous n’avez plus d’excuse pour installer et configurer moins de 10 hyperviseurs par jour. :-p


nice shot !
merci pour le partage philippe je te dirais si j’ai réussi rapidement 😉
Hello Tom, j’espère que tout roule pour toi.
Pas de raison que tu n’y arrive pas, je package mes ISO de cette façon depuis X années 😉 (Pratique quand tu n’a pas de licence Ent Plus avec du Host Profile)
Un peu de travail au début sur le 1er fichier kickstart en fonction de ton design. Après, pour les autres ESXi, c’est toujours le même en modifiant la valeur des variables …
Philippe.
Bounjour,
je suis en train de suivre le tuto.
Cependant j ai des difficultés lors du traitement du script esxi.sh.
je suis sous ubuntu .
le paquet vmtar n’est pas dispo….
si j’essaie directement sur un esxi 5.5 .. c’est le mount qui n’est pas reconnu.
comment contourner le vmtar ?
Merci par avance,
Cordialement
Bonjour minos,
vmtar est un binaire 32bits, pour l’utiliser il vous faut une version Ubuntu 32bits.
Voici le lien pour télécharger: vmtar
Bonjour,
Merci pour le retour,
mais je dois mal m ‘y prendre , impossible d’installer le package vmtar.
je suis bien sous une une distrib en 32 bits.
Mais pas moyen ,
Il faut une version d’Ubuntu particulière ? , j ‘ai même essayé avec une debian 32bits ….
Merci par avance,
Bonjour,
Il suffit de copier le fichier binaire dans /usr/sbin et de donner les droits d’execution dessus via un « chmod +x vmtar »
La commande peut ensuite être appelée depuis un shell
Merci du retour ,
En effet cela marche nettement mieux , la commande vmtar est reconnue.
par contre je n’ai rien qui arrive dans le répertoire /vmware-modif/
il est vide , j ‘ai l’impression que la creation de l’iso modifiée ne se fait pas .
ton script s’arrête à :
echo « [….create custom file …) »
il manque la commande pour generer l’iso…?
peut on la lancer avec genisoimage car mkisofs plus dispo appremment ?
Merci par avance,
Cdt
Minos
Coucou,
je m’auto-réponds…
j’ai trouvé cette commande là :
genisoimage -R -r -J –hide-rr-moved -V « toto » -o ESXi-5.5.0.iso /var/tmp/working/distro/
je dois maintenant affiner le script KS.cfg
merci pour tout
Minos
Bonjour,
Oui, effectivement le package « mkisofs » est remplacé par « genisoimage ».
Merci de ce retour.
Bonjour,
Comment générez-vous le fichier ISO? Pouvez-vous donner la commande exacte?
La ligne de commande qui a été proposé ne fonctionne pas. Le fichier ISO est généré mais n’est pas bootable.
genisoimage -R -r -J -hide-rr-moved -o ${MEDIAvserion}.iso custom/
J’ai cherché mais je ne trouve pas grand chose à ce sujet. Certain évoque le bootlinux.bin à préciser dans la commande mais toujours sans succès.
Merci d’avance pour votre aide.
Damien B.
Bonjour Damien,
Dans mes anciens déploiements sur une ubuntu 10.3.4, j’utilisai le package « mkisofs » avec les paramètres indiqués dans mon script (je viens d’ajouter la ligne, elle avait disparu).
Je pense qu’il doit être possible de faire la même chose avec genisoimage:
genisoimage -R -r -V « ISO-LABEL » -cache-inodes -J -hide-rr-moved -l -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${WORKINGdir}/distro -o ${MEDIAoutput}/${CLIENT}${MEDIAversion}.iso
Cordialement,
Philippe.
Hello,
je suis en train de peaufiner mon fichier KS.cfg.
J ‘ai trouvé comment créer des rôles sous esxi en ligne de commande mais je voudrais savoir comment créer un user sous esxi 5.5.0 en ligne de commande à qui je vais lui affecter le nouveau rôle ?
Pour l’instant , rien de bien probant .
Merci par avance,
Minos
Vous avez réalisé un job impressionnant. Je vous remercie pour ce partage.
Cordialement,
DB.