Configuring AWX to Retrieve Dynamic Inventory from Active Directory Using LDAP

This tutorial will guide you through the process of configuring AWX to obtain dynamic inventory from Active Directory (AD) via LDAP.

Summary of Steps:

  1. Create Custom Credential Type for ‘Microsoft AD LDAP’
    • Define a custom credential type tailored for Microsoft AD LDAP within AWX.
  2. Create a Credential for ‘Microsoft AD LDAP’
    • Establish a credential to authenticate with Active Directory.
  3. Add Inventory/Playbook File to Your Git Repository
    • Incorporate an inventory or playbook file in your Git repository that utilizes the microsoft.ad.ldap plugin.
  4. Synchronize the Project Connected to Your Repository
    • Sync the AWX project associated with your Git repository.
  5. Create an Inventory for ‘Microsoft AD LDAP Inventory’
    • Set up an inventory within AWX specifically for Microsoft AD LDAP.
  6. Create an Inventory Source Using the Newly Added Inventory
    • Define an inventory source that leverages the newly created inventory.
  7. Synchronize the Inventory and Verify Hosts
    • Sync the inventory and ensure that the hosts are accurately added.

Let’s dig deeper.

  1. Create Custom Credential Type for ‘Microsoft AD LDAP’

From AWX web portal, go to Administration >> Credential Types >> click Add

Create New Credential Type window, give a name, input configuration and injector configuration:

Name: Microsoft AD LDAP Type

Input configuration:

Injector configuration

Save and now we can create credentials.

2. Create a Credential for ‘Microsoft AD LDAP’

From AWX Web portal, go to Resources >> Credentials >> click Add

Name: Microsoft AD LDAP

Credential Type: Microsoft AD LDAP Type

LDAP Server: your-AD-server

LDAP Port: 389

LDAP Username: user@domain

3. Add Inventory/Playbook File to Your Git Repository

For this, I created inventories/microsoft.ad.ldap.yml with following code

4. Synchronize the Project Connected to Your Repository

Sync the Project connected to your Git or Source code repository.

5. Create an Inventory for ‘Microsoft AD LDAP Inventory’

From AWX Web portal, go to Resources >> Inventory – click Add >> Add Inventory

Name: Microsoft AD LDAP Inventory

Click Save, then go to Sources tab, click Add

Click Save, then click Sync

If successful you will see the computers under Hosts Tab:

Pre-requisites:

EE Environment: Must have the following:

  • dnspython – For option server lookup support
  • pyspnego >= 0.8.0
  • pyspnego[kerberos] – For Kerberos and server lookup support
  • sansldap
  • dpapi-ng – For LAPS decryption support

If you don’t have a suitable EE environment which includes the above then follow my tutorial/blog: creating-a-custom-ee-for-awx/

And a requirements.yml file with the following content:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *