Giter VIP home page Giter VIP logo

photon-packer-templates's Introduction

VMware Photon OS

Packer Templates for VMware Photon OS

VMware Fusion VMware Workstation Pro VirtualBox
Packer Vagrant

Introduction

This repository provides infrastructure-as-code examples to automate the creation of VMware Photon OS ( x86_64 ) machine images as Vagrant boxes using Packer. These Vagrant boxes can be run on VMware Fusion, VMware Workstation Pro, and VirtualBox.

This project is also used to generate the offical vmware/photon Vagrant boxes.

All examples are authored in the HashiCorp Configuration Language ("HCL2").

The following builds are available:

  • VMware Photon OS 4.0 R2 (default)
  • VMware Photon OS 4.0 R1
  • VMware Photon OS 3.0 R3

Requirements

  • HashiCorp Packer 1.8.3 or later

    • Packer Plugin for VMware ( vmware-iso ) 1.0.7 or later

    • Packer Plugin for Virtualbox ( virtualbox-iso ) 1.0.4 or later (Optional)

      Required Packer plugins are automatically downloaded and initialized when using the Makefile.

      For dark sites, you may download the plugins and place these same directory as your Packer executable /usr/local/bin or $HOME/.packer.d/plugins.

  • HashiCorp Vagrant 2.3.1 or later

    • Vagrant Plugin for VMware ( vagrant-vmware-desktop ) 3.0.1 or later
    • Vagrant VMware Utility 1.0.21 or later
  • VMware Fusion 12 (macOS) or VMware Workstation Pro 16 (Windows and Linux)

  • Virtualbox 6.1 (Optional)

The following software packages are recommened to be installed on the Packer host:

  • Git

    Used for cloning the project repository.For information on installing the Git Command line tools, see Git.

  • Microsoft Visual Code

    Used for editing configrations. For information on installing Microsoft Visual Studio Code, see Visual Studio Code.

    The Visual Studio Code extension for Packer 0.3.0 or later is also recommended for syntax support. Learn more on the Visual Studio Code Marketplace.

Get Started

Step 1 - Clone the Repository

Clone the project repository.

Example:

git clone https://github.com/vmware/photon-packer-templates.git

The general directory structure of the repository.

├── scripts
│   ├── system
│   │   └── *.sh
│   ├── vagrant
│   │   ├── *.sh
│   │   └── *.tpl
│   ├── virtualbox
│   │   └── *.sh
│   ├── vmware
│   │   └── *.sh*
│   └── *.sh
├── output
│   ├── photon-<version>-<release>-vagrant-<provider>.box
│   └── manifest.json
├── LICENSE
├── Makefile
├── NOTICE
├── override.pkrvars.hcl
├── photon-<version>-<release>.pkrvars.hcl
├── photon.pkr.hcl
├── photon.pkrtpl.hcl
├── README.md
└── variables.pkr.hcl

The files are distributed in the following directories.

  • output - location of the Vagrant boxes and manifest created after the completion of the machine image build.

  • scripts - contains the scripts to initialize and prepare the machine image builds based on the platform for the Vagrant box.

Step 2 - Update Input Variables

  1. Obtain the URL, checksum type (e.g., sha1), and checksum value for the VMware Photon OS .iso image. This will be use in the build input variables.

  2. Obtain the sha256 checksum value for the VirtualBox Guest Additions .iso image. This will be use as input variables when building for VirtualBox.

  3. Update the contents of the photon-<version>-<release>.pkrvars.hcl file, as needed.

// VMware Photon OS Settings

os_version         = "4.0"
os_release         = "R2"
iso_checksum_type  = "sha1"
iso_checksum_value = "eeb08738209bf77306268d63b834fd91f6cecdfb"
iso_url            = "https://packages.vmware.com/photon/4.0/Rev2/iso/photon-4.0-c001795b8.iso"

// VirtualBox Guest Additions

guest_additions_url      = "https://download.virtualbox.org/virtualbox/6.1.40/VBoxGuestAdditions_6.1.40.iso"
guest_additions_checksum = "d456c559926f1a8fdd7259056e0a50f12339fd494122cf30db7736e2032970c6"
  1. Modify the Overrides (Optional)

The project sets input defaults in the variables.pkr.hcl. You can override the defaults by editing the override.pkr.hcl file and uncommenting the relevent overrides.

