Python pexpect issue

Running the playbook below to join a linux server to our AD domain. The screenshot below displays the version of ansible. The issue I am having is with the pexpect module. I am getting the following error at the point when the task is to join the domain.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: cannot import name ‘use_native_pty_fork’

fatal: [10.10.87.200]: FAILED! => {“changed”: false, “msg”: “Failed to import the required Python library (pexpect) on qictanstest.wlu.ca’s Python /usr/bin/python3.6. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter”}

The task of installing the pexpect module was successful. Not sure where to go next. I cannot find any information on that error.

  • name: Join Domain

hosts: xxxxxxxx

gather_facts: false

vars_files:

  • group_vars/ol8

vars_prompt:

  • name: “bind_password”

prompt: "Password for "

private: yes

tasks:

  • name: install pexpect

pip:

name: pexpect

  • name: Install the required packages

yum:

name: realmd,sssd,oddjob,oddjob-mkhomedir,adcli,samba-common,samba-common-tools,samba-client,samba-winbind,samba-winbind-clients

state: present

notify:

  • restart realmd

  • name: Join system to AD

expect:

command: /bin/bash -c “/usr/sbin/realm join --user=xxxxxxxxxxx”

responses:

Password for *: “{{ bind_password }}”

  • name: Add default_domain_suffix to sssd.conf

lineinfile:

dest: /etc/sssd/sssd.conf

line: 'default_domain_suffix = xxxxxxxxx

insertafter: ‘^[sssd]’

  • name: Allow the LinuxAdmins AD group to logon to the system

command: /bin/bash -c “/usr/sbin/realm permit -g xxxxxxxx”

  • name: Add the LinuxAdmins AD Group to sudoers

lineinfile:

dest: /etc/sudoers

line: ‘%xxxxxxxxca ALL=(ALL) ALL’

insertafter: ‘^%wheel’

handlers:

  • name: restart realmd

service:

name: realmd

state: restarted

  • name: restart sssd

service:

name: sssd

state: restarted

According to
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/expect_module.html#requirements the module needs to be available on the host that executes it.
To be fair it’s not immediately obvious what that is, but since you have the module on one end, it must mean that it is required on the other end (the host you’re managing).

So install that prior to the pexpect task.

(attachments)

image002.jpg

Thanks for the response but I do have pexpect3 installed on both the ansible server as well as the server I am managing.

Rene

(attachments)

image002.jpg

Thanks for the response but I do have pexpect3 installed on both the ansible server as well as the server I am managing.

Rene

The question is if you installed pexpect into your Python3 instance. If you have also a Python2 instance on the target
server, ansible pip module might have installed it there.

Regards
        Racke