Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Support TF v0.13 and OCP 4.6 #44

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Run this code from either Mac or Linux (Intel) system.
# Pre-requisites
- **Git**: Please refer to the following [link](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for instructions
on installing `git` for Linux and Mac.
- **Terraform >= 0.12.2, < 0.13**: Please refer to the following [link](https://learn.hashicorp.com/terraform/getting-started/install.html) for instructions on installing `terraform` for Linux and Mac.
- **Terraform >= 0.13**: Please refer to the following [link](https://learn.hashicorp.com/terraform/getting-started/install.html) for instructions on installing `terraform` for Linux and Mac. For validating the version run `terraform version` command after install.
- **Terraform Providers**: Please ensure terraform providers are built and installed on Terraform Client Machine. You can follow the [Build Terraform Providers](docs/terraform-provider-build.md) guide.
- **libvirt**: Please ensure `libvirt` is installed and configured on the KVM host. You can follow the [Libvirt Host setup](docs/libvirt-host-setup.md) guide.

Expand Down
7 changes: 7 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ git clone https://github.com/ocp-power-automation/ocp4-upi-kvm.git
cd ocp4_upi_kvm
```

**NOTE**: Please checkout a [release branch](https://github.com/ocp-power-automation/ocp4-upi-kvm/branches) eg. `release-4.5` for deploying a specific OCP release. The `master` branch will contain the latest changes which may not work with stable OCP releases but might work with pre-release OCP versions. You can also checkout stable [release tags](https://github.com/ocp-power-automation/ocp4-upi-kvm/releases) eg. `v4.3` for deploying a stable OCP releases.

To checkout specific release branch or tag please run:
```
$ git checkout <branch|tag name>
```

## Setup Variables
Update the var.tfvars with values explained in the following sections. You can also set the variables using other ways mentioned [here](https://www.terraform.io/docs/configuration/variables.html#assigning-values-to-root-module-variables) such as -var option or environment variables.

Expand Down
148 changes: 125 additions & 23 deletions docs/terraform-provider-build.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,168 @@
# Steps to build terraform providers
# Terraform Providers

Follow below steps based on your Terraform Client Machine Architecture to setup terraform providers. These steps are required to be followed before running the automation.
At present Terraform registry does not support some plugins. Third-party providers can be manually installed using [local filesystem as a mirror](https://www.terraform.io/docs/commands/cli-config.html#filesystem_mirror). This is in additon to the provider plugins that are downloaded by Terraform during `terraform init`.

Follow below steps based on your Terraform client machine to setup terraform providers. These steps are required to be followed before running the automation.

Most of the steps require Go to be installed from https://golang.org/dl/. We recommed Go version above 1.14. Make sure to set your GOPATH environment variable and add $GOPATH/bin to PATH.

## On Mac/Linux
Install latest go from https://golang.org/dl/ and set your GOPATH

Identify your platform. All example commands assume Linux as a platform:

> Linux: linux_amd64

> Mac OSX: darwin_amd64

Identify your Terraform plugin directory. You will need to create the directory on your client machine:

> Linux: ~/.local/share/terraform/plugins OR /usr/local/share/terraform/plugins OR /usr/share/terraform/plugins.

> Mac OSX: ~/Library/Application Support/io.terraform/plugins OR /Library/Application Support/io.terraform/plugins


**Libvirt provider**: Please refer to the section below for instructions on installing the libvirt provider plugin. For [more information](https://github.com/dmacvicar/terraform-provider-libvirt#building-from-source).

Run below commands to install libvirt provider. Make sure to change `PLATFORM` and `PLUGIN_PATH` values based on your client machine.

```
PLATFORM=linux_amd64
PLUGIN_PATH=~/.local/share/terraform/plugins

#Install the Libvirt provider plugin:
git clone https://github.com/dmacvicar/terraform-provider-libvirt $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
cd $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
make install
mkdir -p ~/.terraform.d/plugins/
cp $GOPATH/bin/terraform-provider-libvirt ~/.terraform.d/plugins/terraform-provider-libvirt
cd -

# Create plugin directory and copy the binary
mkdir -p $PLUGIN_PATH/registry.terraform.io/dmacvicar/libvirt/1.0.0/$PLATFORM/
cp $GOPATH/bin/terraform-provider-libvirt $PLUGIN_PATH/registry.terraform.io/dmacvicar/libvirt/1.0.0/$PLATFORM/terraform-provider-libvirt
```


**Ignition provider v2.1.0**

Run below commands to download the **zip** archive from [community-terraform-provider releases page](https://github.com/community-terraform-providers/terraform-provider-ignition/releases/tag/v2.1.0).

```
PLATFORM=linux_amd64
PLUGIN_PATH=~/.local/share/terraform/plugins

# Create plugin directory and download the zip file
mkdir -p $PLUGIN_PATH/registry.terraform.io/terraform-providers/ignition/
wget https://github.com/community-terraform-providers/terraform-provider-ignition/releases/download/v2.1.0/terraform-provider-ignition_2.1.0_$PLATFORM.zip -P $PLUGIN_PATH/registry.terraform.io/terraform-providers/ignition/
```


## On IBM Power Systems
Download Terraform for IBM Power Systems from https://www.power-devops.com/terraform

Install latest go from https://golang.org/dl/ and set your GOPATH
**Terraform** binary on IBM Power is not available for download. You will need to install it from source by running:

```
TAG_VERSION=v0.13.2
git clone https://github.com/hashicorp/terraform --branch $TAG $GOPATH/src/github.com/hashicorp/terraform
cd $GOPATH/src/github.com/hashicorp/terraform
TF_DEV=1 scripts/build.sh
```

Validate using:
```
mkdir -p ~/.terraform.d/plugins/
$GOPATH/bin/terraform version
```


Identify your platform. All example commands assume Linux as a platform:

> Linux: linux_ppc64le

Identify your Terraform plugin directory. You will need to create the directory on your client machine:

> Linux: ~/.local/share/terraform/plugins OR /usr/local/share/terraform/plugins OR /usr/share/terraform/plugins.

Make sure to change `PLATFORM` and `PLUGIN_PATH` values based on your client machine.

**terraform-provider-libvirt**: Please refer to the section below for instructions on installing the libvirt provider plugin. For [more information](https://github.com/dmacvicar/terraform-provider-libvirt#building-from-source).

```
PLATFORM=linux_ppc64le
PLUGIN_PATH=~/.local/share/terraform/plugins

#Install the Libvirt provider plugin:
git clone https://github.com/dmacvicar/terraform-provider-libvirt $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
cd $GOPATH/src/github.com/dmacvicar/terraform-provider-libvirt
make install
cp $GOPATH/bin/terraform-provider-libvirt ~/.terraform.d/plugins/terraform-provider-libvirt
cd -

# Create plugin directory and copy the binary
mkdir -p $PLUGIN_PATH/registry.terraform.io/dmacvicar/libvirt/1.0.0/$PLATFORM/
cp $GOPATH/bin/terraform-provider-libvirt $PLUGIN_PATH/registry.terraform.io/dmacvicar/libvirt/1.0.0/$PLATFORM/terraform-provider-libvirt
```

**terraform-provider-random >=2.3, <3.0**: Please refer to the section below for instructions on installing the random provider plugin. For [more information](https://github.com/hashicorp/terraform-provider-random#building-the-provider).

**terraform-provider-random**: Please refer to the section below for instructions on installing the random provider plugin. For [more information](https://github.com/hashicorp/terraform-provider-random#building-the-provider).

Note: Set `VERSION` to a compatible version eg. 2.3.0

```
git clone --branch <TAG> https://github.com/terraform-providers/terraform-provider-random $GOPATH/src/github.com/terraform-providers/terraform-provider-random
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-random
VERSION=2.3.0
PLATFORM=linux_ppc64le
PLUGIN_PATH=~/.local/share/terraform/plugins

#Install the random provider plugin:
git clone https://github.com/hashicorp/terraform-provider-random --branch v$VERSION $GOPATH/src/github.com/hashicorp/terraform-provider-random
cd $GOPATH/src/github.com/hashicorp/terraform-provider-random
make build
cp $GOPATH/bin/terraform-provider-random ~/.terraform.d/plugins/terraform-provider-random_<TAG>
cd -

Note: Set <TAG> to compatible version eg. v2.3.0
# Create plugin directory and copy the binary
mkdir -p $PLUGIN_PATH/registry.terraform.io/hashicorp/random/$VERSION/$PLATFORM/
cp $GOPATH/bin/terraform-provider-random $PLUGIN_PATH/registry.terraform.io/hashicorp/random/$VERSION/$PLATFORM/terraform-provider-random
```

**terraform-provider-ignition >=1.2, <2.0**: Please refer to the section below for instructions on installing the ignition provider plugin. For [more information](https://github.com/terraform-providers/terraform-provider-ignition#building-the-provider).

**terraform-provider-ignition**: Please refer to the section below for instructions on installing the ignition provider plugin. For [more information](https://github.com/community-terraform-providers/terraform-provider-ignition#building-the-provider).

Note: Set `VERSION` to a compatible version eg. 2.1.0

```
git clone --branch <TAG> https://github.com/terraform-providers/terraform-provider-ignition $GOPATH/src/github.com/terraform-providers/terraform-provider-ignition
VERSION=2.1.0
PLATFORM=linux_ppc64le
PLUGIN_PATH=~/.local/share/terraform/plugins

#Install the ignition provider plugin:
git clone https://github.com/community-terraform-providers/terraform-provider-ignition --branch v$VERSION $GOPATH/src/github.com/terraform-providers/terraform-provider-ignition
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-ignition
make build
cp $GOPATH/bin/terraform-provider-ignition ~/.terraform.d/plugins/terraform-provider-ignition_<TAG>
cd -

Note: Set <TAG> to compatible version eg. v1.2.1
# Create plugin directory and copy the binary
mkdir -p $PLUGIN_PATH/registry.terraform.io/terraform-providers/ignition/$VERSION/$PLATFORM/
cp $GOPATH/bin/terraform-provider-ignition $PLUGIN_PATH/registry.terraform.io/terraform-providers/ignition/$VERSION/$PLATFORM/terraform-provider-ignition
```

**terraform-provider-null >=2.1, <3.0**: Please refer to the section below for instructions on installing the null provider plugin. For [more information](https://github.com/hashicorp/terraform-provider-null#building-the-provider).

**terraform-provider-null**: Please refer to the section below for instructions on installing the null provider plugin. For [more information](https://github.com/hashicorp/terraform-provider-null#building-the-provider).

Note: Set `VERSION` to a compatible version eg. 2.1.2

```
git clone --branch <TAG> https://github.com/terraform-providers/terraform-provider-null $GOPATH/src/github.com/terraform-providers/terraform-provider-null
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-null
VERSION=2.1.2
PLATFORM=linux_ppc64le
PLUGIN_PATH=~/.local/share/terraform/plugins

#Install the null provider plugin:
git clone https://github.com/hashicorp/terraform-provider-null --branch v$VERSION $GOPATH/src/github.com/hashicorp/terraform-provider-null
cd $GOPATH/src/github.com/hashicorp/terraform-provider-null
make build
cp $GOPATH/bin/terraform-provider-null ~/.terraform.d/plugins/terraform-provider-null_<TAG>
cd -

Note: Set <TAG> to compatible version eg. v2.1.2
# Create plugin directory and copy the binary
mkdir -p $PLUGIN_PATH/registry.terraform.io/hashicorp/null/$VERSION/$PLATFORM/
cp $GOPATH/bin/terraform-provider-null $PLUGIN_PATH/registry.terraform.io/hashicorp/null/$VERSION/$PLATFORM/terraform-provider-null
```


Upon successful completion. Please follow the instructions outlined here
https://github.com/ocp-power-automation/ocp4-upi-kvm/blob/master/docs/quickstart.md#start-install

16 changes: 16 additions & 0 deletions modules/1_prepare/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
null = {
source = "hashicorp/null"
version = "~> 2.1"
}
random = {
source = "hashicorp/random"
version = "~> 2.3"
}
}
required_version = "~> 0.13"
}
15 changes: 7 additions & 8 deletions modules/4_nodes/nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ resource "libvirt_volume" "rhcos_base" {
pool = var.storage_pool_name
}


# volumes
resource "libvirt_volume" "bootstrap" {
name = "${var.cluster_id}-bootstrap"
Expand All @@ -53,7 +52,7 @@ resource "libvirt_volume" "worker" {

# hostname-ignitions
data "ignition_file" "b_hostname" {
filesystem = "root"
overwrite = true
mode = "420" // 0644
path = "/etc/hostname"
content {
Expand All @@ -64,7 +63,7 @@ EOF
}
data "ignition_file" "m_hostname" {
count = var.master["count"]
filesystem = "root"
overwrite = true
mode = "420" // 0644
path = "/etc/hostname"
content {
Expand All @@ -75,7 +74,7 @@ EOF
}
data "ignition_file" "w_hostname" {
count = var.worker["count"]
filesystem = "root"
overwrite = true
mode = "420" // 0644
path = "/etc/hostname"

Expand All @@ -89,7 +88,7 @@ EOF

# ignitions
data "ignition_config" "bootstrap" {
append {
merge {
source = "http://${var.bastion_ip}:8080/ignition/bootstrap.ign"
}
files = [
Expand All @@ -98,7 +97,7 @@ data "ignition_config" "bootstrap" {
}
data "ignition_config" "master" {
count = var.master["count"]
append {
merge {
source = "http://${var.bastion_ip}:8080/ignition/master.ign"
}
files = [
Expand All @@ -107,7 +106,7 @@ data "ignition_config" "master" {
}
data "ignition_config" "worker" {
count = var.worker["count"]
append {
merge {
source = "http://${var.bastion_ip}:8080/ignition/worker.ign"
}
files = [
Expand Down Expand Up @@ -221,4 +220,4 @@ resource "null_resource" "worker_ip" {
triggers = {
address = cidrhost(var.network_cidr, local.first_worker_ip + count.index)
}
}
}
16 changes: 16 additions & 0 deletions modules/4_nodes/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_providers {
ignition = {
source = "terraform-providers/ignition"
version = "~> 2.1"
}
libvirt = {
source = "dmacvicar/libvirt"
}
null = {
source = "hashicorp/null"
version = "~> 2.1"
}
}
required_version = "~> 0.13"
}
9 changes: 9 additions & 0 deletions modules/5_install/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "~> 2.1"
}
}
required_version = "~> 0.13"
}
9 changes: 0 additions & 9 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
#
################################################################

terraform {
required_version = "~> 0.12.2"
required_providers {
ignition = "~> 1.2"
null = "~> 2.1"
random = "~> 2.3"
}
}

provider "libvirt" {
uri = var.libvirt_uri
}
Expand Down
4 changes: 2 additions & 2 deletions var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ rhel_subscription_username = ""
rhel_subscription_password = ""

### OpenShift variables
openshift_install_tarball = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/stable-4.4/openshift-install-linux.tar.gz"
openshift_client_tarball = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/stable-4.4/openshift-client-linux.tar.gz"
# openshift_install_tarball = ""
# openshift_client_tarball = ""

#release_image_override = ""

Expand Down
8 changes: 4 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ variable "installer_log_level" {
variable "helpernode_tag" {
description = "Set the branch/tag name or commit# for using ocp4-helpernode repo"
# Checkout level for https://github.com/RedHatOfficial/ocp4-helpernode which is used for setting up services required on bastion node
default = "fddbbc651153ef2966e5cb4d4167990b31c01ceb"
default = "5eab3db53976bb16be582f2edc2de02f7510050d"
}

variable "install_playbook_tag" {
description = "Set the branch/tag name or commit# for using ocp4-playbooks repo"
# Checkout level for https://github.com/ocp-power-automation/ocp4-playbooks which is used for running ocp4 installations steps
default = "02a598faa332aa2c3d53e8edd0e840440ff74bd5"
default = "b988d620bd70284c7674e7a94e107c456c940dd0"
}

variable "ansible_extra_options" {
Expand All @@ -176,11 +176,11 @@ locals {
### OpenShift variables
################################################################
variable "openshift_install_tarball" {
default = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/stable-4.4/openshift-install-linux.tar.gz"
default = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp-dev-preview/latest-4.6/openshift-install-linux.tar.gz"
}

variable "openshift_client_tarball" {
default = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/stable-4.4/openshift-client-linux.tar.gz"
default = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp-dev-preview/latest-4.6/openshift-client-linux.tar.gz"
}

variable "release_image_override" {
Expand Down
12 changes: 12 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
random = {
source = "hashicorp/random"
version = "~> 2.3"
}
}
required_version = ">= 0.13"
}