Skip to content

Commit

Permalink
Hotfixes before release (#626)
Browse files Browse the repository at this point in the history
* Validate that the desired volume group exists before trying
to expand it

* Add Windows support for MSI Role assignment

* align the MSI assignment

* Tweak the package install order

* Subscription ID handling

* Skip Windows Hosts

* Change Play and remove become

* Change the order of the variables

* Validate that the desired volume group exists before expanding it for SAP CAL

* Check both scs and ers

* Skip the location check

* Web App Updates

* chore: Update last modified date format in LandscapeController and SystemController

* Add support for MSI

* Don't install extension

* chore: Set ACSS registration information in main.yaml

* Save the modification date

* Set missing parameters

* add always tag

* Use the correct object

* Use hostname to seed the UUID

* Linting fixes

* Remove the incorrect variable

* Add the -p parameter for creating the terraform cache folder

* chore: Update AMS resource identifier handling in outputs.tf

* Fix the coalesce when not using SPN

* Change the logic

* Update variables that are superseded

* chore: Update script_helpers.sh to handle missing webapp client secret

* Precreate the cache folder

* Secret is not mandatory when using MSI

* chore: Update NFS configuration for Red Hat 8 and 9

---------

Co-authored-by: Kimmo Forss <[email protected]>
Co-authored-by: Nadeen Noaman <[email protected]>
Co-authored-by: hdamecharla <[email protected]>
  • Loading branch information
4 people authored Sep 5, 2024
1 parent a0dd249 commit 292c608
Show file tree
Hide file tree
Showing 31 changed files with 396 additions and 262 deletions.
15 changes: 12 additions & 3 deletions Webapp/SDAF/Controllers/LandscapeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public async Task<IActionResult> CreateAsync(LandscapeModel landscape)
await UnsetDefault(landscape.Id);
}
landscape.Id = Helper.GenerateId(landscape);
DateTime currentDateAndTime = DateTime.Now;
landscape.LastModified = currentDateAndTime.ToShortDateString();

await _landscapeService.CreateAsync(new LandscapeEntity(landscape));
TempData["success"] = "Successfully created workload zone " + landscape.Id;
string id = landscape.Id;
Expand Down Expand Up @@ -220,7 +223,7 @@ public async Task<IActionResult> DeployAsync(string id, string partitionKey)

List<SelectListItem> environments = restHelper.GetEnvironmentsList().Result;
ViewBag.Environments = environments;


return View(landscapeView);
}
Expand Down Expand Up @@ -351,14 +354,17 @@ public async Task<IActionResult> EditAsync(LandscapeModel landscape)

await _landscapeService.CreateTFVarsAsync(file);

return RedirectToAction("Edit", "Landscape", new { @id = landscape.Id, @partitionKey = landscape.environment }); //RedirectToAction("Index");
return RedirectToAction("Edit", "Landscape", new { @id = landscape.Id, @partitionKey = landscape.environment }); //RedirectToAction("Index");
}
else
{
if (landscape.IsDefault)
{
await UnsetDefault(landscape.Id);
}
DateTime currentDateAndTime = DateTime.Now;
landscape.LastModified = currentDateAndTime.ToShortDateString();

await _landscapeService.UpdateAsync(new LandscapeEntity(landscape));
TempData["success"] = "Successfully updated workload zone " + landscape.Id;

Expand All @@ -378,7 +384,7 @@ public async Task<IActionResult> EditAsync(LandscapeModel landscape)

await _landscapeService.CreateTFVarsAsync(file);

return RedirectToAction("Edit", "Landscape", new { @id = landscape.Id, @partitionKey = landscape.environment }); //RedirectToAction("Index");
return RedirectToAction("Edit", "Landscape", new { @id = landscape.Id, @partitionKey = landscape.environment }); //RedirectToAction("Index");
}
}
catch (Exception e)
Expand Down Expand Up @@ -408,6 +414,9 @@ public async Task<IActionResult> SubmitNewAsync(LandscapeModel landscape)
await UnsetDefault(landscape.Id);
}
landscape.Id = Helper.GenerateId(landscape);
DateTime currentDateAndTime = DateTime.Now;
landscape.LastModified = currentDateAndTime.ToShortDateString();

