You could probably get away with changing your task to do something like:
name: join system to ad
shell: echo “{{ domain_password }}” | realm join -U ansibleuser addomain.com
But it’s generally bad practice to put passwords on the command line, since anyone logged onto the target machine could just do “ps” and see the password exposed.
Another option would be to create a keytab for “ansibleuser” then have the playbook kinit the service account using the keytab and do an unattended join. But you’d have to make sure that everything is cleaned up (keytab and the associated ticket cache) after the join is complete.
Neither of these are idempotent, however. So every time you run the playbook it will just be trying to do the join again no matter the status of the machine.
Hey Steve, Thank you so much, You’re a life saver, the shell: echo “{{ domain_password }}” | realm join -U ansibleuser addomain.com seemed to work perfectly fine. once again thank you very much Steve.
and Kai I tried the expect module and it promoted me to install pexpect module 3.3 which is currently not recommended by Red Hat and my company doesn’t want to have pexpect 3.3 therefore i needed another way around.