diff --git a/docs/var.tfvars-doc.md b/docs/var.tfvars-doc.md index 378df4d01..c335998a8 100644 --- a/docs/var.tfvars-doc.md +++ b/docs/var.tfvars-doc.md @@ -207,6 +207,11 @@ This variable can be used when debugging ansible playbooks. ansible_extra_options = "-v" ``` +This variable can be used to change the repository name for installing ansible package on RHEL. +``` +ansible_repo_name = "ansible-2.9-for-rhel-8-ppc64le-rpms" +``` + This variable specifies the external DNS servers to forward DNS queries that cannot be resolved locally. ``` dns_forwarders = "1.1.1.1; 9.9.9.9" diff --git a/modules/1_prepare/prepare.tf b/modules/1_prepare/prepare.tf index 3fd62d049..cebecb1f9 100644 --- a/modules/1_prepare/prepare.tf +++ b/modules/1_prepare/prepare.tf @@ -238,7 +238,7 @@ EOF } } -resource "null_resource" "bastion_packages" { +resource "null_resource" "enable_repos" { count = local.bastion_count depends_on = [null_resource.bastion_init, null_resource.setup_proxy_info, null_resource.bastion_register] @@ -252,14 +252,35 @@ resource "null_resource" "bastion_packages" { } provisioner "remote-exec" { - inline = [ - "#sudo yum update -y --skip-broken", - "sudo yum install -y wget jq git net-tools vim python3 tar" + inline = [<" ]]; then + sudo yum install -y epel-release +else + sudo subscription-manager repos --enable ${var.ansible_repo_name} +fi +EOF ] } +} + +resource "null_resource" "bastion_packages" { + count = local.bastion_count + 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 + host = data.ibm_pi_instance_ip.bastion_public_ip[count.index].external_ip + private_key = var.private_key + agent = var.ssh_agent + timeout = "15m" + } + provisioner "remote-exec" { inline = [ - "pip3 install ansible -q" + "#sudo yum update -y --skip-broken", + "sudo yum install -y wget jq git net-tools vim python3 tar" ] } provisioner "remote-exec" { @@ -271,6 +292,11 @@ resource "null_resource" "bastion_packages" { "sudo systemctl enable NetworkManager" ] } + provisioner "remote-exec" { + inline = [ + "sudo yum install -y ansible" + ] + } } locals { diff --git a/modules/1_prepare/variables.tf b/modules/1_prepare/variables.tf index e404d7205..aa2e32d99 100644 --- a/modules/1_prepare/variables.tf +++ b/modules/1_prepare/variables.tf @@ -38,6 +38,7 @@ variable "ssh_agent" {} variable "rhel_subscription_username" {} variable "rhel_subscription_password" {} +variable "ansible_repo_name" {} variable "rhel_smt" {} diff --git a/ocp.tf b/ocp.tf index 73e4858ea..311a6989e 100644 --- a/ocp.tf +++ b/ocp.tf @@ -35,6 +35,7 @@ module "prepare" { ssh_agent = var.ssh_agent rhel_subscription_username = var.rhel_subscription_username rhel_subscription_password = var.rhel_subscription_password + ansible_repo_name = var.ansible_repo_name rhel_smt = var.rhel_smt storage_type = local.storage_type volume_type = var.volume_type diff --git a/var.tfvars b/var.tfvars index 647c5676f..d66f9606c 100644 --- a/var.tfvars +++ b/var.tfvars @@ -40,7 +40,6 @@ rhel_subscription_username = "" #Leave this as-is i rhel_subscription_password = "" #Leave this as-is if using CentOS as bastion image rhel_smt = 4 - ### OpenShift Installation Details openshift_install_tarball = "https://mirror.openshift.com/pub/openshift-v4/ppc64le/clients/ocp/stable-4.5/openshift-install-linux.tar.gz" @@ -68,6 +67,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 89886e90a..e6bdc5fa7 100644 --- a/variables.tf +++ b/variables.tf @@ -194,6 +194,10 @@ variable "ansible_extra_options" { default = "-v" } +variable "ansible_repo_name" { + default = "ansible-2.9-for-rhel-8-ppc64le-rpms" +} + variable "pull_secret_file" { default = "data/pull-secret.txt" }