You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/highly-available-nfs-workload-on-hpe-greenlake-for-private-cloud-enterprise-using-serviceguard-for-linux.md
@@ -17,15 +17,13 @@ One of the options provided through HPE GreenLake is to make it easy for custome
17
17
18
18
## Terraform
19
19
20
-
21
20
Terraform is an open-source Infrastructure-as-Code framework originally created by HashiCorp that is written in Go. It uses a declarative language (HashiCorp Configuration Language HCL or JSON more recently) to describe the desired state of the infrastructure in terms of cloud, virtual machines, networks, storage, and many other components. Terraform uses the concept of “providers” to integrate with all major public clouds. Terraform is a so-called idempotent system in the sense that it does not generate any side effects if applied multiple times on infrastructure already in the desired state. Terraform has gained quite the momentum in the last few years.
22
21
23
22
## HPE Serviceguard for Linux
24
23
25
24
HPE Serviceguard for Linux (SGLX) is a high availability (HA) and disaster recovery (DR) clustering solution that increases uptime for your critical applications by protecting them from a multitude of infrastructure and application faults across physical or virtual environments over any distance. The solution also reduces the impact of unplanned downtime with no compromise on data integrity or performance, and it helps achieve near zero planned downtime for maintenance.
26
25
27
-
## Ansible
28
-
26
+
## Ansible
29
27
30
28
Ansible Automation Platform is an end-to-end automation platform to configure systems, deploy software, and orchestrate advanced workflows. It includes resources to create, manage, and scale across the entire enterprise.
31
29
@@ -47,7 +45,6 @@ You can create a virtual machine in the Virtual Machines service of HPE GreenLak
47
45
48
46
## Building a Terraform configuration file from scratch
49
47
50
-
51
48
Let’s start building this Terraform (TF) file using your favourite editor.
52
49
Selecting a Terraform provider
53
50
The first section of the file will enumerate the “providers” you rely upon for building your infrastructure, and they could be multiple providers in a single TF file. In the case here, you only have the HPE GreenLake provider referenced as hpe/hpegl in the official Terraform registry.
@@ -74,9 +71,7 @@ https://registry.terraform.io/providers/HPE/hpegl/latest This page also provides
74
71
The docs folder is your best source of information for using the different data sources and resources provided by the provider. If you navigate to the resources section, you will see that one resource you can configure with this provider is a VM instance. This article will focus on this resource.
75
72
Note: Because this is open source, do not hesitate to open issues, or even a pull request, if you identify an issue.
76
73
77
-
##
78
-
Setting up the Terraform provider
79
-
74
+
## Setting up the Terraform provider
80
75
81
76
Set up the required parameters for hpegl provider that was specified earlier. As previously explained, you can either explicitly set those parameters in your TF file or have them set in a series of environment variables or have a mix of both. It is recommended to add the following two parameters in your TF file:
82
77
@@ -93,31 +88,55 @@ provider "hpegl" {
93
88
The rest (such as tenant id, user id and user secret key) can be placed in a RC file, which you can source before running your Terraform command.
94
89
You can find your location and your space name from the HPE GreenLake for Private Cloud Enterprise Overview. In the example shown below, FTC06 is our location:
95
90
91
+

92
+
96
93
In the capture below, Default is the space you will use for your work with Terraform. You can check your available Spaces from the HPE GreenLake console under your profile icon, Change Space.
97
94
98
-
Setting up API Client access
95
+

96
+
97
+
## Setting up API Client access
98
+
99
+
99
100
Next, you need to create a new API Client access dedicated to Terraform. You can do this from the HPE GreenLake console under your settings icon, select User Management and then the API Clients tab.
100
101
102
+

103
+
101
104
Create a new API Client and be sure to note down the Issuer, Client ID and Client Secret values which are shown.
102
105
The value for the tenant ID may be seen in the Tenant ID field under the API Access menu and in the URL of your browser.
103
106
107
+

108
+
104
109
With this you can now build a resource file that defines the following environment variables:
110
+
111
+
```
105
112
export HPEGL_TENANT_ID=<Your Tenant ID>
106
113
export HPEGL_USER_ID=<Client ID of the API Client>
107
114
export HPEGL_USER_SECRET=<Secret Key displayed when you created the API Client>
108
115
export HPEGL_IAM_SERVICE_URL=<Issuer URL>
116
+
```
117
+
118
+
119
+
109
120
And execute it on your machine to set these environment variables.
110
121
111
-
Assign Roles to API Client
122
+
## Assign Roles to API Client
123
+
124
+
112
125
Once your API Client has been created, you need to assign a Role and a Space. You can assign a Role and a Space by clicking on your new API Client and then clicking the Create Assignment button.
113
126
Since intent is to use this API Client to create resources in the Virtual Machines Service, we need to assign an appropriate Virtual Machines Role. Choose a Role like ‘Private Cloud Tenant Contributor’ and choose the same Space as used earlier, I.e., ‘Default.’
114
127
115
128
Note: More details on HPE GreenLake user roles can be found in the HPE GreenLake documentation.
129
+
130
+
##
116
131
Set API Client Usernames and Passwords
132
+
133
+
117
134
When a user creates virtual machines using the HPE GreenLake for Private Cloud Enterprise: Virtual Machines user interface, they first set the Linux and Windows username and password. Once this is done, any virtual machines subsequently created by that user will inherit these credentials. The user can later use these credentials to log into these virtual machines.
118
135
API Clients which are used to create virtual machines can also set Linux and Windows username and password values. Since the API Client does not use the HPE GreenLake for Private Cloud Enterprise: Virtual Machines user interface, this must be done via an API call.
119
-
Here is a sample script which reads the VM*USERNAME and VM_PASSWORD environment variables and uses the values for Linux and Windows username and password for the API Client. The script assumes a Location value of ‘FTC06’ and Space value of ‘Default’.
120
-
To execute this script, first set appropriate values for the VM_USERNAME and VM_PASSWORD environment variables. Next, execute the resource file, which was created earlier, which sets the HPEGL** environment variables for your API Client. Finally, execute the script below.
136
+
Here is a sample script which reads the VM\*USERNAME and VM_PASSWORD environment variables and uses the values for Linux and Windows username and password for the API Client. The script assumes a Location value of ‘FTC06’ and Space value of ‘Default’.
137
+
To execute this script, first set appropriate values for the VM_USERNAME and VM_PASSWORD environment variables. Next, execute the resource file, which was created earlier, which sets the HPEGL\** environment variables for your API Client. Finally, execute the script below.
Your next step with the TF file is to query the HPE GreenLake provider to collect information needed to create your first VM instance. From the documentation, you can see that you need to gather the following information:
156
179
• Cloud ID
157
180
• Group ID
@@ -164,58 +187,69 @@ Your next step with the TF file is to query the HPE GreenLake provider to collec
164
187
• Folder Code
165
188
For this, you will use the Terraform data statements. For example, the following statement retrieves the Cloud ID and stores it (in variable called cloud), which we can later retrieve using: data.hpegl_vmaas_cloud.cloud.id
166
189
190
+
```
167
191
# Retrieve cloud id
168
-
169
192
data "hpegl_vmaas_cloud" "cloud" {
170
193
name = "HPE GreenLake VMaaS Cloud"
171
194
}
195
+
196
+
```
197
+
172
198
Using a similar technique, you can retrieve the rest of the data you need:
173
199
200
+
```
174
201
# And a network
175
-
176
202
data "hpegl_vmaas_network" "blue_segment" {
177
203
name = "Blue-Segment"
178
204
}
179
-
205
+
180
206
data "hpegl_vmaas_cloud_folder" "compute_folder" {
181
207
cloud_id = data.hpegl_vmaas_cloud.cloud.id
182
208
name = "ComputeFolder"
183
209
}
184
-
210
+
185
211
# Locate a resource pool
186
-
187
212
data "hpegl_vmaas_resource_pool" "cl_resource_pool" {
188
213
cloud_id = data.hpegl_vmaas_cloud.cloud.id
189
214
name = "gl-ftc06-G2i-vm-02"
190
215
}
191
-
216
+
192
217
# And a group
193
-
194
218
data "hpegl_vmaas_group" "default_group" {
195
219
name = "Default"
196
220
}
197
-
221
+
198
222
# Locate a plan
199
-
200
223
data "hpegl_vmaas_plan" "g2i_medium" {
201
224
name = "G2i-medium"
202
225
}
203
-
226
+
204
227
# A layout
205
-
206
228
data "hpegl_vmaas_layout" "vmware" {
207
229
name = "Vmware VM"
208
230
instance_type_code = "vmware"
209
231
}
210
-
232
+
211
233
# And a template
212
-
213
234
data "hpegl_vmaas_template" "vanilla" {
214
235
name = "redhat8-20220331T1850"
215
236
}
216
-
You can get information about each of the data statements supported by the hpegl provider from GitHub.
217
-
Creating VM resources
237
+
238
+
```
239
+
240
+
######
241
+
242
+
243
+
You can get information about each of the data statements supported by the hpegl provider from [GitHub.](https://github.com/hpe/terraform-provider-hpegl/tree/main/docs/data-sources)
244
+
245
+
## Creating VM resources
246
+
247
+
218
248
The next step is to use a Terraform resource statement to create a random integer (used in VM names) and a second resource to request the creation of several VM instances:
3 VMs need to be created to setup SGLX. 2 VMs will be used to create Serviceguard for Linux nodes where the NFS service will be up and running. The third VM will act as a quorum server for the Serviceguard cluster to ensure that split brain of the cluster does not impact the availability of the monitored workload.
257
334
Note: You can get information about each of the resource statements supported by the hpegl provider from GitHub.
258
335
Note: An existing Serviceguard Quorum Server in your environment can be used instead of provisioning a third VM, provided the Quorum Server is reachable to the 2 VM’s that were created.
336
+
337
+
##
259
338
Terraform init
339
+
340
+
260
341
Before you can use Terraform, you need to initialize it from the configuration file we have created. This is done with the following step:
0 commit comments