IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
342 stars 673 forks source link

Satellite Host Attach Configuration Adds Incorrect Repos #3576

Closed jmkanz closed 2 years ago

jmkanz commented 2 years ago

ISSUE:

The current Terraform Provider for the Satellite service has incorrect source code located here. The data_source that configures the satellite host attach script incorrectly enables all repos to be added when IBM is selected as the provider.

On line 140 - 141, the logic shows that if IBM is chosen as the provider, the host should enable all repos via subscription-manager:

for i, line := range lines {
        if strings.Contains(line, "API_URL=") {
            i = i + 1
            if strings.ToLower(hostProvider) == "aws" {
                lines[i] = "yum update -y\nyum-config-manager --enable '*'\nyum repolist all\nyum install container-selinux -y"
            } else if strings.ToLower(hostProvider) == "ibm" {
                lines[i] = "subscription-manager refresh\nsubscription-manager repos --enable=*\n"
            } else if strings.ToLower(hostProvider) == "azure" {
                lines[i] = fmt.Sprintf(`yum update --disablerepo=* --enablerepo="*microsoft*" -y

This is causing issues with IBM VSI's in SoftLayer where some of the additional repos are not available and thus host attach fails.

Recommended Solution:

To resolve this issue, I'd recommend having only the required repos enabled when IBM is selected as the provider, such as:

            } else if strings.ToLower(hostProvider) == "ibm" {
                lines[i] = "subscription-manager refresh\nsubscription-manager repos --enable rhel-server-rhscl-7-rpms\nsubscription-manager repos --enable rhel-7-server-optional-rpms\nsubscription-manager repos --enable rhel-7-server-rh-common-rpms\nsubscription-manager repos --enable rhel-7-server-supplementary-rpms\nsubscription-manager repos --enable rhel-7-server-extras-rpms"

The correct repos are documented here for IBM Hosts: https://cloud.ibm.com/docs/satellite?topic=satellite-ibm

jmkanz commented 2 years ago

Added PR#3577 for the fix: https://github.com/IBM-Cloud/terraform-provider-ibm/pull/3577