ansible-collections / community.docker

Community Docker Collection for Ansible: modules and plugins for working with Docker
https://galaxy.ansible.com/ui/repo/published/community/docker/
GNU General Public License v3.0
200 stars 115 forks source link

TypeError: expected str, bytes or os.PathLike object, not NoneType #885

Closed jryburn closed 4 months ago

jryburn commented 4 months ago
SUMMARY

Getting an error when running community.docker.docker_compose_v2 with docker compose v2.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: expected str, bytes or os.PathLike object, not NoneType
fatal: [docklands]: FAILED! => changed=false 
  ansible_facts:
    discovered_interpreter_python: /usr/bin/python3
  module_stderr: |-
    Shared connection to docklands closed.
  module_stdout: |-
    Traceback (most recent call last):
      File "/home/jryburn/.ansible/tmp/ansible-tmp-1718564577.664031-17406-270974829020286/AnsiballZ_docker_compose_v2.py", line 107, in <module>
        _ansiballz_main()
      File "/home/jryburn/.ansible/tmp/ansible-tmp-1718564577.664031-17406-270974829020286/AnsiballZ_docker_compose_v2.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/jryburn/.ansible/tmp/ansible-tmp-1718564577.664031-17406-270974829020286/AnsiballZ_docker_compose_v2.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.community.docker.plugins.modules.docker_compose_v2', init_globals=dict(_module_fqn='ansible_collections.community.docker.plugins.modules.docker_compose_v2', _modlib_path=modlib_path),
      File "<frozen runpy>", line 226, in run_module
      File "<frozen runpy>", line 98, in _run_module_code
      File "<frozen runpy>", line 88, in _run_code
      File "/tmp/ansible_community.docker.docker_compose_v2_payload_25tm_220/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 642, in <module>
      File "/tmp/ansible_community.docker.docker_compose_v2_payload_25tm_220/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 633, in main
      File "/tmp/ansible_community.docker.docker_compose_v2_payload_25tm_220/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 419, in __init__
      File "/tmp/ansible_community.docker.docker_compose_v2_payload_25tm_220/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/module_utils/compose_v2.py", line 561, in __init__
      File "<frozen posixpath>", line 418, in abspath
    TypeError: expected str, bytes or os.PathLike object, not NoneType
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1
ISSUE TYPE
COMPONENT NAME

community.docker.docker_compose_v2

ANSIBLE VERSION
ansible [core 2.14.2]
  config file = /Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg
  configured module search path = ['/Users/jryburn/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/jryburn/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.6 (main, Aug 30 2022, 05:12:36) [Clang 13.1.6 (clang-1316.0.21.2.5)] (/usr/local/opt/python@3.10/bin/python3.10)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /Users/jryburn/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.docker 3.10.3 
CONFIGURATION
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = False
CONFIG_FILE() = /Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg
DEFAULT_HOST_LIST(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = ['/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/hosts.ini']
DEFAULT_ROLES_PATH(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = ['/etc/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = yaml
DEPRECATION_WARNINGS(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = False
HOST_KEY_CHECKING(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = False
INTERPRETER_PYTHON(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = auto_silent
PERSISTENT_COMMAND_TIMEOUT(/Users/jryburn/Documents/GitHub/ryburn-network-playbooks/ansible.cfg) = 60
OS / ENVIRONMENT

Screenshot 2024-06-16 at 2 08 23 PM

STEPS TO REPRODUCE

I get the error every time I run the playbook.

https://pastebin.com/MchPZCyK
EXPECTED RESULTS

I would expect that the playbook would work through each project, pull down the latest containers, and rebuild the containers using the new images. This worked fine with community.docker.docker_compose when I was running docker-compose < 2.0 on these servers.

ACTUAL RESULTS
https://pastebin.com/x4ePdYMa
felixfontein commented 4 months ago

You need to specify either project_src or definition in every community.docker.docker_compose_v2 task. Unfortunately the check for that got lost, so the module doesn't complain about it but instead crashes when it assumes that one of them has been provided...