geerlingguy / ansible-role-docker_arm

Ansible Role - Docker for ARM and Pi
MIT License
98 stars 28 forks source link

Install docker-compose's missing dependencies #4

Closed whoan closed 4 years ago

whoan commented 5 years ago

This PR solves some errors I had on a clean installation of Raspbian (Buster).

stale[bot] commented 4 years ago

This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark pull requests as stale.

offbyone commented 4 years ago

This is still needed; can this be merged?

stale[bot] commented 4 years ago

This issue is no longer marked for closure.

geerlingguy commented 4 years ago

Is this only the case on Raspbian 10? Or is this happening in regular old Debian as well?

The Debian 10 tests seem to pass without issue: https://travis-ci.com/github/geerlingguy/ansible-role-docker_arm/jobs/299281915

geerlingguy commented 4 years ago

Related to #7?

whoan commented 4 years ago

Is this only the case on Raspbian 10? Or is this happening in regular old Debian as well?

I only tested it on Raspbian 10

Related to #7?

@geerlingguy Yes, this PR would solve #7

tslmy commented 4 years ago

Tested locally on a Raspberry Pi 4 B (4GB) with latest Raspbian ; works.

geerlingguy commented 4 years ago

I just tested on my drupal-pi project (which uses this role on a Pi 4 B with Raspbian 10 (latest build, 2020-02-13), and didn't have any issues... but maybe there's some configuration I'm using in that project which masks the error.

geerlingguy commented 4 years ago

I'm doing a bit of debugging—I wanted to see if I could reproduce the original issue. I have the following release installed:

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster

And used the following inventory:

[pi]
10.0.100.137 ansible_user=pi ansible_python_interpreter=/usr/bin/python3

And the following playbook:

---
- hosts: pi
  become: yes

  pre_tasks:
    - apt: update_cache=true

  roles:
    - geerlingguy.pip
    - geerlingguy.docker_arm

And here's the issue that crops up when installing docker-compose:

TASK [geerlingguy.docker_arm : Install Docker Compose using Pip.] ******************************************************
fatal: [10.0.100.137]: FAILED! => {"changed": false, "cmd": ["/usr/bin/pip", "install", "docker-compose"], "msg": "stdout: Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting docker-compose
  Downloading https://files.pythonhosted.org/packages/40/91/670b31a1c452cc5f3ed9e1ff905f6c4501a182551dfd8fa1981a8dca2d67/docker_compose-1.25.4-py2.py3-none-any.whl (136kB)
Collecting backports.ssl-match-hostname<4,>=3.5; python_version < \"3.5\" (from docker-compose)
...
      arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
       #include <ffi.h>
                ^~~~~~~
      compilation terminated.
      error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

      ----------------------------------------
  Command \"/usr/bin/python -u -c \"import setuptools, tokenize;__file__='/tmp/pip-install-iIIX7K/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\
', '\
');f.close();exec(compile(code, __file__, 'exec'))\" install --record /tmp/pip-record-DHakrI/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-3VFTEr --compile\" failed with error code 1 in /tmp/pip-install-iIIX7K/cffi/

  ----------------------------------------

:stderr: Command \"/usr/bin/python -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-3VFTEr --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel \"cffi>=1.1; python_implementation != 'PyPy'\"\" failed with error code 1 in None
"}
geerlingguy commented 4 years ago

I think the problem is the docker_pip_executable is hardcoded to pip, which tries installing with Python 2.7.x—this is the command:

"/usr/bin/pip", "install", "docker-compose"

If I use the playbook:

---
- hosts: pi
  become: yes

  vars:
    pip_package: python3-pip
    docker_pip_executable: pip3

  pre_tasks:
    - apt: update_cache=true

  roles:
    - geerlingguy.pip
    - geerlingguy.docker_arm

Then everything installs properly. So the best answer, I think, is to start defaulting to Python 3 / pip3. I'm going to make those changes (rather than complicate this role further by overwriting installs like this PR is doing.

That said, some people may want to use python / Python 2, so this PR can offer guidance in that scenario.

I will update the defaults in this role to reflect Python 3 and pip3, and also the README as needed.

davidlballenger commented 4 years ago

I'm continuing to have installation of docker-compose fail with the error mentioned above, even after adding the vars shown in the above playbook. I found that I had to change the apt pre_task to install libffi-dev.

I've tested this on:

All had an 'apt update' and 'apt full-upgrade' applied followed by a reboot as part of the initial installation before running the playbook. All failed on installation of docker-compose until I added installation of libffi-dev.

Thanks - David