await _landscapeService.CreateAsync(new LandscapeEntity(landscape));
TempData["success"] = "Successfully created workload zone " + landscape.Id;
string id = landscape.Id;
Expand Down
8 changes: 8 additions & 0 deletions Webapp/SDAF/Controllers/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ public async Task<IActionResult> CreateAsync(SystemModel system)
await UnsetDefault(system.Id);
}
system.Id = Helper.GenerateId(system);
DateTime currentDateAndTime = DateTime.Now;
system.LastModified = currentDateAndTime.ToShortDateString();
SystemEntity systemEntity = new(system);
await _systemService.CreateAsync(systemEntity);
TempData["success"] = "Successfully created system " + system.Id;
Expand Down Expand Up @@ -479,7 +481,10 @@ public async Task<IActionResult> EditAsync(SystemModel system)
system.Description = system.database_platform + " distributed system on " + system.scs_server_image.publisher + " " + system.scs_server_image.offer + " " + system.scs_server_image.sku;
}
}
DateTime currentDateAndTime = DateTime.Now;
system.LastModified = currentDateAndTime.ToShortDateString();
await _systemService.UpdateAsync(new SystemEntity(system));

TempData["success"] = "Successfully updated system " + system.Id;
string id = system.Id;
string path = $"/SYSTEM/{id}/{id}.tfvars";
Expand Down Expand Up @@ -527,6 +532,9 @@ public async Task<IActionResult> SubmitNewAsync(SystemModel system)
await UnsetDefault(system.Id);
}
system.Id = Helper.GenerateId(system);
DateTime currentDateAndTime = DateTime.Now;
system.LastModified = currentDateAndTime.ToShortDateString();

await _systemService.CreateAsync(new SystemEntity(system));
TempData["success"] = "Successfully created system " + system.Id;
return RedirectToAction("Index");
Expand Down
2 changes: 2 additions & 0 deletions Webapp/SDAF/Models/LandscapeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public bool IsValid()
[DisplayName("Workload zone ID")]
public string Id { get; set; }

public string LastModified { get; set; }

// BASIC

public bool IsDefault { get; set; } = false;
Expand Down
1 change: 1 addition & 0 deletions Webapp/SDAF/Models/SystemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public bool IsValid()

[DisplayName("System ID")]
public string Id { get; set; }
public string LastModified { get; set; }

// BASIC

Expand Down
9 changes: 9 additions & 0 deletions Webapp/SDAF/ParameterDetails/LandscapeDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
"Overrules": "",
"Display": 1
},
{
"Name": "LastModified",
"Required": false,
"Description": "System definition was modified on.",
"Type": "textbox",
"Options": [],
"Overrules": "",
"Display": 1
},
{
"Name": "save_naming_information",
"Required": false,
Expand Down
9 changes: 9 additions & 0 deletions Webapp/SDAF/ParameterDetails/SystemDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@
"Overrules": "",
"Display": 1
},
{
"Name": "LastModified",
"Required": false,
"Description": "System definition was modified on.",
"Type": "textbox",
"Options": [],
"Overrules": "",
"Display": 1
},
{
"Name": "network_logical_name",
"Required": true,
Expand Down
2 changes: 1 addition & 1 deletion Webapp/SDAF/SDAFWebApp.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<NameOfLastUsedPublishProfile>C:\Work\Repos\sap-automation\Webapp\SDAF\Properties\PublishProfiles\cpln-noeu-sapdeployment597 - Web Deploy1.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>cpln-noeu-sapdeployment597 - Web Deploy1</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions Webapp/SDAF/Views/System/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</div>
</div>
}

<div id="form-sticky-header">
<div class="filter-checkboxes">
<fluent-checkbox checked class="parameters-filter" onchange="toggleParams(this, 1)" id="basic-filter">Basic</fluent-checkbox>
Expand Down Expand Up @@ -145,7 +145,7 @@
</td>

</tr>


</form>
</div>
14 changes: 9 additions & 5 deletions Webapp/SDAF/Views/System/Install.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,21 @@

@Html.EditorForModel("Checkbox", new { ParameterName = "database_install", DisplayName = "Database Installation", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "scs_installation", DisplayName = "SCS Installation", IsChecked = true })
@Html.EditorForModel("Checkbox", new { ParameterName = "scs_installation", DisplayName = "SCS Installation & High Availability Configuration", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "db_load", DisplayName = "Database Load", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "high_availability_configuration", DisplayName = "SAP & DB High Availability Setup", IsChecked = true })
@Html.EditorForModel("Checkbox", new { ParameterName = "high_availability_configuration", DisplayName = "Database High Availability Configuration", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "pas_installation", DisplayName = "PAS Installation", IsChecked = true })
@Html.EditorForModel("Checkbox", new { ParameterName = "pas_installation", DisplayName = "Primary Application Server Installation", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "application_server_installation", DisplayName = "APP Installation", IsChecked = true })
@Html.EditorForModel("Checkbox", new { ParameterName = "application_server_installation", DisplayName = "Application Server Installation", IsChecked = true })

