Automate Linux Machine join AD using Ansible. This module is inspired from the work of
- https://github.com/rahulinux/ansible-domain-join Domain Administrators default group is configured to enable sudo
It was tested on the following versions:
- 2.4
Tested with RHEL 7 Targeted for EL
Clone the repository in the roles directory in ansible as install_snmpd and include this role in your list. For example
- host: all
vars_files:
- vars/ad.yaml
roles:
- domain_join
You need to privode the details to join linux into domain, like domain user who has right to add client into domain and DNS server and FQDNS.
Create ad.yaml file with the content below and include it into the plyabook. Make sure /etc/resolv.conf contains the dns server address
---
- ad_server:
ip: xxxx
fqdn: ad1.example.com
user: svc_ad
pass: 'xxxx'
domain: example.com
Modify ou_membership to add the machine to custom OU
sudo realm list
id __user_name__
ssh __user_name__@localhost
If you want to reverse the process and remove yourself from the domain, simply run the ‘realm leave’ command followed by the domain name, as shown below.
realm leave example.com