124 lines
3.3 KiB
YAML
124 lines
3.3 KiB
YAML
---
|
|
- name: Wait for system to be fully booted
|
|
ansible.builtin.wait_for_connection:
|
|
timeout: 300
|
|
sleep: 10
|
|
|
|
- name: Ensure Windows Update service is running
|
|
ansible.windows.win_service:
|
|
name: wuauserv
|
|
state: started
|
|
start_mode: auto
|
|
|
|
- name: Ensure BITS service is running
|
|
ansible.windows.win_service:
|
|
name: BITS
|
|
state: started
|
|
start_mode: auto
|
|
|
|
- name: Install Windows updates (loop until no more pending)
|
|
ansible.windows.win_updates:
|
|
category_names:
|
|
- SecurityUpdates
|
|
- CriticalUpdates
|
|
- UpdateRollups
|
|
- Updates
|
|
state: installed
|
|
reboot: true
|
|
reboot_timeout: 3600
|
|
server_selection: windows_update
|
|
register: win_updates_result
|
|
until: win_updates_result.installed_update_count == 0
|
|
retries: 5
|
|
delay: 30
|
|
|
|
- name: Report Windows Update result
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
Windows Update complete.
|
|
Last pass installed {{ win_updates_result.installed_update_count }} update(s).
|
|
Reboot required: {{ win_updates_result.reboot_required }}.
|
|
|
|
- name: Join Active Directory domain
|
|
microsoft.ad.membership:
|
|
dns_domain_name: "{{ domain_name }}"
|
|
hostname: "{{ inventory_hostname_short }}"
|
|
domain_admin_user: "{{ domain_join_user }}"
|
|
domain_admin_password: "{{ domain_join_password }}"
|
|
domain_ou_path: "{{ domain_ou_path | default(omit) }}"
|
|
state: domain
|
|
reboot: true
|
|
|
|
- name: Initialize data disk as GPT
|
|
community.windows.win_initialize_disk:
|
|
disk_number: "{{ data_disk_number }}"
|
|
style: gpt
|
|
online: true
|
|
|
|
- name: Create SQL Data partition (F:)
|
|
community.windows.win_partition:
|
|
disk_number: "{{ data_disk_number }}"
|
|
partition_size: "{{ sql_data_part_gb }} GiB"
|
|
drive_letter: F
|
|
state: present
|
|
|
|
- name: Format SQL Data partition (F:)
|
|
community.windows.win_format:
|
|
drive_letter: F
|
|
file_system: NTFS
|
|
new_label: SQLData
|
|
allocation_unit_size: 65536
|
|
|
|
- name: Create SQL Log partition (G:)
|
|
community.windows.win_partition:
|
|
disk_number: "{{ data_disk_number }}"
|
|
partition_size: "{{ sql_log_part_gb }} GiB"
|
|
drive_letter: G
|
|
state: present
|
|
|
|
- name: Format SQL Log partition (G:)
|
|
community.windows.win_format:
|
|
drive_letter: G
|
|
file_system: NTFS
|
|
new_label: SQLLog
|
|
allocation_unit_size: 65536
|
|
|
|
- name: Create SQL TempDB partition (H:)
|
|
community.windows.win_partition:
|
|
disk_number: "{{ data_disk_number }}"
|
|
partition_size: "{{ sql_tempdb_part_gb }} GiB"
|
|
drive_letter: H
|
|
state: present
|
|
|
|
- name: Format SQL TempDB partition (H:)
|
|
community.windows.win_format:
|
|
drive_letter: H
|
|
file_system: NTFS
|
|
new_label: SQLTempDB
|
|
allocation_unit_size: 65536
|
|
|
|
- name: Create SQL Backup partition (I:)
|
|
community.windows.win_partition:
|
|
disk_number: "{{ data_disk_number }}"
|
|
partition_size: "{{ (data_disk_size_gb | int) - (sql_data_part_gb | int) - (sql_log_part_gb | int) - (sql_tempdb_part_gb | int) - 1 }} GiB"
|
|
drive_letter: I
|
|
state: present
|
|
|
|
- name: Format SQL Backup partition (I:)
|
|
community.windows.win_format:
|
|
drive_letter: I
|
|
file_system: NTFS
|
|
new_label: SQLBackup
|
|
allocation_unit_size: 65536
|
|
|
|
- name: Create SQL Server directories
|
|
ansible.windows.win_file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
loop:
|
|
- 'F:\Data'
|
|
- 'G:\Log'
|
|
- 'H:\TempDB\Data'
|
|
- 'H:\TempDB\Log'
|
|
- 'I:\Backup'
|