Ansible期望模块错误

时间:2017-11-02 20:10:09

标签: ansible sysadmin

我使用Ansible 2.2.1.0

我尝试使用带有命令的ansible expect模块:

expect:
    command: set password of database
    responses:
        Admin Password for db_name: 'admin'
        Admin Password Confirmation: 'admin'

我收到此错误:

  

致命:[subdomain.xxxx.com]:失败了! => {“已更改”:false,“failed”:true,“module_stderr”:“连接到sante.c3-bs.com已关闭。\ r \ n”,“module_stdout”:“Traceback(最近一次调用最后一次):\ r \ n \ n文件\“/ tmp / ansible_ys2qrkdy / ansible_module_expect.py \”,第237行,在\ r \ n main()\ r \ n文件\“/ tmp / ansible_ys2qrkdy / ansible_module_expect.py \”,第149行,主要\ r \ n响应= u'%s \ n'%value.rstrip('\ n')。decode()\ r \ nAttributeError:'str'对象没有属性'decode'\ r \ n“,”msg “:”MODULE FAILURE“}

我不明白这个错误可以有人帮助我并给我正确的答案 expect命令的响应或正确的语法?

[编辑] **我在这里给出了所有命令:

- name: Configure tryton database
become: yes
become_method: sudo
become_user: root
expect:
    command: su - gnuhealth -c "python3 /home/gnuhealth/gnuhealth/tryton/server/trytond-4.2.6/bin/trytond-admin -c /home/gnuhealth/gnuhealth/tryton/server/config/trytond.conf -d db_name --all"
    responses:
        (?i)Admin Password for db_name: "admin"
        (?i)Admin Password Confirmation: "admin"

我使用Python 2.7.9

1 个答案:

答案 0 :(得分:0)

简单的修复似乎是使用更新的ansible版本。这个或类似的东西似乎在版本2.4 - https://github.com/ansible/ansible/pull/24269

中得到修复

如果您的系统没有提供,则可以使用pip安装新版本。请记住首先卸载系统包。

相关问题