diff --git a/ansible/promote_dc.yml b/ansible/promote_dc.yml index 50b0173..bb10edd 100644 --- a/ansible/promote_dc.yml +++ b/ansible/promote_dc.yml @@ -8,7 +8,11 @@ ansible.windows.win_shell: | $size = Get-PartitionSupportedSize -DriveLetter C Resize-Partition -DriveLetter C -Size $size.SizeMax - ignore_errors: yes + register: resize_partition_result + failed_when: > + resize_partition_result.rc != 0 and + 'already the requested size' not in (resize_partition_result.stderr | default('')) + changed_when: resize_partition_result.rc == 0 - name: Set primary DC as DNS server ansible.windows.win_dns_client: @@ -35,15 +39,26 @@ - name: Reboot after promotion ansible.windows.win_reboot: msg: "Rebooting to apply Domain Controller promotion" - reboot_timeout: 1800 - post_reboot_delay: 60 + reboot_timeout: 3600 + connect_timeout: 30 + post_reboot_delay: 180 when: dc_promotion.reboot_required + - name: Wait for Active Directory Domain Services to be running + ansible.windows.win_service_info: + name: NTDS + register: ntds_service + retries: 20 + delay: 30 + until: + - ntds_service.exists + - ntds_service.services[0].state == "running" + - name: Force Active Directory replication ansible.windows.win_command: repadmin /syncall /A /e /d register: repadmin_result changed_when: false - ignore_errors: yes + failed_when: false - name: Show replication status ansible.builtin.debug: