/packer-centos-vsphere-example

A basic Packer example to create a CentOS 7 VM and deploy to VCenter as a template.

Primary LanguageShell

Packer

Introduction

This repository contains a basic (demo) example for creating a CentOS 7 VMware image with Packer. A Virtual Machine will be created, several hardening actions takes place and the VM will be uploaded to a VCenter and then marked as a template. This template can then be used with a tool like terraform to deploy 1 or more servers.

Create VM

Requirements

The following requirements should be met before you can do something:

Creds.json

The creds.json file should contain the following specific VCenter variables.

{
  "vcenter_host": "<FQDN_OR_IP_VCENTER>",
  "vcenter_username": "<USERNAME>",
  "vcenter_password": "<PASSWORD>",
  "vcenter_datacenter": "<DATACENTER>"
}

Ansible

Once the VM is build and provisioned, Ansible will be installed and a playbook (with a basic role) will be applied as well. When all is done, Ansible and the dependencies will be removed again.

Build

The following command can be used for creating the VM, uploading to the VCenter and mark it as a template.

packer build  -var "git_commit=$(git rev-parse HEAD)" -var-file=creds.json CentOS_7.json

Some links that have helped me to create a VM (Lost a few).