Skip to content

Commit

Permalink
Move product version declaration to base (#1713)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximenoel8 authored Oct 2, 2024
1 parent afdf375 commit aed8598
Show file tree
Hide file tree
Showing 37 changed files with 91 additions and 75 deletions.
2 changes: 2 additions & 0 deletions backend_modules/aws/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ locals {
overwrite_fqdn = local.route53_domain == null ? local.provider_settings["overwrite_fqdn"] : "${var.base_configuration["name_prefix"]}${var.name}.${var.base_configuration["route53_domain"]}"
route53_zone_id = lookup(var.base_configuration, "route53_zone_id", null)
route53_domain = lookup(var.base_configuration, "route53_domain", null)
product_version = var.product_version != null ? var.product_version : var.base_configuration["product_version"]
resource_name_prefix = "${var.base_configuration["name_prefix"]}${var.name}"
Expand Down Expand Up @@ -245,6 +246,7 @@ resource "null_resource" "host_salt_configuration" {
use_ntp = var.base_configuration["use_ntp"]
testsuite = var.base_configuration["testsuite"]
roles = var.roles
product_version = local.product_version
use_os_released_updates = var.use_os_released_updates
additional_repos = var.additional_repos
additional_repos_only = var.additional_repos_only
Expand Down
10 changes: 6 additions & 4 deletions backend_modules/azure/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ locals {
public_security_group_id = var.base_configuration.public_security_group_id
private_security_group_id = var.base_configuration.private_security_group_id
private_additional_security_group_id = var.base_configuration.private_additional_security_group_id
resource_group_name = var.base_configuration.resource_group_name
resource_name_prefix = "${var.base_configuration["name_prefix"]}${var.name}"
public_instance = lookup(var.provider_settings, "public_instance", false)
location = var.base_configuration["location"]
resource_group_name = var.base_configuration.resource_group_name
resource_name_prefix = "${var.base_configuration["name_prefix"]}${var.name}"
public_instance = lookup(var.provider_settings, "public_instance", false)
location = var.base_configuration["location"]
product_version = var.product_version != null ? var.product_version : var.base_configuration["product_version"]
}

data "template_file" "user_data" {
Expand Down Expand Up @@ -181,6 +182,7 @@ resource "azurerm_virtual_machine_data_disk_attachment" "addtionaldisks-attach"
use_ntp = var.base_configuration["use_ntp"]
testsuite = var.base_configuration["testsuite"]
roles = var.roles
product_version = local.product_version
use_os_released_updates = var.use_os_released_updates
additional_repos = var.additional_repos
additional_repos_only = var.additional_repos_only
Expand Down
3 changes: 2 additions & 1 deletion backend_modules/feilong/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
name_prefix = var.base_configuration["name_prefix"]
domain = var.base_configuration["domain"]
ssh_key_path = var.base_configuration["ssh_key_path"]
product_version = var.product_version != null ? var.product_version : var.base_configuration["product_version"]
provider_settings = merge({
userid = null
memory = "2G"
Expand Down Expand Up @@ -61,7 +62,7 @@ resource "null_resource" "provisioning" {
use_avahi = false
provider = "feilong"
roles = var.roles
product_version = var.product_version
product_version = local.product_version
use_os_released_updates = var.use_os_released_updates
additional_repos = var.additional_repos
additional_repos_only = var.additional_repos_only
Expand Down
6 changes: 3 additions & 3 deletions backend_modules/libvirt/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ output "configuration" {
additional_network = local.additional_network
additional_network_id = join(",", libvirt_network.additional_network.*.id)

pool = local.pool
network_name = local.bridge == null ? local.network_name : null
bridge = local.bridge
pool = local.pool
network_name = local.bridge == null ? local.network_name : null
bridge = local.bridge
bastion_host = lookup(var.provider_settings, "bastion_host", null)
bastion_host_key = lookup(var.provider_settings, "bastion_host_key", null)
bastion_port = lookup(var.provider_settings, "bastion_port", null)
Expand Down
3 changes: 2 additions & 1 deletion backend_modules/libvirt/host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {
}
]
container_runtime = lookup(var.grains, "container_runtime", "")
product_version = lookup(var.grains, "product_version", "")
product_version = var.product_version != null ? var.product_version : var.base_configuration["product_version"]

combustion = contains(local.combustion_images, var.image)
provider_settings = merge({
Expand Down Expand Up @@ -298,6 +298,7 @@ resource "null_resource" "provisioning" {
additional_certs = var.additional_certs
additional_packages = var.additional_packages
swap_file_size = var.swap_file_size
product_version = local.product_version
authorized_keys = concat(
var.base_configuration["ssh_key_path"] != null ? [trimspace(file(var.base_configuration["ssh_key_path"]))] : [],
var.ssh_key_path != null ? [trimspace(file(var.ssh_key_path))] : [],
Expand Down
2 changes: 2 additions & 0 deletions backend_modules/null/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resource "null_resource" "base" {
triggers = {
cc_username = var.cc_username
cc_password = var.cc_password
product_version = var.product_version
timezone = var.timezone
use_ntp = var.use_ntp
ssh_key_path = var.ssh_key_path
Expand Down Expand Up @@ -33,5 +34,6 @@ output "configuration" {
name_prefix = var.name_prefix
use_shared_resources = var.use_shared_resources
testsuite = var.testsuite
product_version = var.product_version
}
}
5 changes: 5 additions & 0 deletions backend_modules/null/base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ variable "is_server_paygo_instance" {
type = bool
default = false
}

variable "product_version" {
description = "One of: 4.3-nightly, 4.3-released, 4.3-pr, 4.3-beta, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
type = string
}
4 changes: 2 additions & 2 deletions backend_modules/null/host/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ variable "volume_provider_settings" {
}

variable "product_version" {
description = "One of: 4.3-nightly, 4.3-released, 4.3-pr, 4.3-beta, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
description = "One of: 4.3-released, 4.3-nightly, 4.3-pr, 4.3-beta, 4.3-build_image, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
type = string
default = "5.0-released"
default = null
}
5 changes: 3 additions & 2 deletions backend_modules/ssh/host/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
resource_name_prefix = "${var.base_configuration["name_prefix"]}${var.name}"

provider_settings = merge({
product_version = var.product_version != null ? var.product_version : var.base_configuration["product_version"]
provider_settings = merge({
host = null
user = "root"
password = "linux"
Expand Down Expand Up @@ -85,6 +85,7 @@ resource "null_resource" "provisioning" {
timezone = var.base_configuration["timezone"]
use_ntp = var.base_configuration["use_ntp"]
testsuite = var.base_configuration["testsuite"]
product_version = local.product_version
roles = var.roles
use_os_released_updates = var.use_os_released_updates
install_salt_bundle = var.install_salt_bundle
Expand Down
2 changes: 2 additions & 0 deletions main.tf.aws-create-mirror-snapshot.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ locals {
name_prefix = "mirrorsnap-"
region = "eu-west-2"
availability_zone = "${local.region}a"
product_version = "5.0-released"
ssh_allowed_ips = [""] // add your IP address in here
}

Expand All @@ -36,6 +37,7 @@ module "base" {
cc_password = local.cc_password

name_prefix = local.name_prefix
product_version = local.product_version

provider_settings = {
availability_zone = local.availability_zone
Expand Down
3 changes: 1 addition & 2 deletions main.tf.aws.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "base" {
cc_password = ...

name_prefix = ... // if you use name_prefix, make sure to update the server_configuration for clients/minions below
product_version = "uyuni-release"

provider_settings = {
availability_zone = local.availability_zone
Expand Down Expand Up @@ -67,7 +68,6 @@ module "server" {

name = "server"
image = "opensuse154o"
product_version = "uyuni-release"

provider_settings = { }
}
Expand All @@ -79,7 +79,6 @@ module "minion" {
name = "minion"
image = "opensuse154o"
server_configuration = module.server.configuration
product_version = "uyuni-release"
}

output "key_file" {
Expand Down
4 changes: 1 addition & 3 deletions main.tf.azure.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module "base" {

name_prefix = local.name_prefix
// if you use name_prefix, make sure to update the server_configuration for clients/minions below

product_version = "uyuni-release"
provider_settings = {
location = local.location
ssh_allowed_ips = "*"
Expand Down Expand Up @@ -65,7 +65,6 @@ module "server" {

name = "server"
image = "suma41"
product_version = "suma41"


provider_settings = {
Expand All @@ -82,7 +81,6 @@ module "minion" {
name = "minion"
image = "opensuse154"
server_configuration = module.server.configuration
product_version = "uyuni-release"
}

output "key_file" {
Expand Down
3 changes: 1 addition & 2 deletions main.tf.libvirt.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "base" {
// Set SUSE Customer Center credentials here if you have some
// cc_username = ""
// cc_password = ""
product_version = "uyuni-master"

// optional parameters with defaults below
// use_avahi = true
Expand All @@ -40,7 +41,6 @@ module "server" {
base_configuration = module.base.configuration

name = "server"
product_version = "uyuni-master"
// see modules/server_containerized/variables.tf for possible values

// connect_to_additional_network = true
Expand All @@ -66,6 +66,5 @@ module "minion" {
name = "minion"
image = "opensuse155o"
server_configuration = module.server.configuration
product_version = module.server.configuration.product_version
// see modules/minion/variables.tf for possible values
}
3 changes: 1 addition & 2 deletions main.tf.libvirt.example.Manager-43
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "base" {
// Set SUSE Customer Center credentials here if you have some
// cc_username = ""
// cc_password = ""
product_version = "4.3-nightly"

// optional parameters with defaults below
// use_avahi = true
Expand All @@ -40,7 +41,6 @@ module "server" {
base_configuration = module.base.configuration

name = "server"
product_version = "4.3-nightly"
// see modules/server_containerized/variables.tf for possible values

// connect_to_additional_network = true
Expand All @@ -54,6 +54,5 @@ module "minion" {
name = "minion"
image = "sles15sp4o"
server_configuration = module.server.configuration
product_version = module.server.configuration.product_version
// see modules/minion/variables.tf for possible values
}
2 changes: 1 addition & 1 deletion main.tf.ssh.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module "base" {

cc_username = "UC7"
cc_password = ...
product_version = "4.3-nightly"

// optional parameters with defaults below
// use_avahi = true
Expand All @@ -20,7 +21,6 @@ module "server" {
base_configuration = module.base.configuration

name = "server"
product_version = "4.3-nightly"
// see modules/suse_manager/variables.tf for possible values

// connect_to_additional_network = true
Expand Down
2 changes: 2 additions & 0 deletions modules/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module "base_backend" {

cc_username = var.cc_username
cc_password = var.cc_password
product_version = var.product_version
timezone = var.timezone
use_ntp = var.use_ntp
ssh_key_path = var.ssh_key_path
Expand All @@ -23,6 +24,7 @@ output "configuration" {
value = merge({
cc_username = var.cc_username
cc_password = var.cc_password
product_version = var.product_version
timezone = var.timezone
use_ntp = var.use_ntp
ssh_key_path = var.ssh_key_path
Expand Down
4 changes: 1 addition & 3 deletions modules/build_host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ module "build_host" {
roles = ["build_host"]
disable_firewall = var.disable_firewall
grains = {
product_version = var.product_version
mirror = var.base_configuration["mirror"]
mirror = var.base_configuration["mirror"]
server = var.server_configuration["hostname"]
auto_connect_to_master = var.auto_connect_to_master
avahi_reflector = var.avahi_reflector
sles_registration_code = var.sles_registration_code
}


image = var.image
provider_settings = var.provider_settings
}
Expand Down
5 changes: 3 additions & 2 deletions modules/build_host/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ variable "name" {
}

variable "product_version" {
description = "A valid SUSE Manager version (eg. 4.3-nightly, head) see README_ADVANCED.md"
default = "released"
description = "One of: 4.3-released, 4.3-nightly, 4.3-pr, 4.3-beta, 4.3-build_image, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
type = string
default = null
}

variable "server_configuration" {
Expand Down
2 changes: 1 addition & 1 deletion modules/client/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module "client" {
connect_to_additional_network = false
roles = ["client"]
disable_firewall = var.disable_firewall
product_version = var.product_version
grains = {
product_version = var.product_version
mirror = var.base_configuration["mirror"]
server = var.server_configuration["hostname"]
auto_register = var.auto_register
Expand Down
5 changes: 3 additions & 2 deletions modules/client/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ variable "name" {
}

variable "product_version" {
description = "A valid SUSE Manager version (eg. 4.3-nightly) see README_ADVANCED.md"
default = "released"
description = "One of: 4.3-released, 4.3-nightly, 4.3-pr, 4.3-beta, 4.3-build_image, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
type = string
default = null
}

variable "server_configuration" {
Expand Down
4 changes: 2 additions & 2 deletions modules/controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ module "controller" {
connect_to_base_network = true
connect_to_additional_network = false
roles = ["controller"]
product_version = var.product_version
grains = {
cc_username = var.base_configuration["cc_username"]
cc_password = var.base_configuration["cc_password"]
git_username = var.git_username
git_password = var.git_password
git_repo = var.git_repo
branch = var.branch == "default" ? var.testsuite-branch[var.server_configuration["product_version"]] : var.branch
branch = var.branch == "default" ? var.testsuite-branch[var.base_configuration["product_version"]] : var.branch
mirror = var.no_mirror == true ? null : var.base_configuration["mirror"]
product_version = var.product_version

server = var.server_configuration["hostname"]
proxy = var.proxy_configuration["hostname"]
Expand Down
5 changes: 3 additions & 2 deletions modules/controller/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ variable "server_instance_id" {
}

variable "product_version" {
description = "A valid SUSE Manager version (eg. 4.3-nightly, head) see README_ADVANCED.md"
default = "released"
description = "One of: 4.3-released, 4.3-nightly, 4.3-pr, 4.3-beta, 4.3-build_image, 4.3-VM-nightly, 4.3-VM-released, 5.0-nightly, 5.0-released, head, uyuni-master, uyuni-released, uyuni-pr"
type = string
default = null
}
Loading

0 comments on commit aed8598

Please sign in to comment.