# Override the default input variable values.

# os_packagelist           = "minimal"
# vm_name                  = "photon"
# guest_additions_url      = "https://download.virtualbox.org/virtualbox/7.0.0/VBoxGuestAdditions_7.0.0.iso"
# guest_additions_checksum = "f1e214507e4e845e18fdc4ce6ae9ab3aa3514f37d8a702201129c69ea2b3a675"
# ssh_password             = "VMw@re123!"
# ssh_timeout              = "15m"
# boot_wait                = "3s"
# boot_key_interval        = "10ms"
# hardware_version_vmw     = 18
# headless                 = false
# cpu_count                = 2
# memory_size              = 1024
# disk_size                = 20480
# network_vmw              = nat

Build

You can use the included Makefile to validate and build the all or specific machine images on macOS and Linux:

> make

Targets:
  validate
    validate-vmware-iso.vagrant-vmw
    validate-virtualbox-iso.vagrant-vbx
   
  build
    build-vmware-iso.vagrant-vmw
    build-virtualbox-iso.vagrant-vbx
   
  clean
  • validate - validates the configuration for all or specific targets.

  • build - runs a build for all or specific targets.

  • clean - removes all artifacts from the the output directory and removes the packer_cache directory. It does not remove any registered Vagrant boxes.

All required Packer plugins are automatically initialized when using validate and build options. If the plugins are not present, they will be automatically downloaded and installed.

For dark sites, you may download the plugins and place these same directory as your Packer executable /usr/local/bin or $HOME/.packer.d/plugins.

Example: Build all targets.

make build 

Example: Build only the VMware Fusion / Workstation Pro target.

make build-vmware-iso.vagrant-vmw

Alternatively, you can manually initilize, validate, and build on macOS, Linux, and Windows.

Example: Initialize for all targets.

  • macOS and Linux:

    packer init -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows:

    packer init -var-file .\photon-4.0-R2.pkrvars.hcl .

Example: Validate all targets.

  • macOS and Linux:

    packer validate -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows:

    packer validate -var-file .\photon-4.0-R2.pkrvars.hcl .

Example: Build all targets.

  • macOS and Linux:

    packer build --force -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows:

    packer build --force -var-file .\photon-4.0-R2.pkrvars.hcl .

Example: Build only the VMware Fusion / Workstation Pro target.

  • macOS and Linux:

    packer build --force -only=vmware-iso.vagrant-vmw -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows:

    packer build --force -only vmware-iso.vagrant-vmw -var-file .\photon-4.0-R2.pkrvars.hcl .

Example: Build only the VirtualBox target.

  • macOS and Linux:

    packer build --force -only=virtualbox-iso.vagrant-vbx -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows

    packer build --force -only virtualbox-iso.vagrant-vbx -var-file .\photon-4.0-R2.pkrvars.hcl .

Example: Build only the VMware Fusion / Workstation Pro target with an input variable override for the VMware Photon OS Developer package list.

  • macOS and Linux:

    packer build --force -var os_packagelist=developer -only=vmware-iso.vagrant-vmw -var-file=photon-4.0-R2.pkrvars.hcl .
  • Windows:

    packer build --force -var os_packagelist=developer -only vmware-iso.vagrant-vmw -var-file .\photon-4.0-R2.pkrvars.hcl .

Run

After you have created the Vagrant boxes for VMware Photon OS, you can bring them up in your provider of choice.

Example: VMware Fusion or VMware Workstation Pro

cd output
vagrant init photon-4.0-R2-minimal-vagrant-vmw.box
vagrant up --provider vmware_desktop

Example: VirtualBox

cd output
vagrant init photon-4.0-R2-minimal-vagrant-vbx.box
vagrant up --provider virtualbox

Example: SSH to the VMware Photon OS box.

> vagrant ssh
vagrant@photon-minimal [ ~ ]$ 

By default, shared folders are disabled between the Vagrant box and the host.

Edit the Vagrantfile to manage the share folders.

Example: Enable Shared Folders

Vagrant.configure("2") do |config|
  config.vm.box = "photon-4.0-R2-minimal-vagrant-vmw.box"
  config.vm.synced_folder '.', '/vagrant', disabled: false
end

Edit the Vagrantfile to modify additional provider configurations, such as CPU and memory.

Example: Modify the CPU and Memory Resources

