diff --git a/modules/1_bastion/bastion.tf b/modules/1_bastion/bastion.tf index b90db6e2f..00ead53f3 100644 --- a/modules/1_bastion/bastion.tf +++ b/modules/1_bastion/bastion.tf @@ -218,8 +218,34 @@ EOF } } +resource "null_resource" "enable_repos" { + count = ( var.rhel_subscription_username == "" || var.rhel_subscription_username == "" ) && var.rhel_subscription_org == "" ? 0 : 1 + depends_on = [null_resource.bastion_init, null_resource.setup_proxy_info, null_resource.bastion_register] + + connection { + type = "ssh" + user = var.rhel_username + host = openstack_compute_instance_v2.bastion.access_ip_v4 + private_key = var.private_key + agent = var.ssh_agent + timeout = "${var.connection_timeout}m" + } + + provisioner "remote-exec" { + inline = [<" ]] ) && [[ -z "${var.rhel_subscription_org}" ]]; then + sudo yum install -y epel-release +else + sudo subscription-manager repos --enable ${var.ansible_repo_name} +fi +EOF + ] + } +} + resource "null_resource" "bastion_packages" { - depends_on = [null_resource.bastion_init, null_resource.setup_proxy_info, null_resource.bastion_register] + depends_on = [null_resource.bastion_init, null_resource.setup_proxy_info, null_resource.bastion_register, null_resource.enable_repos] connection { type = "ssh" user = var.rhel_username @@ -237,7 +263,7 @@ resource "null_resource" "bastion_packages" { } provisioner "remote-exec" { inline = [ - "pip3 install ansible -q" + "sudo yum install -y ansible" ] } provisioner "remote-exec" { diff --git a/modules/1_bastion/variables.tf b/modules/1_bastion/variables.tf index a4db6b574..fd57071d0 100644 --- a/modules/1_bastion/variables.tf +++ b/modules/1_bastion/variables.tf @@ -48,6 +48,7 @@ variable "rhel_subscription_username" {} variable "rhel_subscription_password" {} variable "rhel_subscription_org" {} variable "rhel_subscription_activationkey" {} +variable "ansible_repo_name" {} variable "storage_type" {} variable "volume_size" {} diff --git a/ocp.tf b/ocp.tf index 3641e61d0..23745941c 100644 --- a/ocp.tf +++ b/ocp.tf @@ -59,6 +59,7 @@ module "bastion" { rhel_subscription_password = var.rhel_subscription_password rhel_subscription_org = var.rhel_subscription_org rhel_subscription_activationkey = var.rhel_subscription_activationkey + ansible_repo_name = var.ansible_repo_name storage_type = var.storage_type volume_size = var.volume_size volume_storage_template = var.volume_storage_template diff --git a/var.tfvars b/var.tfvars index ea0363ebe..d788e8de8 100644 --- a/var.tfvars +++ b/var.tfvars @@ -59,6 +59,7 @@ cluster_id = "" #installer_log_level = "info" #ansible_extra_options = "-v" +#ansible_repo_name = "ansible-2.9-for-rhel-8-ppc64le-rpms" #dns_forwarders = "1.1.1.1; 9.9.9.9" #rhcos_kernel_options = [] #chrony_config = true diff --git a/variables.tf b/variables.tf index 3f9097d68..ce251858f 100644 --- a/variables.tf +++ b/variables.tf @@ -246,6 +246,10 @@ variable "ansible_extra_options" { default = "-v" } +variable "ansible_repo_name" { + default = "ansible-2.9-for-rhel-8-ppc64le-rpms" +} + locals { private_key_file = var.private_key_file == "" ? "${path.cwd}/data/id_rsa" : var.private_key_file public_key_file = var.public_key_file == "" ? "${path.cwd}/data/id_rsa.pub" : var.public_key_file