创建 AD域(新林)
使用 win_domain 模块# debian 13已经移除这个模块,使用的是 microsoft.ad.domain
新模块:
如果没有安装 ad-domain-services ,新模块会自动安装,但是很费时(大概5分钟)
---- name: Domain hosts: Server2 gather_facts: false tasks: - name: Change Hostname win_hostname: name: "{{ inventory_hostname }}" register: restart - name: restart device win_reboot: reboot_timeout: 3600 when: restart.changed - name: Install ad-domain-service software win_feature: name: ad-domain-services - name: Install Domain microsoft.ad.domain: dns_domain_name: wsc2026.org safe_mode_password: "Skills39" reboot: true
旧模块:
---- name: hostname hosts: all gather_facts: false tasks: - name: changed hostname win_hostname: name: "{{ inventory_hostname }}" notify: restart - name: Install Windows Feature win_feature: name: AD-Domain-Services handlers: - name: restart win_reboot: reboot_timeout: 3600- name: Install AD-Domain-Server hosts: Server1 gather_facts: false tasks: - name: Configure DC win_domain: dns_domain_name: shanghai.org safe_mode_password: Skills39 notify: restart handlers: - name: restart win_reboot: reboot_timeout: 3600