Skip to content

Commit

Permalink
new host link endpoint commits (#4970)
Browse files Browse the repository at this point in the history
* new host link endpoint commits

* add host link agent argument and example. Fixed RHEL7 repos to RHEL8

---------

Co-authored-by: Justin Kanz <[email protected]>
  • Loading branch information
jmkanz and Justin Kanz authored Dec 11, 2023
1 parent d05f916 commit d7a0611
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20231204080125-462fa9e436bc
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231116055201-2a84da7b9bd6
github.com/IBM-Cloud/power-go-client v1.5.4
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20231204080125-462fa9e436bc h1:AeooCa6UMW
github.com/IBM-Cloud/bluemix-go v0.0.0-20231204080125-462fa9e436bc/go.mod h1:jIGLnIfj+uBv2ALz3rVHzNbNwt0V/bEWNeJKECa8Q+k=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c h1:tRS4VuOG3lHNG+yrsh3vZZQDVNLuFJB0oZbTJp9YXds=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231116055201-2a84da7b9bd6 h1:QXU1Atl/JSI3ZtYB9tHbWLhrFYE1E+5Iww1sjQ7mqdo=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231116055201-2a84da7b9bd6/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.5.4 h1:fk+QgOdZvwq696UynehfGrMGMHXDYOJfRCE3Pec9o6c=
github.com/IBM-Cloud/power-go-client v1.5.4/go.mod h1:ZsKqKC4d4MAWujkttW1w9tG7xjlIbkIpVENX476ghVY=
Expand Down
11 changes: 11 additions & 0 deletions ibm/service/satellite/data_source_ibm_satellite_host_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func DataSourceIBMSatelliteAttachHostScript() *schema.Resource {
Optional: true,
ExactlyOneOf: []string{"host_provider", "custom_script"},
},
"host_link_agent_endpoint": {
Description: "The satellite link agent endpoint, required for reduced firewall attach script",
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -155,6 +160,12 @@ func dataSourceIBMSatelliteAttachHostScriptRead(d *schema.ResourceData, meta int
scriptPath = filepath.Join(scriptDir, "addHost.sh")
}

// If the user supplied link agent endpoint, use reduced firewall attach script
if hlae, ok := d.GetOk("host_link_agent_endpoint"); ok {
host_link_agent_endpoint := hlae.(string)
createRegOptions.HostLinkAgentEndpoint = &host_link_agent_endpoint
}

resp, err := satClient.AttachSatelliteHost(createRegOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error Generating Satellite Registration Script: %s\n%s", err, resp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestAccIBMSatelliteAttachHostScriptDataSourceBasicCoreos(t *testing.T) {
Config: testAccCheckIBMSatelliteAttachHostScriptDataSourceConfigCoreos(locationName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.ibm_satellite_attach_host_script.script", "host_provider", "ibm"),
resource.TestCheckResourceAttr("data.ibm_satellite_attach_host_script.script", "host_link_agent_endpoint", "testendpoint"),
),
},
},
Expand All @@ -75,5 +76,6 @@ data "ibm_satellite_attach_host_script" "script" {
labels = ["env:prod"]
coreos_host = true
host_provider = "ibm"
host_link_agent_endpoint = "testendpoint"
}`, locationName)
}
22 changes: 12 additions & 10 deletions website/docs/d/satellite_attach_host_script.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ data "ibm_satellite_attach_host_script" "script" {
}
```

### Sample to read satellite host script to attach AWS EC2 host to Satellite control plane
### Sample to read satellite host script to attach AWS EC2 host to Satellite control plane and uses reduced firewall requirements.

```terraform
data "ibm_satellite_attach_host_script" "script" {
location = var.location
labels = var.labels
script_dir = "/tmp"
host_provider = "aws"
location = var.location
labels = var.labels
script_dir = "/tmp"
host_provider = "aws"
host_link_agent_endpoint = "c-01-ws.us-south.link.satellite.cloud.ibm.com"
}
```
### Sample to read satellite host script to attach IBM host to Satellite control plane
Expand All @@ -38,11 +39,11 @@ data "ibm_satellite_attach_host_script" "script" {
location = var.location
custom_script = <<EOF
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
subscription-manager release --set=8
subscription-manager repos --enable rhel-8-for-x86_64-baseos-rpms
subscription-manager repos --enable rhel-8-for-x86_64-appstream-rpms
subscription-manager repos --disable='*eus*'
yum install container-selinux -y
EOF
}
Expand All @@ -57,6 +58,7 @@ Review the argument references that you can specify for your data source.
- `host_provider` - (Optional, String) The name of host provider, such as `ibm`, `aws` or `azure`.
- `labels` - (Optional, Set(Strings)) The set of key-value pairs to label the host, such as `["cpu:4"]` to describe the host capabilities.
- `script_dir` - (Optional, String) The directory path to store the generated script.
- `host_link_agent_endpoint` - (Optional, String) The endpoint that the link agent uses to connect to the link tunnel server. Required for reduced firewall support.

## Attributes reference
In addition to the argument reference list, you can access the following attribute reference after your resource is created.
Expand Down

0 comments on commit d7a0611

Please sign in to comment.