无法运行Ansible的“期望”模块

时间:2019-02-06 12:43:16

标签: ansible

我正在尝试运行一个Ansible脚本来调用“期望”模块(请参阅消息末尾)。

运行它时出现错误:

  

需要pexpect python模块

但是,用于安装pexpect的pip任务运行没有错误。

我在做什么错了?

谢谢。

AlainDésilets

===剧本内容===

---
- name: Run Anaconda shell

  hosts: all
  vars:
      conda_home: "~/anaconda2-NEW"
      conda_inst_sh_path: /path/to/Anaconda2-2018.12-MacOSX-x86_64.sh

  tasks:

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

    - name: Run anaconda installation script
      expect:
        command: "sh {{conda_inst_sh_path}}"
        responses:
          (?i)password: "MySekretPa$$word"
      become: yes
      become_user: root

1 个答案:

答案 0 :(得分:0)

expect module的Ansible文档指出:

  

执行此模块的主机需要满足以下要求。   
python >= 2.6   
pexpect >= 3.3

除了在目标系统上的pexpect> = 3.3之外,还需要以python的最低版本安装2.6,这意味着您必须在pexpect下定义的每个系统上安装pythonhosts: all

相关问题