This repository provides Terraform configurations to deploy Artifactory on a VMware vSphere environment.
Before deploying, ensure you have:
- Terraform - Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files.
- Access to a VMware vSphere environment with the proper authorization to create VMs.
- DNS entry for
artifactory.gym.lan
pointing to the deployed VM's IP address (e.g.,192.168.252.8
).
If you are an IBMer or Business Parter, you can request access to vSphere through IBM TechZone.
VMware on IBM Cloud Environments
Select `Request vCenter access (OCP Gym)
To use this Terraform code to deploy virtual machines on vSphere, you first need a VM template. Here's how to create one using a RHEL 9 image.
You want to deploy VMs using Terraform, but Terraform needs a pre-existing VM template to clone from.
Red Hat provides a tool to generate OVA files for RHEL 9. This is a convenient way to create a VM image that can be imported into vSphere.
π You can find the image builder on the Red Hat Customer Portal.
Once you have the OVA file:
- Open vSphere Client.
- Go to Deploy OVF Template.
- Upload the RHEL 9 OVA.
- Follow the wizard to deploy it as a VM or template.
π‘ Tip: If you're connecting to vSphere through a WireGuard VPN, you might experience timeouts or connectivity issues.
In such cases, consider running your Terraform commands from a bastion host that resides within the same network or environment as vSphere.
This can help avoid VPN-related latency or firewall restrictions that interfere with the connection.
To install Terraform from a RHEL 8 bastion host, follow these steps:
Open a terminal and run:
sudo dnf install -y yum-utils git bind-utils
Create a new repo file:
sudo tee /etc/yum.repos.d/hashicorp.repo <<EOF
[hashicorp]
name=HashiCorp Stable - RHEL 8
baseurl=https://rpm.releases.hashicorp.com/RHEL/8/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg
EOF
Now install Terraform:
sudo dnf install -y terraform
Check the installed version:
terraform -version
π‘ Important: Currently this Terraform module assumes that the network is 192.168.252.0/24. This is hard-coded into the module, sorry.
There are 4 static IP addresses that are needed.
Hostname | IP | FQDN |
---|---|---|
artifactory |
192.168.252.8 |
haproxy.gym.lan |
The example table above assumes the base_domain
is set to gym.lan
- Log in to pfSense via the web UI (usually at
https://192.168.252.1
). - Navigate to:
Services β DNS Forwarder. - Scroll down to Host Overrides.
- For each device:
- Click Add.
- Set the IP address (from the table above).
- Set the Hostname (e.g.,
artifactory
). - Set the Domain to
gym.lan
(or appropriate base domain) to form the FQDN. - Click Save.
- Click Apply Changes at the top of the page.
To ensure the FQDNs resolve correctly:
- Test resolution using:
nslookup artifactory.gym.lan
To ensure that your static DHCP mappings (like artifactory.gym.lan
, etc.) are resolvable via DNS, you need to enable a specific setting in pfSense:
- Log in to the pfSense Web UI.
- Navigate to:
Services β DNS Forwarder. - Scroll down to the General DNS Forwarder Options section.
- Check the box for: Register DHCP static mappings in DNS forwarder
- Click Save and then Apply Changes.
π‘ This setting controls whether hostnames assigned to static DHCP clients are automatically added to the DNS forwarder or resolver so they can be resolved locally.
Clone this repository to your local workstation. This will allow you to configure and run terraform.
Open a terminal and run:
sudo dnf install -y git bind-utils
Now clone this repo:
git clone <repo>
There is a file called terraform.tfvars.example
. Copy this file to terraform.tfvars
and set variables here according to
your needs.
We are now ready to deploy our infrastructure. First we ask terraform to plan the execution with:
terraform plan
now we can deploy our resources with:
terraform apply
- Default Username:
admin
- Auto-generated Password: To retrieve the password, run:
terraform output -raw artifactory_password && echo
- Base URL:
https://artifactory.gym.lan:8443
If you see the "Artifactory is starting up" page, it indicates the web server is running but there's an issue with the Artifactory application itself. Check the following:
- Ensure the PostgreSQL database is running and accessible.
- Verify that disk space is not at 100% utilization.
- The default daily/weekly backups are disabled during the first startup.
To destroy all resources, run the following command.
terraform destroy -auto-approve