@Html.EditorForModel("Checkbox", new { ParameterName = "webdispatcher_installation", DisplayName = "WebDispatcher Installation", IsChecked = false })
@Html.EditorForModel("Checkbox", new { ParameterName = "webdispatcher_installation", DisplayName = "Web Dispatcher Installation", IsChecked = false })

@Html.EditorForModel("Checkbox", new { ParameterName = "post_configuration_actions", DisplayName = "Post Configuration Actions", IsChecked = false })

@Html.EditorForModel("Checkbox", new { ParameterName = "ams_provider", DisplayName = "Configure AMS Provider", IsChecked = false })

@Html.EditorForModel("Checkbox", new { ParameterName = "acss_registration", DisplayName = "Register System in ACSS", IsChecked = true })

Expand Down
23 changes: 21 additions & 2 deletions deploy/ansible/playbook_06_00_acss_registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,26 @@
tags:
- 0.1-passwords

- name: "0.0 Validations - Get Access Token"
ansible.builtin.command: >-
az account get-access-token --query accessToken -o tsv
changed_when: false
register: access_token_data
no_log: true
tags:
- always

- name: "0.0 Validations - Save the access token"
ansible.builtin.set_fact:
access_token: "{{ access_token_data.stdout }}"
no_log: true
tags:
- always


# /*---------------------------------------------------------------------------8
# | |
# | Playbook for SAP Web Dispatcher Install |
# | Playbook for ASCS Registration |
# | |
# +------------------------------------4--------------------------------------*/

Expand All @@ -54,7 +71,6 @@

name: ACSS Registration
remote_user: "{{ orchestration_ansible_user }}"
become: true
gather_facts: true # Important to collect hostvars information
vars_files:
- vars/ansible-input-api.yaml # API Input template with defaults
Expand Down Expand Up @@ -87,11 +103,14 @@
when:
- acssEnvironment is defined
- acssSapProduct is defined
- ansible_os_family != "Windows"
ansible.builtin.include_role:
name: "roles-misc/0.5-ACSS-registration"
vars:
acss_environment: "{{ acssEnvironment }}"
acss_sap_product: "{{ acssSapProduct }}"
acss_access_token: "{{ hostvars.localhost.access_token }}"
acss_guid: "{{ ansible_hostname | to_uuid }}"
loop: "{{ all_sids }}"
loop_control:
loop_var: sid_to_be_deployed
Expand Down
79 changes: 42 additions & 37 deletions deploy/ansible/roles-misc/0.5-ACSS-registration/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
become_user: "{{ sap_sid | lower }}adm"
become: true
when:
- "'scs' in supported_tiers"
- "'scs' in supported_tiers or 'ers' in supported_tiers"
block:
- name: "0.5.1 acss registration: - Get sapcontrol path"
ansible.builtin.find:
Expand Down Expand Up @@ -50,7 +50,7 @@

- name: "0.5.1 acss registration: - Show if SCS is running on {{ ansible_hostname }}"
ansible.builtin.debug:
var: is_running
var: is_running

- name: "0.5.1 acss registration: - Validate that SCS is running on {{ ansible_hostname }}"
ansible.builtin.set_fact:
Expand All @@ -64,30 +64,31 @@
become_user: root
when:
- hostvars[ansible_hostname]['scs_running_on'] is defined
- ansible_hostname == hostvars[ansible_hostname]['scs_running_on']
block:
- name: "0.5.1 acss registration: - Check where the cluster group g-{{ sap_sid | upper }}_{{ instance_type | upper }} is running"
ansible.builtin.shell: >-
set -o pipefail;
crm_resource --resource g-{{ sap_sid | upper }}_{{ instance_type | upper }} --locate | cut -d ':' -f 2| cut -d " " -f 2
when:
- scs_high_availability
- ansible_os_family | upper == 'SUSE'
register: cluster_group_location
failed_when: cluster_group_location.stdout != hostvars[ansible_hostname]['scs_running_on']
tags:
- skip_ansible_lint
# - name: "0.5.1 acss registration: - Check where the cluster group g-{{ sap_sid | upper }}_{{ instance_type | upper }} is running"
# ansible.builtin.shell: >-
# set -o pipefail;
# crm_resource --resource g-{{ sap_sid | upper }}_{{ instance_type | upper }} --locate | cut -d ':' -f 2| cut -d " " -f 2
# when:
# - scs_high_availability
# - ansible_os_family | upper == 'SUSE'
# register: cluster_group_location
# failed_when: cluster_group_location.stdout != hostvars[ansible_hostname]['scs_running_on']
# tags:
# - skip_ansible_lint

