All Projects → mrlesmithjr → Packer For Vsphere And More

mrlesmithjr / Packer For Vsphere And More

Programming Languages

shell
77523 projects
powershell
5483 projects

Projects that are alternatives of or similar to Packer For Vsphere And More

Hybrid multicloud overlay
MutiCloud_Overlay demonstrates a use case of overlay over one or more clouds such as AWS, Azure, GCP, OCI, Alibaba and a vSphere private infrastructure in Hub and spoke topology, point to point topology and in a Single cloud. Overlay protocols IPv6 and IPv4 are independent of underlying infrastructure. This solution can be integrated with encryption and additional security features.
Stars: ✭ 127 (+101.59%)
Mutual labels:  vsphere, ansible, packer
Packer Ubuntu 1404
DEPRECATED - Packer Example - Ubuntu 14.04 Vagrant Box using Ansible provisioner
Stars: ✭ 81 (+28.57%)
Mutual labels:  ansible, packer, virtualbox
Packer Centos 6
This build has been moved - see README.md
Stars: ✭ 78 (+23.81%)
Mutual labels:  ansible, packer, virtualbox
Packer Ubuntu 1804
This build has been moved - see README.md
Stars: ✭ 101 (+60.32%)
Mutual labels:  ansible, packer, virtualbox
Ansible Role Packer rhel
Ansible Role - Packer RHEL/CentOS Configuration for Vagrant VirtualBox
Stars: ✭ 45 (-28.57%)
Mutual labels:  ansible, packer, virtualbox
Packer Templates
Scripts and Templates used for generating Vagrant images
Stars: ✭ 219 (+247.62%)
Mutual labels:  ansible, packer, virtualbox
Beetbox
Pre-provisioned L*MP stack
Stars: ✭ 94 (+49.21%)
Mutual labels:  ansible, packer, virtualbox
Packer Centos 7
This build has been moved - see README.md
Stars: ✭ 223 (+253.97%)
Mutual labels:  ansible, packer, virtualbox
Packer Boxes
Jeff Geerling's Packer build configurations for Vagrant boxes.
Stars: ✭ 495 (+685.71%)
Mutual labels:  ansible, packer, virtualbox
packer-ubuntu
No description or website provided.
Stars: ✭ 29 (-53.97%)
Mutual labels:  packer, virtualbox
New-Machine
Utilizing Vagrant, Packer, Chocolatey, and Boxstarter to Configure my Dev Machines
Stars: ✭ 26 (-58.73%)
Mutual labels:  packer, virtualbox
Vagrant Boxes
baseboxes build with packer.io for use with vagrant
Stars: ✭ 291 (+361.9%)
Mutual labels:  packer, virtualbox
ansible-role-packer-debian
Ansible Role - Packer Debian/Ubuntu Configuration for Vagrant VirtualBox
Stars: ✭ 32 (-49.21%)
Mutual labels:  packer, virtualbox
packer-post-processor-virtualbox-to-hyperv
Packer plugin to create Hyper-V vagrant boxes from VirtualBox artifacts
Stars: ✭ 18 (-71.43%)
Mutual labels:  packer, virtualbox
packer-ubuntu-18.04
packer example - Ubuntu Server 18.04.5
Stars: ✭ 37 (-41.27%)
Mutual labels:  packer, virtualbox
insaneworks-packer-template
CentOS 7-8 8Stream / AlmaLinux 8 / FreeBSD 12 - 13 x64 + VirtualBox / VMWare for Packer Template + FreeBSD 13 / AlmaLinux 9 + Parallels
Stars: ✭ 38 (-39.68%)
Mutual labels:  packer, virtualbox
Kube Ansible
Build a Kubernetes cluster via Ansible playbook. 🔧 🔧 🔧
Stars: ✭ 354 (+461.9%)
Mutual labels:  ansible, virtualbox
Bento
Packer templates for building minimal Vagrant baseboxes for multiple platforms
Stars: ✭ 3,779 (+5898.41%)
Mutual labels:  packer, virtualbox
docker-hands-on-guide
Hands on guide for docker, k8s cluster lightweight virtualization.
Stars: ✭ 25 (-60.32%)
Mutual labels:  packer, virtualbox
Robox
The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
Stars: ✭ 303 (+380.95%)
Mutual labels:  packer, virtualbox

