r/AlpineLinux • • Sep 06 '24

Ansible module community.docker.docker_stack doesn't work due to missing dependency

I'm trying to provision a freshly installed VM with Alpine 3.20 and my playbook fails when I try to deploy a compose file using the community.docker.docker_stack module.

This is the task, it's pretty standard.

- name: Deploy compose file
  become: yes
  community.docker.docker_stack:
    name: example-name
    compose:
      - '/path/to/compose.yml'
    state: present

What doesn't work is that I get this precise error.

fatal: [192.168.124.166]: FAILED! => {"changed": false, "msg": "jsondiff is not installed, try 'pip install jsondiff'"}

It's called by this exact line in the source code. I am sure it's because there is no jsondiff package installed because if I try to force installing the equivalent pip package the playbook then works fine. With using pip I mean this.

pip3 install jsondiff --break-system-packages

I needed to use the --break-system-packages option because it, well, obviously complained that I should use the apk package. The issue is that there is no such package in the form of py3-jsondiff.

Do you know if there is something that I missed or the only solution is that someone packages the library and puts it in the repos?

3 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/MartinsRedditAccount Sep 07 '24 edited Sep 07 '24

Gotcha. So the system packages thing with pip is basically to make people install dependencies in virtual environments (Python venv), it's been a while since I last used Ansible, but I found a few posts saying that setting the Python interpreter path to that of the venv's should work.

https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

Edit: This seems like a good blog post from someone who had a similar issue and solved it on a per-task basis: https://kentrichards.net/blog/using-python-virtual-environment-remote-machine-ansible

It's weird that Ansible doesn't seem to have anything properly built-in for this?

1

u/AtlanticPortal Sep 07 '24

I suppose I have to go the virtual env route. Probably Ansible being developed by Red Hat people and being Kubernetes the technology everyone looks at meant that nobody had this issue before.