Joining to the Domain using Ansible

Posted: November 20, 2018 in ansible, Windows Server

File structure is same as in this post.

Playbook for Joining Machine to AD Domain:

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: Join to the domain
   win_domain_membership:
     dns_domain_name: '{{ dns_name }}'
     domain_admin_user: '{{ domain_admin_user }}'
     domain_admin_password: '{{ vault_ad_admin_pass }}'
     state: domain
 register: domain_state
 - name: Reboot after joining
   win_reboot:
     msg: "Joining Domain.Rebooting..."
     pre_reboot_delay: 15
   when: domain_state.reboot_required</pre> 
Comments
  1. Justin Smith says:

    Im running ansible natively on my mac… does the win_domain_membership require a “windows bridge computer” to run these specific commands? Wen i run these with my local host it says powershell isnt installed, because it isnt.

    Like

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