Packer For vSphere and More

This repo is for creating a consistent and repeatable VM templates. No matter whether creating locally or remotely to vSphere, the base image development will remain identical. This ensures that environments are built the same.

Requirements

Required Software

Updating/Creating Environment Variables and Etc. Using Ansible

In order to automate things easily so we do not forget anything we can also use Ansible to update/create our variables, kickstart, and preseed configurations. You will just need to update the variables in the following files to meet your requirements.

You will also need to create playbooks/group_vars/all/accounts.yml with the following (This file is excluded from Git):

---
# Define default Linux user password to create and use for SSH
default_password: packer

# Define default Linux user to create and use for SSH
default_username: packer

# Define ESXi login password
esxi_password: [email protected]

# Define ESXi login user
esxi_username: root

# Define Linux root password to assign when appropriate
root_password: packer

# Define vCenter login password
vcenter_password: [email protected]!

# Define vCenter login user
vcenter_username: [email protected]

Once you have updated the above variables you can then run the following Ansible playbook to configure environmentals.

ansible-playbook playbooks/generate_configs.yml

Required ESXi Tweaks

As part of the previous step of using Ansible to generate configurations and etc. you will find a PowerShell script GuestIPHack.ps1 that is created which can be used to configure your vSphere hosts to allow Packer to build.

Usage

NOTE: The below methods ensure that all builds are consistent regardless of the platform you choose to deploy to. This ensures that the underlying VM image is consistent across environments.

Image Versions Based On Timestamps

We have implemented the {{ timestamp }} function within Packer to append the timestamp to each image being built. This will allow for images to be continually built based on timestamp in order to properly select an image that you would like to consume.

Example image built:

Build 'ubuntu1604-packer-template-1525281143' finished.

KVM

This method will build VM templates for KVM usage. You will need to run these directly on the KVM host.

Ubuntu 12.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1204.json ubuntu_kvm.json

Ubuntu 14.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1404.json ubuntu_kvm.json

Ubuntu 16.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1604.json ubuntu_kvm.json

Ubuntu 18.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1804.json ubuntu_kvm.json

VMware Fusion And VirtualBox

This method will build a local only usable VM using VMware Fusion and VirtualBox.

NOTE: You may also choose whether to only build for one or the other platforms. In order to do that you may specify the following when building -only=virtualbox-iso or -only=vmware-iso.

The final result of this method are Vagrant boxes which can be imported and used for repeatable testing.

CentOS 6

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos6.json centos.json

CentOS 7

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos7.json centos.json

Debian 8

packer build -var-file=private_variables.json -var-file=variables.json -var-file=debian8.json debian.json

Debian 9

packer build -var-file=private_variables.json -var-file=variables.json -var-file=debian9.json debian.json

Ubuntu 12.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1204.json ubuntu.json

Ubuntu 14.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1404.json ubuntu.json

Ubuntu 16.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1604.json ubuntu.json

Ubuntu 18.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1804.json ubuntu.json

Using Vagrant

If you have created local VM images using the method in VMware Fusion And VirtualBox you can use them with Vagrant. Vagrant allows you to spin up images easily after the base images have been created. After following the method described, you will have files with .box extension in the parent folder of this repo. These files are excluded from version control because of their size and the fact that they are easily created.

Vagrant Boxes

As mentioned you will have some files with .box extension in the parent folder which we will be importing for testing.

ls -lh *.box
...
-rw-r--r--  1 larry  staff   885M Mar 12 11:19 ubuntu1604-packer-template-virtualbox.box
-rw-r--r--  1 larry  staff   762M Mar 12 11:16 ubuntu1604-packer-template-vmware.box

In the example above these are for Ubuntu 16.04 based on the naming of the files. The -virtualbox and -vmware in the file names represent which platform they are for, either VirtualBox or VMware Fusion.

Importing Vagrant Boxes

