Ansible is a great tool to automate everything in your environment. This is an example of how I set up an Ansible playbook for newly deployed Linux server.
A while back, I was able to get my Ubuntu servers to join my Active Directory domain thanks to Wolfhaven’s excellent blog post on the topic. It was the most native way I could find to get the Active Directory integration to work. I took everything I learned from Wolfhaven and added it to an Ansible playbook to automate this for any server I deploy. There are enough complicated steps that Ansible ends up being the perfect option for documentation and automation.
Check out the code: https://github.com/tvories/ansible-realmd