Ansible. Error during use docker-compose module. No module named 'docker' - docker-compose

I have a problem with run my playbook.yml with docker-compose module
---
- name: Deploying asistant application services
hosts: 1.1.1.1
vars:
dest_path: /my/path
become: yes
tasks:
- name: coping file docker-compose.yml
copy:
src: ./app/docker-compose.yml
dest: "{{ dest_path }}"
loop:
- docker-compose.yml
- name: run docker applications
docker_compose:
project_src: "{{ dest_path }}"
Python version
~$ python --version
Python 3.9.4
Ansible version
~$ ansible --version
ansible [core 2.11.6]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/rafal/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/rafal/.local/lib/python3.9/site-packages/ansible
ansible collection location = /home/rafal/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.4 (default, Nov 19 2021, 16:27:14) [GCC 8.3.0]
jinja version = 3.0.3
libyaml = True
I have also installed
~$ pip3 list | grep docker
docker 5.0.3
docker-compose 1.29.2
docker-py 1.10.6
docker-pycreds 0.4.0
dockerpty 0.4.1
Python3 in my system was installed in /user/local/bin
Python2.7.16 in my system was installed in /user/bin
Run command.
python3 $(which ansible-playbook) playbook.yml -u user -K -vvv
And result after run
"msg": "Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on ASSISTANT-DEV's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` (Python >= 3.6) or `pip install docker==4.4.4` (Python 2.7) or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"
}
Actually I don't have any idea what installed yet, or what, where a must set

Related

How to install brew on a raspberry pi?