After choosing which platform you would like to use, you can then import the respective Vagrant box. We will be importing both Vagrant boxes in this example for Ubuntu 16.04.

VirtualBox:

vagrant box add ubuntu1604-packer-template-virtualbox ubuntu1604-packer-template-virtualbox.box
...
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu1604-packer-template-virtualbox' (v0) for provider:
    box: Unpacking necessary files from: file:///Users/larry/projects/Packer/ubuntu1604-packer-template-virtualbox.box
==> box: Successfully added box 'ubuntu1604-packer-template-virtualbox' (v0) for 'virtualbox'!

VMware Fusion:

vagrant box add ubuntu1604-packer-template-vmware ubuntu1604-packer-template-vmware.box
...
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu1604-packer-template-vmware' (v0) for provider:
    box: Unpacking necessary files from: file:///Users/larry/projects/Packer/ubuntu1604-packer-template-vmware.box
==> box: Successfully added box 'ubuntu1604-packer-template-vmware' (v0) for 'vmware_desktop'!
Consuming Vagrant Boxes

Now that you have followed the Importing Vagrant Boxes section. You are now ready to consume them for testing. The below is just an example of how to create your testing folder structure so feel free to adjust based on your needs.

NOTE: Using Vagrant with VMware Fusion or VMware Desktop requires a paid for Vagrant plugin. So the examples will only be using VirtualBox as this does not require a paid for plugin.

First we need to create the folder structure and initialize the Vagrant environments based on our needs:

mkdir -p ~/projects/Vagrant-testing/VirtualBox/Ubuntu/16.04
mkdir -p ~/projects/Vagrant-testing/VMware/Ubuntu/16.04
cd ~/projects/Vagrant-testing/VirtualBox/Ubuntu/16.04
vagrant init ubuntu1604-packer-template-virtualbox
cd ~/projects/Vagrant-testing/VMware/Ubuntu/16.04
vagrant init ubuntu1604-packer-template-vmware

Now we are ready to spin up the Vagrant environment which we would like to begin testing with:

cd ~/projects/Vagrant-testing/VirtualBox/Ubuntu/16.04
vagrant up
...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu1604-packer-template-virtualbox'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: 1604_default_1520868963557_57262
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.0.40
    default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
    default: /vagrant => /Users/larry/projects/Vagrant-testing/VirtualBox/Ubuntu/16.04

Once the above completes you are ready to begin your testing. We can SSH to the box to work within the Vagrant environment:

vagrant ssh

You are now ready to do whatever you would like with your testing.

And when you are done with your testing you can easily tear down the Vagrant environment:

vagrant destroy
...
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...

VMware Fusion Export To vSphere

This method will build a local VM using VMware Fusion but will export the image as a vSphere template when complete.

CentOS 6

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos6.json centos_fusion_esx.json

CentOS 7

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos7.json centos_fusion_esx.json

Ubuntu 12.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1204.json ubuntu_fusion_esx.json

Ubuntu 14.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1404.json ubuntu_fusion_esx.json

Ubuntu 16.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1604.json ubuntu_fusion_esx.json

Ubuntu 18.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1804.json ubuntu_fusion_esx.json

VMware vSphere

This method will build VM templates using Packer directly on a vSphere host and then convert to a template via vCenter.

CentOS 6

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos6.json centos_esx.json

CentOS 7

packer build -var-file=private_variables.json -var-file=variables.json -var-file=centos7.json centos_esx.json

Debian 8

packer build -var-file=private_variables.json -var-file=variables.json -var-file=debian8.json debian_esx.json

Debian 9

packer build -var-file=private_variables.json -var-file=variables.json -var-file=debian9.json debian_esx.json

Ubuntu 12.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1204.json ubuntu_esx.json

Ubuntu 14.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1404.json ubuntu_esx.json

Ubuntu 16.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1604.json ubuntu_esx.json

Ubuntu 18.04

packer build -var-file=private_variables.json -var-file=variables.json -var-file=ubuntu1804.json ubuntu_esx.json

License

MIT

Author Information

Larry Smith Jr.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].