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

Option to use guest cpu mode #26

Merged
merged 1 commit into from
Jul 27, 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
3 changes: 2 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Update the following variables specific to your cluster requirement. All the var

Update the following variables specific to the nodes.

* `cpu_mode` : (Optional) Guest CPU mode value. Eg: custom, host-passthrough, host-model.
* `network_cidr` : (Optional) Network subnet range for the cluster. Ensure it is unique for each cluster on the same host. Default is set to '192.168.27.0/24'.
* `rhel_username` : (Optional) The user that we should use for the connection to the bastion host. Default is set to 'root'.
* `rhel_password` : (Optional) The password for above username for the connection to the bastion host initially. Leave empty if ssh-key is already set on bastion_image.
Expand All @@ -61,7 +62,7 @@ Update the following variables specific to the nodes.
* `private_key_file` : (Optional) Corresponding private key file. Default path is '~/.ssh/id_rsa'.
* `private_key` : (Optional) The contents of an SSH key to use for the connection. Ignored if `public_key_file` is provided.
* `public_key` :(Optional) The contents of corresponding key to use for the connection. Ignored if `public_key_file` is provided.
* `rhel_subscription_username` : (Optional) The username required for RHEL subcription on bastion host. Leave empty if repos are already set in the bastion_imageyy and subscription is not needed.
* `rhel_subscription_username` : (Optional) The username required for RHEL subcription on bastion host. Leave empty if repos are already set in the bastion_image and subscription is not needed.
* `rhel_subscription_password` : (Optional) The password required for RHEL subcription on bastion host.

### Setup OpenShift Variables
Expand Down
14 changes: 1 addition & 13 deletions modules/1_prepare/prepare.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ resource "libvirt_domain" "bastion" {
}

cpu = {
mode = "host-passthrough"
mode = var.cpu_mode
}

network_interface {
Expand Down Expand Up @@ -146,18 +146,6 @@ then
sudo subscription-manager refresh
sudo subscription-manager attach --auto
fi
EOF
]
}
provisioner "remote-exec" {
when = destroy
on_failure = continue
inline = [<<EOF
if [ '${var.rhel_subscription_username}' != '' ]
then
sudo subscription-manager unregister
sudo subscription-manager remove --all
fi
EOF
]
}
Expand Down
3 changes: 3 additions & 0 deletions modules/1_prepare/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ variable "bastion" {
vcpu = 2
}
}

variable "cpu_mode" {}

variable "bastion_image" { default = "file:///home/libvirt/images/bastion.qcow2" }

variable "rhel_username" {}
Expand Down
6 changes: 3 additions & 3 deletions modules/4_nodes/nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ resource "libvirt_domain" "bootstrap" {
target_port = 0
}
cpu = {
mode = "host-passthrough"
mode = var.cpu_mode
}
network_interface {
network_id = var.network_id
Expand All @@ -177,7 +177,7 @@ resource "libvirt_domain" "master" {
target_port = 0
}
cpu = {
mode = "host-passthrough"
mode = var.cpu_mode
}
network_interface {
network_id = var.network_id
Expand All @@ -201,7 +201,7 @@ resource "libvirt_domain" "worker" {
target_port = 0
}
cpu = {
mode = "host-passthrough"
mode = var.cpu_mode
}
network_interface {
network_id = var.network_id
Expand Down
2 changes: 2 additions & 0 deletions modules/4_nodes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ variable "worker" {
}
}

variable "cpu_mode" {}

variable "rhcos_image" {}
variable "storage_pool_name" {}
variable "network_cidr" {}
Expand Down
2 changes: 2 additions & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module "prepare" {
cluster_domain = var.cluster_domain
cluster_id = "${random_id.label.hex}"
bastion = var.bastion
cpu_mode = var.cpu_mode
bastion_image = var.bastion_image
rhel_username = var.rhel_username
rhel_password = var.rhel_password
Expand All @@ -61,6 +62,7 @@ module "nodes" {
bootstrap = var.bootstrap
master = var.master
worker = var.worker
cpu_mode = var.cpu_mode
rhcos_image = var.rhcos_image
storage_pool_name = module.prepare.storage_pool_name
network_cidr = var.network_cidr
Expand Down
1 change: 1 addition & 0 deletions var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bastion = { memory = 8192, vcpu = 2 }
bootstrap = { memory = 8192, vcpu = 4, count = 1 }
master = { memory = 16384, vcpu = 4, count = 3 }
worker = { memory = 16384, vcpu = 4, count = 2 }
cpu_mode = ""
network_cidr = "192.168.88.0/24"
rhel_username = "root"
rhel_password = "123456"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ variable "worker" {
}
}

variable "cpu_mode" {
description = "Optional guest CPU mode value. Eg: custom, host-passthrough, host-model"
default = ""
}

variable "network_cidr" {
description = "Network subnet range for the cluster nodes"
default = "192.168.27.0/24"
Expand Down