Vagrant.configure("2") do |config|
  config.vm.box = "photon-4.0-R2-minimal-vagrant-vmw.box"
  config.vm.provider "vmware_desktop" do |v|
    v.vmx["numvcpus"] = "2"
    v.vmx["memsize"] = "2048"
  end
end

Learn more about the Vagrant provider configurations:

photon-packer-templates's People

Contributors

artw avatar dthaluru avatar frapposelli avatar markpeek avatar tenthirtyam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

photon-packer-templates's Issues

Add support for macOS M1 and VMware Fusion Professional Version Tech Preview M1

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Hypervisor

VMware Fusion Professional Version Tech Preview M1

Operating System

macOS Monterrey 12.3.1 M1

HashiCorp Packer

No response

HashiCorp Packer Plugin for VMware

No response

HashiCorp Vagrant

2.2.19

HashiCorp Vagrant VMware Utility

1.0.21

HashiCorp Vagrant plugin for VMware

3.0.1

Environment Details

No response

Description

Hi guys!

I was just trying to use the box here https://app.vagrantup.com/vmware/boxes/photon v4.0.2 by running the following commands:

vagrant init vmware/photon
vagrant up

Which results in the following error:

Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: <provider config: virtualbox>
Line number: 15
Message: NameError: undefined local variable or method `override' for main:Object

vagrant up --provider vmware_desktop, results in the same error.

Any help would be appreciated. Thanks!

Expected Behavior

When I execute:

vagrant init vmware/photon
vagrant up

A new vagrant box with Photon OS is ready to use.

Actual Behavior

vagrant init vmware/photon
vagrant up

Results in the following error:

Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: <provider config: virtualbox>
Line number: 15
Message: NameError: undefined local variable or method `override' for main:Object

Steps to Reproduce

  1. Create a folder called "photon"
  2. Execute the following commands inside this folder:

