Skip to content

Commit

Permalink
Change Ansible installation to use yum
Browse files Browse the repository at this point in the history
Signed-off-by: Yussuf Shaikh <[email protected]>
  • Loading branch information
yussufsh committed Dec 18, 2020
1 parent cb90044 commit ea20180
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/var.tfvars-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 31 additions & 5 deletions modules/1_prepare/prepare.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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 = [<<EOF
# Additional repo for installing ansible package
if [[ -z "${var.rhel_subscription_username}" ]] || [[ "${var.rhel_subscription_username}" == "<subscription-id>" ]]; 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" {
Expand All @@ -271,6 +292,11 @@ resource "null_resource" "bastion_packages" {
"sudo systemctl enable NetworkManager"
]
}
provisioner "remote-exec" {
inline = [
"sudo yum install -y ansible"
]
}
}

locals {
Expand Down
1 change: 1 addition & 0 deletions modules/1_prepare/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ variable "ssh_agent" {}

variable "rhel_subscription_username" {}
variable "rhel_subscription_password" {}
variable "ansible_repo_name" {}

variable "rhel_smt" {}

Expand Down
1 change: 1 addition & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ rhel_subscription_username = "<subscription-id>" #Leave this as-is i
rhel_subscription_password = "<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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit ea20180

Please sign in to comment.