Ansible モジュール Expect を使用すると、次のメッセージが表示されます。 The pexpect Python モジュールが必要です。

Ansible モジュール Expect を使用すると、次のメッセージが表示されます。 The pexpect Python モジュールが必要です。

ymlファイルの一部のコード:

- name: --- run /opt/installer/bin/install.sh ---
  expect:
      command: /opt/installer/bin/install.sh
      responses:
        'Are you installing the application at the central data center? [yes/no default: yes]? [yes]': "\n"
        'What is the code of central data center [default: 01]? [01]': "\n"
        'What is ip or hostname of your server [default: localhost]? [localhost]': 'portal'

pexpect 3.3両方のサーバー(ansibleおよびターゲット)machinesにモジュールを取り付けました。

[root@portal pexpect-3.3]# python setup.py install
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /usr/lib/python2.7/site-packages/pexpect-3.3-py2.7.egg-info
Writing /usr/lib/python2.7/site-packages/pexpect-3.3-py2.7.egg-info

プレイブックを実行すると、次のエラーが発生します。

TASK [ansible-portal : --- run /opt/installer/bin/install.sh ---] *************************************************************************
fatal: [portal]: FAILED! => {"changed": false, "msg": "The pexpect python module is required"}

追加情報:

[root@ansible ansible]# ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

ベストアンサー1

これらのモジュールの一部と同様に、ansibleリモートサーバー側にインストールする必要がある特定のPythonモジュールがあります。

このモジュールを使用すると、次のようにプレイブックを介してpipこれansibleを促進できます。

- name: install pexpect
  pip:
    name: pexpect
  become: yes

ディストリビューションでは、これらのファイルをDEBファイルまたはRPMファイルとして提供することもできます。その場合は、ディストリビューションのパッケージマネージャを使用してこのPythonモジュールをインストールできます。

あなたの場合、モジュールをインストールしたPythonがpexpect使用しているPythonと異なる場合がありますansible。この場合は、システムのパッケージマネージャを使用してインストールしてくださいpexpect

パッケージマネージャを介して

Debian / Ubuntuシステムでapt-getを使用する:

$ sudo apt-get install python-pexpect

Redhatディストリビューション(Fedora / CentOS):

$ sudo yum install -y pexpect

引用する

おすすめ記事