vagrant init vmware/photon
vagrant up

  1. You will get the following error:
Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: <provider config: virtualbox>
Line number: 15
Message: NameError: undefined local variable or method `override' for main:Object

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

Update template with Hyper-V builder

It's nice to have the VirtualBox builder in the template, rather than just including VMware support - it would be great to also include a builder for Hyper-V.

non empty /etc/machine-id confuses dhcp server

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Hypervisor

VMware Workstation 16 Pro

Operating System

Windows 10 Version 20H2

HashiCorp Packer

No response

HashiCorp Packer Plugin for VMware

No response

HashiCorp Vagrant

2.2.19

HashiCorp Vagrant VMware Utility

1.0.21

HashiCorp Vagrant plugin for VMware

3.0.1

Environment Details

No response

Description

with a non empty /etc/machine-id all deployed vm's are assigned the same ip address from the internal DHCP server on the VMnet networks.

Expected Behavior

Every deployed vm to get a uniqe DHCP adress

Actual Behavior

VM's get the same DHCP address

Steps to Reproduce

Deploy 2 vm.

  # -*- mode: ruby -*-
  #   # vi: set ft=ruby :
  #
  Vagrant.configure("2") do |config|
    config.vm.box = "vmware/photon"

    config.vm.define "one" do |one|
      one.vm.hostname = "photon1"
    end
    config.vm.define "two" do |two|
      two.vm.hostname = "photon2"
    end
  end

Log Fragments and Files

vagrant up log

Bringing machine 'one' up with 'vmware_desktop' provider...
Bringing machine 'two' up with 'vmware_desktop' provider...
==> one: Cloning VMware VM: 'vmware/photon'. This can take some time...
==> one: Checking if box 'vmware/photon' version '4.0.2' is up to date...
==> one: Verifying vmnet devices are healthy...
==> one: Preparing network adapters...
==> one: Fixed port collision for 22 => 2222. Now on port 2205.
==> one: Starting the VMware VM...
==> one: Waiting for the VM to receive an address...
==> one: Forwarding ports...
one: -- 22 => 2205
==> one: Waiting for machine to boot. This may take a few minutes...
one: SSH address: 127.0.0.1:2205
one: SSH username: vagrant
one: SSH auth method: private key
one: Warning: Remote connection disconnect. Retrying...
one:
one: Vagrant insecure key detected. Vagrant will automatically replace
one: this with a newly generated keypair for better security.
one: Warning: Authentication failure. Retrying...
one: Warning: Authentication failure. Retrying...
one: Warning: Authentication failure. Retrying...
one: Warning: Authentication failure. Retrying...
one: Warning: Authentication failure. Retrying...
one: Warning: Remote connection disconnect. Retrying...
==> one: Machine booted and ready!
==> one: Setting hostname...
==> one: Configuring network adapters within the VM...
==> two: Cloning VMware VM: 'vmware/photon'. This can take some time...
==> two: Checking if box 'vmware/photon' version '4.0.2' is up to date...
==> two: Verifying vmnet devices are healthy...
==> two: Preparing network adapters...
==> two: Fixed port collision for 22 => 2222. Now on port 2206.
==> two: Starting the VMware VM...
==> two: Waiting for the VM to receive an address...
==> two: Forwarding ports...
two: -- 22 => 2206
==> two: Waiting for machine to boot. This may take a few minutes...
two: SSH address: 127.0.0.1:2200
two: SSH username: vagrant
two: SSH auth method: private key
two: Warning: Remote connection disconnect. Retrying...
two:
two: Vagrant insecure key detected. Vagrant will automatically replace
two: this with a newly generated keypair for better security.
two:
two: Inserting generated public key within guest...
two: Removing insecure key from the guest if it's present...
two: Key inserted! Disconnecting and reconnecting using new SSH key...
==> two: Machine booted and ready!
==> two: Setting hostname...
==> two: Configuring network adapters within the VM...

Screenshots

VM 1

image

VM 2

image

Additional Context

I made a modified box based on the vmware/photon 4.0.2
where the only modification was to delete the file /etc/machine-id
that box works as expected.

Screenshots of 3 working VM's

VM 1

image

VM 2

image

VM 3

image

vagrant-vmware_desktop build is missing gawk

When running Vagrant up with the vmware desktop provider (fusion), the network configuration of Photon OS fails with:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mv /tmp/bash: line 2: awk: command not found /etc/systemd/network/

This can be solved by installing gawk also for the vagrant-vmware_desktop image.

The vmware/photon box on atlas also is missing awk.

Vagrant user password expiration.

@brndmg commented on Tue Sep 27 2016

The vagrant password is expiring in the vmware/photon 1.2.0 box.

==> default: Running 'pre-boot' VM customizations...
==> 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
The configured shell (config.ssh.shell) is invalid and unable
to properly execute commands. The most common cause for this is
using a shell that is unavailable on the system. Please verify
you're using the full path to the shell and that the shell is
executable by the SSH user.
~/Dev/code/vagrant-project  $ vagrant ssh
You are required to change your password immediately (password aged)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for vagrant.
(current) UNIX password:

@embano1 commented on Wed Sep 28 2016

Thx, was about to open an issue as well on this since my multi-node deployment (https://github.com/embano1/Vagrant_Docker_Enterprise) fails now.
Please fix.

Thank you.

Issue with Packer Build

When trying to do a Packer Build using the instruction provided I am running into some sort of issue where the VM reboots after attempting to get the kickstart file. Any errors cannot be read due to how fast the reboot is. Files are an exact match as the instructions.

Mac OS X 10.15.4
Packer 1.5.6
Fusion 11.5.3

README.md requires updating

The new Packer file renamed the source from vmware-iso.vagrant-vmware_desktop to vmware-iso.vagrant-vmware.

In the README.md file, the build target vagrant-vmware_desktop shows up in three locations and should be replaced with vagrant-vmware.

VMware build doesn't use VMware's Photon OS guest type.

VMware has supported the guest OS type "vmware-photon-64" for a number of releases but the Packer template uses "other3xlinux-64", which may be less than optimal especially since Photon OS 4.0 uses a 5.10 Linux Kernel

Support for Photon OS 4.0 GA

The current repository doesn't appear to support Photon OS 4.0.

You might be able to leverage my new Packer template (https://github.com/timothybrush/packer-templates) under photon4 that uses Photon OS 4.0 GA to build out Vagrant boxes for each of the 4 different installation types (developer, minimal, ostree host, real time). However, it currently only supports the vmware_desktop provider since I don't use or have Virtualbox installed.

You might also find my Vagrant Boxes useful.

Notes:

  • Photon OS packages and OSTree show errors when upgrading to the latest versions.
  • OSTree Host installs but don't run rpm-ostree update to upgrade it. The system will fail to restart. This is an issue that the Photon OS team should investigate.

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.