-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for running ovftool directly on ESXi #187
Open
dizzyd
wants to merge
4
commits into
josenk:master
Choose a base branch
from
dizzyd:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Terraform esxi Provider (08 ovftool on ESXi) | ||
--- | ||
|
||
Since we have SSH enabled on ESXi, it's possible to install ovftool directly on the ESXi host and avoid large network copies | ||
by hosting the OVA/OVFs locally. | ||
|
||
To use this functionality, perform the following steps: | ||
1. Install ovftool somewhere on the ESXi host. For example, ``/vmfs/volumes/datastore1/ovftool`` (directory) | ||
2. Add the ``esxi_remote_ovftool_path`` to provider config: | ||
``` | ||
provider "esxi" { | ||
esxi_hostname = "${var.esxi_server}" | ||
esxi_username = "${var.esxi_user}" | ||
esxi_password = "${var.esxi_password}" | ||
esxi_remote_ovftool_path = "/vmfs/volumes/datastore1/ovftool/ovftool" | ||
} | ||
``` | ||
3. Install an OVA somewhere on the ESXi host. For example, /vmfs/volumes/datastore1/ovas/ubuntu-22.04-server-cloudimg-amd64.ova | ||
4. Use the ``host_ovf://`` prefix to tell the plugin where to find the local image. Example: | ||
``` | ||
resource "esxi_guest" "vmtest" { | ||
... | ||
ovf_source = "host_ovf:///vmfs/volumes/datastore1/isos/ubuntu-22.04-server-cloudimg-amd64.ova" | ||
} | ||
``` | ||
|
||
Now, when creating the vmtest instance, terraform will run the ovftool on the ESXi host directly and will pull the image on that | ||
same host, avoiding massive copies over the network. | ||
|
||
Note that ovf_properties and guestinfo directives will work as expected. We highly recommend using guestinfo directive w/ cloud-init | ||
configs where possible (anything using cloud-init 21.2+ should work) and avoid the overhead of rebooting the instance multiple | ||
times. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
provider "esxi" { | ||
esxi_hostname = var.esxi_hostname | ||
esxi_hostport = var.esxi_hostport | ||
esxi_hostssl = var.esxi_hostssl | ||
esxi_username = var.esxi_username | ||
esxi_password = var.esxi_password | ||
|
||
esxi_remote_ovftool_path = "/vmfs/volumes/datastore1/ovftool/ovftool" | ||
} | ||
|
||
resource "esxi_guest" "vmtest" { | ||
guest_name = var.vm_hostname | ||
disk_store = var.disk_store | ||
|
||
network_interfaces { | ||
virtual_network = var.virtual_network | ||
} | ||
|
||
# | ||
# Specify an ovf file to use as a source. | ||
# | ||
ovf_source = "host_ovf:///vmfs/volumes/datastore1/ovas/ubuntu-22.04-server-cloudimg-amd64.ova" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# See https://www.terraform.io/intro/getting-started/variables.html for more details. | ||
# | ||
|
||
# Change these defaults to fit your needs! | ||
|
||
variable "esxi_hostname" { | ||
default = "esxi" | ||
} | ||
|
||
variable "esxi_hostport" { | ||
default = "22" | ||
} | ||
|
||
variable "esxi_hostssl" { | ||
default = "443" | ||
} | ||
|
||
variable "esxi_username" { | ||
default = "root" | ||
} | ||
|
||
variable "esxi_password" { | ||
# Unspecified will prompt | ||
} | ||
|
||
variable "virtual_network" { | ||
default = "VM Network" | ||
} | ||
|
||
variable "disk_store" { | ||
default = "DiskStore01" | ||
} | ||
|
||
variable "vm_hostname" { | ||
default = "vmtest06" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
required_providers { | ||
esxi = { | ||
source = "registry.terraform.io/josenk/esxi" | ||
# | ||
# For more information, see the provider source documentation: | ||
# | ||
# https://github.com/josenk/terraform-provider-esxi | ||
# https://registry.terraform.io/providers/josenk/esxi | ||
# | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to Do that man , there are only win and linux files meanwhile esxi is not linux , tho you do it with host client ? i dont found any console or sth to some cmds , am a beginner..