Windows Active Directory en DNS setup

---

# Change Hostname
- name: wijzig-computernaam
  hosts: "{{ host }}"
  remote_user: "{{ user }}"
  become: yes
  become_user: "{{ user }}"
  become_method: runas
  gather_facts: yes
  vars_files:
    - vars-windows.yml
  tasks:
    - name: Wijzig computernaam
      win_hostname:
        name: "{{ hostname }}"
    - name: Herstart server
      win_reboot:

# Install ADDS
- name: installeer-adds
  hosts: windows
  remote_user: "{{ user }}"
  become: yes
  become_user: "{{ user }}"
  become_method: runas
  gather_facts: no
  vars_files:
    - vars-windows.yml
  tasks:
    - name: Installeer ADDS
      win_feature:
        name: AD-Domain-Services
        state: present
        include_sub_features: yes
        include_management_tools: yes
      register: win_feature

    - name: Installeer DNS
      win_feature:
        name: DNS
        state: present
        include_sub_features: yes
        include_management_tools: yes
      register: win_feature

    #- name: Herstart server wanneer dit nodig is voor het installeren van de rol/feature
    #  win_reboot:
    #  when: win_feature.reboot_required

    - name: Herstart server
      win_reboot:

# Set DNS Localhost
- name: setup-dns-adres
  hosts: windows
  remote_user: "{{ user }}"
  become: yes
  become_user: "{{ user }}"
  become_method: runas
  gather_facts: no
  vars_files:
    - vars-windows.yml
  tasks:
    - name: Stel DNS IPv4 adressen in
      win_dns_client:
        adapter_names: "{{ network_adapter }}"
        ipv4_addresses: "{{ dns_addresses }}"
        log_path: "{{ log_dns_setup }}"

# Setup ADDS
- name: setup-adds
  hosts: windows
  remote_user: "{{ user }}"
  become: yes
  become_user: "{{ user }}"
  become_method: runas
  gather_facts: no
  vars_files:
    - vars-windows.yml
  tasks:
    - name: Maak een nieuw domein met een nieuw forest
      win_domain:
        dns_domain_name: "{{ domain_name }}"
        domain_netbios_name: "{{ domain_netbios }}"
        safe_mode_password: "{{ domain_safemode_password }}"
      register: domain_result

    - name: Start netlogon service
      win_service:
        name: netlogon
        state: started

    #- name: Herstart server wanneer dit nodig is voor het installeren van de rol/feature
    #  win_reboot:
    #  when: domain_result.reboot_required

    - name: Herstart server
      win_reboot:

Windows Active Directory en DNS Variablen

---

host: windows
user: <username>
hostname: wsrvadds
network_adapter: "*"
dns_addresses:
  - 127.0.0.1
  - 1.1.1.1
log_dns_setup: c:\dns_log.txt
domain_name: ansible.local
domain_netbios: WSRV-ADDS
domain_safemode_password: <password>