Ansible playbook 和 docker_compose 任务在更新后失败

Ansible playbook 和 docker_compose 任务在更新后失败

有谁能好心帮助我吗?

更新后我仍遇到此问题。我正在运行一个 ansible playbook,其中每个服务都定义为一个角色,并有单独的任务来调出容器。

遇到错误此错误:'container.image_config['ContainerConfig'].get('Volumes') or {}'并且它正在使用散列名称重新创建我的容器,例如 419bbc4d6207_grafana

我在我的角色下定义了以下任务。

- name: Run docker compose for Grafana
  docker_compose:

这是完整的回溯。

  File "/tmp/ansible_docker_compose_payload_on1b18vl/ansible_docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py", line 865, in cmd_up
  File "/usr/local/lib/python3.10/dist-packages/compose/project.py", line 697, in up
    results, errors = parallel.parallel_execute(
  File "/usr/local/lib/python3.10/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/local/lib/python3.10/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/local/lib/python3.10/dist-packages/compose/project.py", line 679, in do
    return service.execute_convergence_plan(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 579, in execute_convergence_plan
    return self._execute_convergence_recreate(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 499, in _execute_convergence_recreate
    containers, errors = parallel_execute(
  File "/usr/local/lib/python3.10/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/local/lib/python3.10/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 494, in recreate
    return self.recreate_container(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 612, in recreate_container
    new_container = self.create_container(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 330, in create_container
    container_options = self._get_container_create_options(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 921, in _get_container_create_options
    container_options, override_options = self._build_container_volume_options(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 960, in _build_container_volume_options
    binds, affinity = merge_volume_bindings(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 1548, in merge_volume_bindings
    old_volumes, old_mounts = get_container_data_volumes(
  File "/usr/local/lib/python3.10/dist-packages/compose/service.py", line 1579, in get_container_data_volumes
    container.image_config['ContainerConfig'].get('Volumes') or {}
fatal: [localhost]: FAILED! => {
    "changed": false,
    "errors": [],
    "invocation": {
        "module_args": {
            "api_version": "auto",
            "build": false,
            "ca_path": null,
            "client_cert": null,
            "client_key": null,
            "debug": false,
            "definition": null,
            "dependencies": true,
            "docker_host": "unix:///var/run/docker.sock",
            "env_file": null,
            "files": null,
            "hostname_check": false,
            "nocache": false,
            "profiles": null,
            "project_name": null,
            "project_src": "/home/x/github/ans_play/roles/grafana/",
            "pull": false,
            "recreate": "smart",
            "remove_images": null,
            "remove_orphans": false,
            "remove_volumes": false,
            "restarted": false,
            "scale": null,
            "services": null,
            "ssl_version": null,
            "state": "present",
            "stopped": false,
            "timeout": null,
            "tls": false,
            "tls_hostname": null,
            "use_ssh_client": false,
            "validate_certs": false
        }
    },
    "module_stderr": "Recreating 419bbc4d6207_grafana ... \n",
    "module_stdout": "",
    "msg": "Error starting project 'ContainerConfig'"
}

相关内容