Created
May 8, 2019 09:32
-
-
Save azzeddinefaik/d76fbcd89fda20ab5f1b93bd21381895 to your computer and use it in GitHub Desktop.
exemple of packer file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables": { | |
"vsphere_server": "myhost.com", | |
"vsphere_network": "mynet", | |
"vsphere_datacenter": "mydc", | |
"vsphere_cluster": "mycluster", | |
"vsphere_resource_pool": "mypool", | |
"vsphere_datastore": "myds", | |
"vsphere_folder": "myfdlr", | |
"vsphere_host": "myvshost", | |
"vm_disk_size": "40000", | |
"vm_ram_size": "4096", | |
"vm_cpu_size": "2", | |
"vsphere_guest_os_type": "rhel7_64Guest", | |
"vm_name": "centos-test", | |
"iso_checksum_type": "sha256", | |
"iso_checksum": "38d5d51d9d100fd73df031ffd6bd8b1297ce24660dc8c13a3b8b4534a4bd291c", | |
"iso_url": "http://ftp.ember.se/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso", | |
"vm_ssh_password": "root", | |
"vm_ssh_username": "root" | |
}, | |
"builders": [ | |
{ | |
"type": "vsphere-iso", | |
"vcenter_server": "{{user `vsphere_server`}}", | |
"insecure_connection": "true", | |
"username": "{{user `vsphere_username`}}", | |
"password": "{{user `vsphere_password`}}", | |
"datacenter": "{{user `vsphere_datacenter`}}", | |
"cluster": "{{user `vsphere_cluster`}}", | |
"host": "{{user `vsphere_host`}}", | |
"datastore": "{{user `vsphere_datastore`}}", | |
"folder": "{{user `vsphere_folder`}}", | |
"vm_version": 13, | |
"vm_name": "{{user `vm_name`}}", | |
"guest_os_type": "{{user `vsphere_guest_os_type`}}", | |
"notes": "centos 7.6 generate by packer {{ isotime }}", | |
"communicator": "ssh", | |
"ssh_username": "{{user `vm_ssh_username`}}", | |
"ssh_password": "{{user `vm_ssh_password`}}", | |
"convert_to_template": true, | |
"CPUs": "{{user `vm_cpu_size`}}", | |
"RAM": "{{user `vm_ram_size`}}", | |
"disk_size": "{{user `vm_disk_size`}}", | |
"disk_thin_provisioned": true, | |
"disk_controller_type": "pvscsi", | |
"network_card": "vmxnet3", | |
"network": "{{user `vsphere_network`}}", | |
"iso_urls": [ | |
"{{user `iso_url`}}" | |
], | |
"iso_checksum_type" :"{{user `iso_checksum_type`}}", | |
"iso_checksum" : "{{user `iso_checksum`}}", | |
"floppy_files": [ | |
"{{ template_dir }}/ks.cfg" | |
], | |
"boot_wait": "10s", | |
"boot_command": [ | |
"<tab>", | |
" text inst.ks=hd:fd0:/ks.cfg net.ifnames=0 biosdevname=0", | |
"<wait>", | |
"<enter>", | |
"<wait>", | |
"<enter>" | |
] | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"environment_vars": [ | |
"centos_pub_key={{user `centos_pub_key`}}" | |
], | |
"scripts": [ | |
"scripts/add_user.sh" | |
] | |
}, | |
{ | |
"type": "shell", | |
"inline": [ | |
"echo {{user `centos_private_key`}} > /home/centos/.ssh/id_rsa ", | |
"chmod 0600 /home/centos/.ssh/id_rsa", | |
"chown -v -R centos:centos /home/centos/.ssh", | |
"echo {{user `centos_password`}} | passwd centos --stdin", | |
"echo {{user `root_new_password`}} | passwd root --stdin" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment