我的环境:
X@mbp 7 % docker version
Client:
Cloud integration: v1.0.24
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:04:45 2022
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.10.0 (82025)
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:23 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0
X@mbp ~ % docker-compose --version
Docker Compose version v2.6.1
X@mbp 7 %
我正试着按照安斯普的战术行事:
X@mbp 7 % cat elastic.yml
- name: community.docker.docker_compose
hosts: localhost
gather_facts: no
tasks:
- name: state:present
community.docker.docker_compose:
project_src: "/opt/X/{{item}}"
files: [ "docker-compose.yml" , "docker-compose.override.yml" ]
state: present
with_items:
- kubefwd
#- auditbeat
- filebeat
- kibana
- logstash
- metricbeat
#- packetbeat%
X@mbp 7 %
并得到以下错误:
无法加载停靠合成。请尝试pip install docker-compose
X@mbp 7 % ansible-playbook elastic.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [community.docker.docker_compose] *****************************************************************************************************************************************************************
TASK [state:present] ***********************************************************************************************************************************************************************************
failed: [localhost] (item=kubefwd) => {"ansible_loop_var": "item", "changed": false, "item": "kubefwd", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_4_yo5xd0/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
failed: [localhost] (item=filebeat) => {"ansible_loop_var": "item", "changed": false, "item": "filebeat", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_awbyirse/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
failed: [localhost] (item=kibana) => {"ansible_loop_var": "item", "changed": false, "item": "kibana", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_x460bn36/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
failed: [localhost] (item=logstash) => {"ansible_loop_var": "item", "changed": false, "item": "logstash", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_k3uv1s2y/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
failed: [localhost] (item=metricbeat) => {"ansible_loop_var": "item", "changed": false, "item": "metricbeat", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_a6j6gs6m/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
PLAY RECAP *********************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
X@mbp 7 % pip install docker-compose
模块未找到错误:没有名为"compose"的模块
即使我安装了docker-compose,我仍然得到相同的错误:
X@mbp 7 % pip install docker-compose
Requirement already satisfied: docker-compose in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (1.29.2)
Requirement already satisfied: docopt<1,>=0.6.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (0.6.2)
Requirement already satisfied: distro<2,>=1.5.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (1.7.0)
Requirement already satisfied: texttable<2,>=0.9.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (1.6.4)
Requirement already satisfied: websocket-client<1,>=0.32.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (0.59.0)
Requirement already satisfied: docker[ssh]>=5 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (5.0.3)
Requirement already satisfied: jsonschema<4,>=2.5.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (3.2.0)
Requirement already satisfied: requests<3,>=2.20.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (2.28.1)
Requirement already satisfied: dockerpty<1,>=0.4.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (0.4.1)
Requirement already satisfied: python-dotenv<1,>=0.13.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (0.20.0)
Requirement already satisfied: PyYAML<6,>=3.10 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker-compose) (5.4.1)
Requirement already satisfied: paramiko>=2.4.2 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from docker[ssh]>=5->docker-compose) (2.11.0)
Requirement already satisfied: six>=1.3.0 in /Users/X/.local/lib/python3.9/site-packages (from dockerpty<1,>=0.4.1->docker-compose) (1.16.0)
Requirement already satisfied: setuptools in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (49.2.1)
Requirement already satisfied: pyrsistent>=0.14.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (0.18.1)
Requirement already satisfied: attrs>=17.4.0 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (21.4.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (1.26.9)
Requirement already satisfied: idna<4,>=2.5 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2022.6.15)
Requirement already satisfied: charset-normalizer<3,>=2 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2.1.0)
Requirement already satisfied: bcrypt>=3.1.3 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (3.2.2)
Requirement already satisfied: pynacl>=1.0.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (1.5.0)
Requirement already satisfied: cryptography>=2.5 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (37.0.2)
Requirement already satisfied: cffi>=1.1 in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (1.15.1)
Requirement already satisfied: pycparser in /Users/X/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (2.21)
X@mbp 7 % ansible-playbook elastic.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [community.docker.docker_compose] *****************************************************************************************************************************************************************
TASK [state:present] ***********************************************************************************************************************************************************************************
failed: [localhost] (item=kubefwd) => {"ansible_loop_var": "item", "changed": false, "item": "kubefwd", "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/var/folders/s5/d76h78tn0hq6w_tppbfkz9mc0000gn/T/ansible_community.docker.docker_compose_payload_vku36wx9/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 497, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
...
请指教。谢谢!
1条答案
按热度按时间rsl1atfo1#
只需向任务添加一个
ansible_python_interpreter
变量,并将其指向Python安装,如下所示: