在vagrant box和host上的pexpect版本都是4.6.0,但是当安装在ansible上时,3.1是最新版本

时间:2018-06-11 15:37:10

标签: pip ansible vagrant

我正在使用ansible在我的流浪盒和我的主机上安装pexpect。当我将pexpect安装到两台计算机上时,版本是4.6.0,但是当使用ansible来使用apt-get进行安装时,最大版本只有3.1。抛出的错误消息是:"Insufficient version of pexpect installed (3.1), this module requires pexpect>=3.3. Error was __init__() got an unexpected keyword argument 'echo'"}我如何安装pexpect才能将expect模块用于ansible?

下载pexpect的代码是

- hosts: all
  become: yes
  become_user: root
  gather_facts: no

 #can use sudo/sudo_user instead of become, but thats depreceated in       ansible 2.6 or later
  tasks:
  - name: download pip
    apt: name=python3-pip state=latest

  - name: update pexpect
    command: pip3 install pexpect
    command: pip3 install --upgrade pip3 
    command: pip3 install --upgrade pexpect

1 个答案:

答案 0 :(得分:0)

按命令运行任务并尝试使用Ansible pip模块。

- name: Install Pexpect
  hosts: all
  become: True
  become_user: root
  gather_facts: False


  tasks:

  - name: download pip
    apt:
      name: python3-pip
      state: latest

  - name: Install Pexpect
    pip:
      name: pexpect
      state: latest

  - name: Upgrade pip - Force reinstall to the latest version
    pip:
      name: pip
      state: forcereinstall