Installing Second Domain Controller using Ansible

Posted: November 20, 2018 in ansible, Windows Server

DNS name,domain admin,safe mode password and admin passwords and will be stored in 2 separate files:

|——-win_playbooks/

|           |–group_vars/

|              | –windows/

|                  | —-vars_win.yml (unencrypted) – dns_name,safe_mode_password (points to vault_win.yml-vault_password),domain_admin_user,domain_admin_password (points to vault_win.yml-vault_admin_pass)

|                 |—-vault_win.yml (encrypted) – vault_password and vault_admin_pass

vars_win.yml:

dns_name: ad.contoso.com
safe_mode_password: '{{ vault_password }}'
domain_admin_user: 'administrator@ad.contoso.com'
domain_admin_password: '{{ vault_ad_admin_pass }}'

vault_win.yml:

vault_password: SomePass
vault_ad_admin_pass: SomePass

Playbook for adding additional Domain Controller:

- name: install second domain controller
  hosts: dc2
  vars_files:
   - group_vars/windows/vault_win.yml
  gather_facts: yes
  tasks:
   - name: Configure Primary DNS Server
     win_dns_client:
       adapter_names: 'Ethernet 2'
       ipv4_addresses:
         - 192.168.1.182
- name: Promote this server to Additional DC
  win_domain_controller:
       dns_domain_name: '{{ dns_name }}'
       domain_admin_user: '{{ domain_admin_user }}'
       domain_admin_password: '{{ vault_ad_admin_pass }}'
       safe_mode_password: '{{ safe_mode_password }}'
       state: domain_controller
       log_path: c:\ansible_win_domain_controller.txt

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s