Skip to content

ibm-client-engineering/terraform-artifactory-vmware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Terraform Artifactory VMware Deployment

This repository provides Terraform configurations to deploy Artifactory on a VMware vSphere environment.

Requirements

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).

IBM TechZone Access to vSphere

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)


Pre flight checklist

๐Ÿ› ๏ธ Preparing a RHEL 9 Template for Terraform on vSphere

An existing RHEL VM template needs to be created. See the Packer RHEL 8 & 9 for VMware vSphere project for instructions on building a VM template in vSphere.

Install Terraform

๐Ÿ’ก 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 yum install -y yum-utils git bind-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum install -y terraform

Check the installed version:

terraform -version

Configure Networking

Required Static IPs

There is 1 static IP addresses that is needed.

๐Ÿ’ก Important: The subnet is controlled by the subnet_cidr value in the variables, default is 192.168.252.0/24.

Hostname IP FQDN
artifactory 192.168.252.8 artifactory.gym.lan

The example table above assumes the base_domain is set to gym.lan, no common_prefix is set and default subnet_cidr is being used.

๐Ÿ› ๏ธ How to Set Static IPs in pfSense

  1. Log in to pfSense via the web UI (usually at https://192.168.252.1).
  2. Navigate to:
    Services โ†’ DNS Forwarder.
  3. Scroll down to Host Overrides.
  4. 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.
  5. Click Apply Changes at the top of the page.

๐Ÿ” Verifying DNS Resolution

To ensure the FQDNs resolve correctly:

  • Test resolution using:
nslookup artifactory.gym.lan

Clone the repository

Clone this repository to your local workstation. This will allow you to configure and run terraform.

1. Install Required Packages

Open a terminal and run:

sudo dnf install -y git bind-utils

2. Clone the repo

Now clone this repo:

git clone https://github.com/ibm-client-engineering/terraform-artifactory-vmware.git
cd terraform-artifactory-vmware

Define Terraform variables

There is a file called terraform.tfvars.example. Copy this file to terraform.tfvars and set variables here according to your needs.

cp terraform.tfvars.example terraform.tfvars
IBM TechZone Tip Use the following commands to configure some of the variables in an IBM TechZone environment.

Install yq

sudo curl -L https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
yq --version

# Define the source YAML file path
YAML_FILE=~/vmware-ipi.yaml

# --- Update vsphere.pkrvars.hcl ---
echo "Updating vsphere.pkrvars.hcl..."
vsphere_hostname=$(yq e '.vsphere_hostname' "$YAML_FILE")
vsphere_username=$(yq e '.vsphere_username' "$YAML_FILE")
vsphere_password=$(yq e '.vsphere_password' "$YAML_FILE")
vsphere_datacenter=$(yq e '.vsphere_datacenter' "$YAML_FILE")
vsphere_cluster=$(yq e '.vsphere_cluster' "$YAML_FILE")
vsphere_datastore=$(yq e '.vsphere_datastore' "$YAML_FILE")
vsphere_network=$(yq e '.vsphere_network' "$YAML_FILE")
vsphere_folder=$(yq e '.vsphere_folder' "$YAML_FILE")
vsphere_resource_pool=$(yq e '.vsphere_resource_pool' "$YAML_FILE")

# Perform in-place substitutions using sed.
# The 'sed' commands handle the replacement of the existing values.
sed -i \
    -e "s|vsphere_hostname\s*=\s*\".*\"|vsphere_hostname = \"$vsphere_hostname\"|" \
    -e "s|vsphere_username\s*=\s*\".*\"|vsphere_username = \"$vsphere_username\"|" \
    -e "s|vsphere_password\s*=\s*\".*\"|vsphere_password = \"$vsphere_password\"|" \
    -e "s|vsphere_datacenter\s*=\s*\".*\"|vsphere_datacenter = \"$vsphere_datacenter\"|" \
    -e "s|vsphere_cluster\s*=\s*\".*\"|vsphere_cluster = \"$vsphere_cluster\"|" \
    -e "s|vsphere_datastore\s*=\s*\".*\"|vsphere_datastore = \"$vsphere_datastore\"|" \
    -e "s|vsphere_network\s*=\s*\".*\"|vsphere_network = \"$vsphere_network\"|" \
    -e "s|vsphere_folder\s*=\s*\".*\"|vsphere_folder = \"$(echo "$vsphere_folder" | sed -E 's|^/IBMCloud/vm/||')\"|" \
    -e "s|template_name\s*=\s*\".*\"|template_name = \"$(echo "$vsphere_folder" | sed -E 's|^/IBMCloud/vm/||')/linux-rhel-9.4-master\"|" \
    -e "s|vsphere_resource_pool\s*=\s*\".*\"|vsphere_resource_pool = \"$(echo "$vsphere_resource_pool" | sed -E 's|^/IBMCloud/host/ocp-gym/Resources/Cluster Resource Pool/Gym Member Resource Pool/||')\"|" \
    terraform.tfvars

echo "All variables have been updated successfully."

Ensure that template_name refers to an existing template in your environment. The example template name is linux-rhel-9.4-master.

Ensure that rhsm_username and rhsm_password are set with Red Hat credentials.

Ensure that accept_license has been set to true.

Deploy

We are now ready to deploy our infrastructure. First, we initialize the providers.

terraform init

Now we ask terraform to plan the execution with (this step is optional):

terraform plan

Now we can deploy our resources with:

terraform apply

Accessing Artifactory

  • Default Username: admin
  • Auto-generated Password: To retrieve the password, run:
    terraform output -raw artifactory_password && echo
  • Base URL: https://artifactory.gym.lan:8443

Troubleshooting

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.

Important Notes

  • The default daily/weekly backups are disabled during the first startup.

Destroy

To destroy all resources, run the following command.

terraform destroy -auto-approve

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages