Add working provisioning and configuration for MS SQL data warehouse
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
mssql_staging_dir: 'C:\SQLInstall'
|
||||
|
||||
mssql_bootstrapper_url: "https://go.microsoft.com/fwlink/p/?linkid=2215158&clcid=0x409&culture=en-us&country=US"
|
||||
mssql_bootstrapper_path: 'C:\SQLInstall\SQLServer2022-setup.exe'
|
||||
|
||||
mssql_iso_path: 'C:\SQLInstall\SQLServer2022-x64-ENU.iso'
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Create SQL Server staging directory
|
||||
ansible.windows.win_file:
|
||||
path: "{{ mssql_staging_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Download SQL Server 2022 setup bootstrapper
|
||||
ansible.windows.win_get_url:
|
||||
url: "{{ mssql_bootstrapper_url }}"
|
||||
dest: "{{ mssql_bootstrapper_path }}"
|
||||
timeout: 120
|
||||
|
||||
- name: Download SQL Server 2022 ISO via bootstrapper
|
||||
ansible.windows.win_command: >-
|
||||
"{{ mssql_bootstrapper_path }}"
|
||||
/Action=Download
|
||||
/MEDIATYPE=ISO
|
||||
/MEDIAPATH="{{ mssql_staging_dir }}"
|
||||
/QUIET
|
||||
args:
|
||||
creates: "{{ mssql_iso_path }}"
|
||||
timeout: 3600
|
||||
|
||||
- name: Find downloaded SQL Server ISO
|
||||
ansible.windows.win_find:
|
||||
paths: "{{ mssql_staging_dir }}"
|
||||
patterns: "*.iso"
|
||||
register: iso_files
|
||||
|
||||
- name: Fail if no ISO found in staging directory
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
No ISO file found in {{ mssql_staging_dir }}.
|
||||
The bootstrapper download may have failed.
|
||||
Check {{ mssql_staging_dir }} on the target host.
|
||||
when: iso_files.files | length == 0
|
||||
|
||||
- name: Mount SQL Server 2022 ISO
|
||||
ansible.windows.win_powershell:
|
||||
script: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$imagePath = '{{ iso_files.files[0].path }}'
|
||||
|
||||
$diskImage = Get-DiskImage -ImagePath $imagePath
|
||||
if (-not $diskImage.Attached) {
|
||||
Mount-DiskImage -ImagePath $imagePath | Out-Null
|
||||
}
|
||||
|
||||
$driveLetter = (Get-DiskImage -ImagePath $imagePath | Get-Volume).DriveLetter
|
||||
if (-not $driveLetter) {
|
||||
throw "ISO mounted but no drive letter was assigned"
|
||||
}
|
||||
|
||||
$Ansible.Result = "${driveLetter}:"
|
||||
register: mount_result
|
||||
|
||||
- name: Set SQL Server ISO drive letter fact
|
||||
ansible.builtin.set_fact:
|
||||
mssql_iso_drive: "{{ mount_result.result }}"
|
||||
|
||||
- name: Show mounted drive letter
|
||||
ansible.builtin.debug:
|
||||
msg: "SQL Server 2022 ISO mounted at {{ mssql_iso_drive }} ({{ iso_files.files[0].path }})"
|
||||
Reference in New Issue
Block a user