- name: "0.5.1 acss registration: - Check where the cluster group g-{{ sap_sid | upper }}_{{ instance_type | upper }} is running"
ansible.builtin.shell: >-
set -o pipefail;
pcs constraint location show resources g-{{ sap_sid | upper }}_{{ instance_type | upper }} | grep "Node" | awk '{print $2}'
when:
- scs_high_availability
- ansible_os_family | upper == 'REDHAT'
register: cluster_group_location
failed_when: cluster_group_location.stdout != hostvars[ansible_hostname]['scs_running_on']
tags:
- skip_ansible_lint
# - name: "0.5.1 acss registration: - Check where the cluster group g-{{ sap_sid | upper }}_{{ instance_type | upper }} is running"
# ansible.builtin.shell: >-
# set -o pipefail;
# pcs constraint location show resources g-{{ sap_sid | upper }}_{{ instance_type | upper }} | grep "Node" | awk '{print $2}'
# when:
# - scs_high_availability
# - ansible_os_family | upper == 'REDHAT'
# register: cluster_group_location
# failed_when: cluster_group_location.stdout != hostvars[ansible_hostname]['scs_running_on']
# tags:
# - skip_ansible_lint

- name: "0.5.1 acss registration: - Get Azure instance metadata"
ansible.builtin.uri:
Expand All @@ -96,21 +97,25 @@
headers:
Metadata: true
register: azure_metadata
when:
- hostvars[ansible_hostname]['scs_running_on'] is defined
- ansible_hostname == hostvars[ansible_hostname]['scs_running_on']

- name: "0.5.1 acss registration: - Set variables from Azure IMDS"
delegate_facts: true
delegate_to: localhost
ansible.builtin.command: >-
"az extension add --name workloads --yes || exit 1"
tags:
- skip_ansible_lint
- name: "Set information"
ansible.builtin.set_fact:
acss_resource_group: "{{ azure_metadata.json.compute.resourceGroupName }}"
acss_resource_id: "{{ azure_metadata.json.compute.resourceId }}"
acss_subscription_id: "{{ azure_metadata.json.compute.subscriptionId }}"
acss_location: "{{ azure_metadata.json.compute.location }}"

# - name: "0.5.1 acss registration: - Set variables from Azure IMDS"
# delegate_facts: true
# delegate_to: localhost
# ansible.builtin.command: >-
# "az extension add --name workloads --yes || exit 1"
# tags:
# - skip_ansible_lint

- name: "0.5.1 acss registration: - Create [ACSS] virtual instance"
ansible.builtin.uri:
url: "https://management.azure.com/subscriptions/{{ acss_subscription_id }}/resourceGroups/{{ acss_resource_group }}/providers/Microsoft.Workloads/sapVirtualInstances/{{ acss_sid }}?api-version=2023-04-01"
url: "https://management.azure.com/subscriptions/{{ acss_subscription_id }}/resourceGroups/{{ acss_resource_group }}/providers/Microsoft.Workloads/sapVirtualInstances/{{ sap_sid | upper }}?api-version=2023-04-01"
method: PUT
body_format: json
body: |
Expand All @@ -127,9 +132,9 @@
}
# status_code: [200, 201]
headers:
Authorization: "Bearer {{ acss_access_token.stdout }}"
Authorization: "Bearer {{ acss_access_token }}"
x-ms-rpaas-new-resource: "true"
x-ms-client-request-id: "SDAF-{{ acss_guid.stdout }}"
x-ms-client-request-id: "SDAF-{{ acss_guid }}"
register: create_vis_response
failed_when: create_vis_response.json.properties.provisioningState != 'Accepted' and create_vis_response.json.properties.provisioningState != 'Succeeded'
no_log: false
Expand Down
Loading

0 comments on commit 292c608

Please sign in to comment.