Vagrant Box 和主机上的 Pexpect 版本都是 4.6.0,但是在 Ansible 上安装时,3.1 是最



我正在使用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

每个命令运行一个任务,并尝试使用 Ansiblepip模块。

- 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

最新更新