Use ansible to allow AD authentication

I am trying to push AD authentication out to a series of Oracle Linux machines.
The command is: realm join --verbose “domain.local” --user “domain_service”

Hi:

I am trying to push AD authentication out to a series of Oracle Linux machines.
The command is: realm join --verbose “domain.local” --user “domain_service”


  • tasks: Add server to AD
    hosts: ‘ud-srv’
    become: true
    vars:
    realm_name:
    realm: “domain.local”
    user: “domain_service”
    pass: ‘Passwd!!’

tasks:

  • name: Join the AD Domain

command: realm join --verbose “{{realm_name.realm}}” --user “{{realm_name.user}}” --one-time-password= “{{realm_name.pass}}”

Have you manually tried this same exact command on the shell? Is it supposed to not ask for a password? Also, I can notice there’s a white space between “=” and “{{realm_name.pass}}”, is that intentional or a mistake?

When I’m not sure how a command (or shell instruction) might work when running through ansible, I use to put an echo at the beginning, register the output in a variable, show it to stdout and copy &paste manually on the shell for testing:

  • name: Join the AD Domain

command: echo realm join --verbose “{{realm_name.realm}}” --user “{{realm_name.user}}” --one-time-password= “{{realm_name.pass}}”
register: result

  • debug: msg={{ result }}

Hope this helps you.

do you get an error or anything?

The shell command is #realm join --verbose “domain.local” --user “vm_service”
Then it prompts for the vm_service password