在docker-compose.yml中使用docker_service模块时,“TypeError:不能在类似字节的对象上使用string模式”

我有以下docker-compose.yml

 version: "3" services: container0: image: myimage build: context: . ports: - "10000:22" container1: image: myimage build: context: . ports: - "10001:22" container2: image: myimage build: context: . ports: - "10002:22" 

以及我的手册中的以下任务:

  - name: setting up containers docker_service: project_src: . files: - docker-compose.yml state: present 

docker-compose.yml似乎是正确的,当直接使用docker-compose up时,没有错误。

但是当运行我的剧本,我得到以下内容:

 $ ansible-playbook -e 'ansible_python_interpreter=/usr/bin/python3' playbook.yml PLAY [set up containers] ********************************************************************************************************** TASK [Gathering Facts] ***************************************************************************************************** ok: [localhost] [...] TASK [setting up containers] *********************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Creating containers_container0_1 ... \r\nCreating containers_container2_1 ... \r\nCreating containers_container1_1 ... \r\n\u001b[1A\u001b[2K\rCreating containers_container0_1 ... \u001b[32mdone\u001b[0m\r\u001b[1B\u001b[1A\u001b[2K\rCreating containers_container2_1 ... \u001b[32mdone\u001b[0m\r\u001b[1B\u001b[1A\u001b[2K\rCreating containers_container1_1 ... \u001b[32mdone\u001b[0m\r\u001b[1BTraceback (most recent call last):\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 1016, in <module>\n main()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 1011, in main\n result = ContainerManager(client).exec_module()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 608, in exec_module\n result = self.cmd_up()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 703, in cmd_up\n get_stdout(fd_name)\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 512, in get_stdout\n new_line = re.sub(r'\\x1b\\[.+m', '', line.encode('ascii'))\n File \"/usr/lib/python3.6/re.py\", line 191, in sub\n return _compile(pattern, flags).sub(repl, string, count)\nTypeError: cannot use a string pattern on a bytes-like object\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0} to retry, use: --limit @/home/vmonteco/Code/Perso/Ansible/containers/playbook.retry PLAY RECAP ***************************************************************************************************************** localhost : ok=6 changed=0 unreachable=0 failed=1 

什么可能导致这个错误?

尽pipe运行此命令后,容器仍然成功创build并启动。

错误摘录:

… File \“/ usr / lib / python3.6 / re.py \”,第191行…

Python 3? Ansible还没有完全兼容Python 3(截至写这个答案的时候)。