Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rhel8 in attach script #4033

Merged
merged 7 commits into from
Oct 17, 2022
49 changes: 30 additions & 19 deletions ibm/service/satellite/data_source_ibm_satellite_host_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,37 +165,48 @@ func dataSourceIBMSatelliteAttachHostScriptRead(d *schema.ResourceData, meta int
//if this is a RHEL host, continue with custom script
if !coreos_enabled {
for i, line := range lines {
if strings.Contains(line, "API_URL=") {
if strings.Contains(line, `export OPERATING_SYSTEM`) {
i = i + 1
if script, ok := d.GetOk("custom_script"); ok {
lines[i] = script.(string)
} else {
if strings.ToLower(hostProvider) == "aws" {
lines[i] = "yum update -y\nyum-config-manager --enable '*'\nyum repolist all\nyum install container-selinux -y"
lines[i] = `
yum-config-manager --enable '*'
yum install container-selinux -y
`
} else if strings.ToLower(hostProvider) == "ibm" {
lines[i] = `subscription-manager refresh
subscription-manager repos --enable rhel-server-rhscl-7-rpms
subscription-manager repos --enable rhel-7-server-optional-rpms
subscription-manager repos --enable rhel-7-server-rh-common-rpms
subscription-manager repos --enable rhel-7-server-supplementary-rpms
subscription-manager repos --enable rhel-7-server-extras-rpms`
lines[i] = `
subscription-manager refresh
if [[ "${OPERATING_SYSTEM}" == "RHEL7" ]]; then
subscription-manager repos --enable rhel-server-rhscl-7-rpms
subscription-manager repos --enable rhel-7-server-optional-rpms
subscription-manager repos --enable rhel-7-server-rh-common-rpms
subscription-manager repos --enable rhel-7-server-supplementary-rpms
subscription-manager repos --enable rhel-7-server-extras-rpms
elif [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then
subscription-manager repos --enable rhel-8-for-x86_64-baseos-rpms
subscription-manager repos --enable rhel-8-for-x86_64-appstream-rpms;
fi
yum install container-selinux -y`
} else if strings.ToLower(hostProvider) == "azure" {
lines[i] = fmt.Sprintf(`yum update --disablerepo=* --enablerepo="*microsoft*" -y
yum-config-manager --enable '*'
yum repolist all
lines[i] = `
if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
update-alternatives --set python3 /usr/bin/python3.8
fi
yum install container-selinux -y
`)
`
} else if strings.ToLower(hostProvider) == "google" {
lines[i] = fmt.Sprintf(`yum update --disablerepo=* --enablerepo="*" -y
yum repolist all
lines[i] = `
if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
update-alternatives --set python3 /usr/bin/python3.8
fi
yum install container-selinux -y
yum install subscription-manager -y
`)
} else {
lines[i] = "subscription-manager refresh\nyum update -y\n"
`
}
}

}
}
}
Expand Down