Giter Site home page Giter Site logo

lab-packer's Introduction

lab-packer

Creates a packer image to deploy on AWS or ESXi.

How to start

Git clone this repository, all paths are relative to the base directory of this repository.

How to setup

Create a json file with credentials. For AWS this is optional, you can skip this if you have AWS CLI configured.

AWS (vars/aws-vars.json):

{
    "aws_access_key": "<AWS ACCESS KEY>",
    "aws_secret_key": "<AWS SECRET KEY>",
    "aws_region": "<AWS REGION>"
}

ESXi (vars/esxi-vars.json):

{
    "username": "packer",
    "password": "packer",
    "esxi_host": "<ESXi IP>",
    "esxi_username": "<ESXi USER>",
    "esxi_password": "<ESXi PASSWORD>"
}

vCenter (vars/vcenter-vars.json):

{
    "vcenter_server": "<VCENTER_ADDRESS>",
    "vcenter_username": "<VCENTER_USER>",
    "vcenter_password": "<VCENTER_PASSWORD>",
    "vcenter_insecure_connection": "<false|true>",
    "vcenter_datacenter": "<DATACENTER>",
    "vcenter_cluster": "<CLUSTER>",
    "vcenter_datastore": "<DATASTORE>"
}

How to use

Run packer from the base folder of this repository.

packer validate -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
packer build -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json

Alternatively you can set a parameter as a environment variable:

{
    (...)
    "vcenter_password": "{{ env `PACKER_VSPHERE_PASSWORD` }}",
    (...)
}

Export vSphere password and call Packer:

export PACKER_VSPHERE_PASSWORD="<PASSWORD>"
packer validate -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
packer build -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json

How to use templates in HCL

Example:

packer init proxmox/almalinux/9
packer validate proxmox/almalinux/9
export PKR_VAR_password="<PASSWORD>"
packer build proxmox/almalinux/9

Output

An image will be created, AMI for AWS or OVA for ESXi ready to be used. A template will be generated for vCenter.

OBS:

The vsphere-iso provider does not cleanup packer_cache folder, remove it manually if desired.

lab-packer's People

Contributors

amsoares06 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.