Ansible常见问题(已解决)

1、yum模块安装RPM包时报错

报错信息:

\ndebug2: fd 3 setting TCP_NODELAY\r\ndebug2: callback done\r\ndebug2: channel 0: open confirm rwindow 0 rmax 32768\r\ndebug3: Wrote 752 bytes for a total of 2797\r\ndebug2: channel_input_status_confirm: type 99 id 0\r\ndebug2: PTY allocation request accepted on channel 0\r\ndebug2: channel 0: rcvd adjust 2097152\r\ndebug2: channel_input_status_confirm: type 99 id 0\r\ndebug2: exec request accepted on channel 0\r\ndebug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r\ndebug1: client_input_channel_req: channel 0 rtype [email protected] reply 0\r\ndebug2: channel 0: rcvd eow\r\ndebug2: channel 0: close_read\r\ndebug2: channel 0: input open -> closed\r\ndebug2: channel 0: rcvd eof\r\ndebug2: channel 0: output open -> drain\r\ndebug2: channel 0: obuf empty\r\ndebug2: channel 0: close_write\r\ndebug2: channel 0: output drain -> closed\r\ndebug2: channel 0: rcvd close\r\ndebug3: channel 0: will not send data after close\r\ndebug2: channel 0: almost dead\r\ndebug2: channel 0: gc: notify user\r\ndebug2: channel 0: gc: user detached\r\ndebug2: channel 0: send close\r\ndebug2: channel 0: is dead\r\ndebug2: channel 0: garbage collecting\r\ndebug1: channel 0: free: client-session, nchannels 1\r\ndebug3: channel 0: status: The following connections are open:\r\n #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)\r\n\r\ndebug3: channel 0: close_fds r -1 w -1 e 6\r\ndebug3: Wrote 32 bytes for a total of 2829\r\ndebug3: Wrote 64 bytes for a total of 2893\r\ndebug1: fd 1 clearing O_NONBLOCK\r\ndebug1: fd 2 clearing O_NONBLOCK\r\nConnection to 10.19.171.100 closed.\r\nTransferred: sent 2712, received 2296 bytes, in 0.1 seconds\r\nBytes per second: sent 35504.5, received 30058.3\r\ndebug1: Exit status 0\r\n",

"module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_K19Zjg/ansible_module_yum.py\", line 25, in \r\n    import yum\r\nImportError: No module named yum\r\n", 

"msg": "MODULE FAILURE"

报错原因,远程主机上默认的python版本为python2.7,在playbook中加入以下配置

vars:
ansible_python_interpreter: /usr/bin/python2.6

修改后的playbook如下:

  • hosts: ‘{{ HOST }}’
    vars:
    ansible_python_interpreter: /usr/bin/python2.6
    gather_facts: False
    become: True
    become_user: root
    roles:
    • { role: linux/wf_install_jdk }

你可能感兴趣的:(Ansible)