These are my raspberry pi OS, Kernel version and archtecture configs
Operating System: Raspbian GNU/Linux 10 (buster)
Kernel: Linux 5.10.52-v7l+
Architecture: arm
When I try to run their script(https://brew.sh/):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
I get
Homebrew on Linux is only supported on Intel processors!
and, whenever I try to run a brew command, I get:
-bash: brew: command not found
Homebrew for linux is called Linuxbrew. And the installation command that you need is:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Please check out this link to get more info about it: https://github.com/Linuxbrew/brew
Also notice that while Linuxbrew can run on Raspberry Pi (32-bit ARM), no binary packages are available for it.
Here are my two cents on installing brew on RaspberryPi Zero W and RaspberryPi 3+ (RaspberryPi OS, bullseye).
$ # Install dependencies
$ sudo apt update -y && sudo apt upgrade -y
$ sudo apt install git
$ # Install rbenv and Ruby 2.6.8 (It takes 30-90 min.)
$ # As of 2022/06/09, ARM processors require Ruby 2.6.8.
$ # Check the gist below what is doing as well.
$ bash <(curl -sL https://gist.github.com/KEINOS/7101f542be23e5048198e2a27c3cfda8/raw/install_ruby_rpi.sh)
$ source ~/.bashrc
$ # Smoke test Ruby
$ ruby --version
ruby 2.6.8p205 (2021-07-07 revision 67951) [armv6l-linux-eabihf]
$ # Clone homebrew repo under /opt
$ sudo git clone --depth=1 https://github.com/Homebrew/brew /opt/homebrew
$ # Setup homebrew
$ sudo chown -R $(whoami) /opt/homebrew
$ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bashrc
$ source ~/.bashrc
$ # Full update to tap homebrew/core (It takes 30-90 min.)
$ brew update --force --verbose
$ # Smoke test brew
$ brew --version
Homebrew 3.5.1
Homebrew/homebrew-core (git revision 1d9fb5dd1e6; last commit 2022-06-09)
$ # Install "hello world" package which supports both 32bit and 64 bit ARM.
$ # - Source: https://github.com/KEINOS/Hello-Cobra
$ # - Formula: https://github.com/KEINOS/homebrew-Hello-Cobra
$ brew install KEINOS/Hello-Cobra/hello-cobra
***snip***
$ hello-cobra hello world
Hello, world!
$ # Env info of RaspberryPi Zero W
$ more /proc/device-tree/model
Raspberry Pi Zero W Rev 1.1
$ cat /etc/debian_version
11.3
$ uname -a
Linux rpi-zero 5.10.92+ #1514 Mon Jan 17 17:35:21 GMT 2022 armv6l GNU/Linux
$ whoami
pi
$ echo $SHELL
/bin/bash
$ # Env info of RaspberryPi 3+
$ more /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2
$ cat /etc/debian_version
11.3
$ uname -a
Linux rpi-3pls 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux
$ whoami
pi
$ echo $SHELL
/bin/bash
Note that everything for brew is slow on ARM6. Patience is required not only when setting up linuxbrew, but also when installing packages using brew.
However, once the package has been successfully installed, it should work as fast as expected. So, I'd say it is worth trying linuxbrew on the ARM6 and ARM64 architectures.
References
ARM | Homebrew on Linux # docs.brew.sh
Untar anywhere | Installation # docs.brew.sh
How can I check the available version of a package in the repositories? # AskUbuntu.com
Installing Ruby versions | rbenv # GitHub
Raspberry Pi
Homebrew can run on Raspberry Pi (32-bit ARM), but no binary packages
(bottles) are available. Support for Raspberry Pi is on a best-effort
basis. Pull requests are welcome to improve the experience on
Raspberry Pi.
https://docs.brew.sh/Homebrew-on-Linux
Two comments on installing Homebrew on Raspberry Pi 400 Rev 1.0, Raspbian Debian 11.5.
For an unknown reason Homebrew installer requires exactly ruby version 2.6.8. My Pi has ruby 2.7.4 but that was not accepted
After installing 2.6.8 using the above hint (ruby-build available from the regular repository does not offer it, the next after 2.6.6 being 2.7.0), the brew update --force --verbose command was still failing on not finding 2.6.8. It was so because the 'brew' script has the PATH explicitely filtered to the system one, "/usr/bin:/bin:/usr/sbin:/sbin". Only after manually adding the path for ruby 2.6.8 did the update work. NB. the script was overwritten during the process so in order to install any package I had to add the path it again.
Any idea why it is "exactly 2.6.8" and not "2.6.8 or newer"?

Problems (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on ansible-awx's Python /bin/python3

SUMMARY:
I has done the installation ansible-awx follow the instruction:
https://howto.lintel.in/install-ansible-tower-awx-centos-7/
ISSUE TYPE :
When i ran command ansible-playbook -i inventory install.yml -vv
in folder source awx /root/awx/installer
Bug Report :
TASK [local_docker : Start the containers] ********************************************************************************************************************************
task path: /root/awx/installer/roles/local_docker/tasks/compose.yml:39
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on ansible-awx's Python /bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via pip install docker or pip install docker-py (Python 2.6). The error was: No module named 'requests'"}
PLAY RECAP ****************************************************************************************************************************************************************
localhost : ok=13 changed=2 unreachable=0 failed=1 skipped=86 rescued=0 ignored=0
I try ran command with : ansible-playbook -i inventory install.yml -e 'ansible_python_interpreter=/usr/bin/python3'
But error the error appears similar above .
ANSIBLE VERSION
ansible 2.9.10
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Apr 2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
OS: CentOS Linux release 7.8.2003 (Core)
Thanks for helping !
I've got the same error and I solved it installing python36-docker and docker-componse.
yum install python3 python36-docker -y
pip3 install docker-compose
then rerun:
ansible-playbook -i inventory install.yml
I run into the same issue, the following command executed on managed node (host) helped:
$ pip3 install docker

rpmbuild on CentOS: no such file or directory

I have created a simple RPM on Fedora27 and it worked fine. It just copied files from tar.gz to /usr/bin/.
When I tried to install this RPM on CentOS I got:
# rpm -i RPMS/x86_64/my_rpm-0.0-5.x86_64.rpm --force
error: Failed dependencies:
libc.so.6(GLIBC_2.26)(64bit) is needed by my_rpm-0.0-5.x86_64
So I assumed I will need to create the RPM on CentOS.
But when I do so I get a weird: 'No such file or directory' that I don't get on Fedora27. Here is a sketch of my spec file:
%define _topdir %(pwd)
%define name my_rpm
%define release 5
%define version 0.0
%define buildroot %{_topdir}/%{name}-%{release}-root
BuildRoot: %{buildroot}
Summary: my_rpm
License: -
Name: %{name}
Release: %{release}
Version: %{version}
Source: %{name}-%{version}-%{release}.tar.gz
Prefix: /usr
Group: Tools
%description
This is my_rpm spec file
%prep
%setup -q -n %(arch)/%{name}-%{version}
%install
install -D my_app -t %{buildroot}/usr/bin/my_rpm/
%files
/usr/bin/my_rpm/*
When I try to build the RPM for it I get:
# rpmbuild -v -bb --clean SPECS/bpf.spec
+ install -D app -t /root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/
install: failed to access '/root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/': No such file or directory
The same SPEC exactly runs smoothly on Fedora27.
What should I change in it my spec file so that it would work both on Fedora27 and CentOS7? or maybe I can fix my initial problem with Glibc?
EDIT 1
I added the "mkdir -p ..." command under install and the build was successful but it still gives me the same error, that I need Glibc 2.6.
What I don't understand is why during the build it says:
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.26)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.3.4)(64bit) libc.so.6(GLIBC_2.7)(64bit) libc.so.6(GLIBC_2.9)(64bit) libelf.so.1()(64bit) libelf.so.1(ELFUTILS_1.0)(64bit) rtld(GNU_HASH)
Edit 2(solution)
I got it to work. My executables are compiled C code. So I had to re-compile everything on CentOS and then build the rpm. Now it works on both Fedora and CentOS.

Dockerfile builds on linux/mac host OS, but not on Windows 10

I have the following Dockerfile for a django app:
FROM python:3.6
RUN mkdir /server
WORKDIR /server
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
libsqlite3-dev
RUN pip install -U pip setuptools
RUN pip install --upgrade pip
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
WORKDIR /server/django
ENTRYPOINT ["/bin/bash", "../docker-entrypoint-server"]
relevant docker-compose related to it:
version: '3'
services:
server:
build: .
container_name: server
environment:
SERVER_ENV: ${SERVER_ENV}
DB_AUTH_SOURCE: ${DB_AUTH_SOURCE}
DB_NAME: ${DB_NAME}
DB_HOST: ${DB_HOST}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
networks:
- app
ports:
- 8081:8000
volumes:
- .:/server
command: /bin/bash
tty: true
stdin_open: true
they work like a charm on linux/mac, but not on Windows 10. When the build reaches the COPY instruction, all it copies are the directory and only the first nested directory within it with no content attached to it.
tried to check for the shared C:\ option on docker, didnt work.
tried on powershell with admin rights and nothing.
What could be the possible causes? Why it works on two host OS and not on Win 10?
edit 1: versions
Windows: Windows 10 Education, 1803
Linux: Ubuntu 18.03 LTS
Mac: High Sierra 10.03
Docker: latest version on all OSs
edit 2: the solution
Turns out that unsharing and sharing, pointed out by JDPeckham, revealed the problem: a firewall misconfig caused by an antivirus that was controlling these configs.
This article: https://success.docker.com/article/error-a-firewall-is-blocking-file-sharing-between-windows-and-the-containers is very helpful for troubleshooting those.

AWS ElasticBeanstalk amazon linux pg_config error with psycopg2

I am testing AWS for launching web service.
I stuck with pg_config. Error log is
/app/requirements.txt (line 1))
Using cached psycopg2-2.6.2.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
There are many solutions in stackoverflow, but it doesn't work for me.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "onreview/wsgi.py"
This is my .ebextensions/python.config files contents. And I'm uploading through zipping my source code.
I changed postgresql95-devel to postgresql-devel, 93, 94, all of it. And I use 9.5 version db right now.
I think --pg-config's path is problem. but I can't change it.
Is there any solution??
p.s I do not want to setup inside the EC2 instance through SSH or something.
You have a syntax error in your original post, packages: should not be indented. I don't know why you have python-devel when python is included in the install, so I can't say that it isn't interfering. Likewise with the line setting the python path.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
aws:elasticbeanstalk:container:python:
WSGIPath: "onreview/wsgi.py"