diff --git a/ansible/roles/win_domain_controller/tasks/setup.yml b/ansible/roles/win_domain_controller/tasks/setup.yml new file mode 100644 index 0000000..c3797a6 --- /dev/null +++ b/ansible/roles/win_domain_controller/tasks/setup.yml @@ -0,0 +1,70 @@ +--- +- name: Copy Templates + tags: copy_templates + block: + - name: Remove existing Group Policy Templates + win_file: + path: "C:\\Windows\\PolicyDefinitions\\" + state: absent + + - name: Copy 'admx' group policy template files to DCs + win_copy: + src: /deployments/{{ os_project }}-{{ win_project }}/policy_templates/PolicyDefinitions/ + dest: "C:\\Windows\\PolicyDefinitions\\" + force: true + + - name: Copy 'adml' group policy template files to DCs + win_copy: + src: /deployments/{{ os_project }}-{{ win_project }}/policy_templates/en-US/ + dest: "C:\\Windows\\PolicyDefinitions\\en-US\\" + force: true + +- name: Promote DC01 + tags: promote_dc01 + block: + - name: Promote DC01 to domain controller + win_domain: + dns_domain_name: "{{ win_project }}.loc" + safe_mode_password: "{{ safemode_password }}" + domain_netbios_name: "{{ win_project|upper }}" + register: dc01_promotion + + - name: Setting DNS Servers (Primary DC) + win_dns_client: + adapter_names: "*" + ipv4_addresses: + - "127.0.0.1" + - "{{ hostvars['eidf075-dev-dc02'].ansible_host }}" + + - name: Rebooting DC01 post promotion to domain controller + win_reboot: + reboot_timeout_sec: 1200 + when: dc01_promotion.reboot_required | default(false) == true + when: inventory_hostname in groups['meta-name_dc01'] + +- name: Promote DC02 + tags: promote_dc02 + block: + - name: Setting DNS Servers (Secondary DC) + tags: promote_dc01 + win_dns_client: + adapter_names: "*" + ipv4_addresses: + - "{{ hostvars['eidf075-dev-dc01'].ansible_host }}" + - "127.0.0.1" + + - name: Promote DC02 to domain controller + win_domain_controller: + dns_domain_name: "{{ win_project }}.loc" + domain_admin_user: "Administrator@{{ win_project }}.loc" + domain_admin_password: "{{ ansible_password }}" + safe_mode_password: "{{ safemode_password }}" + state: domain_controller + register: dc02_promotion + + - name: Rebooting DC02 post promotion to domain controller + win_reboot: + reboot_timeout_sec: 1200 + when: dc02_promotion.reboot_required | default(false) == true + when: inventory_hostname in groups['meta-name_dc02'] + \ No newline at end of file