Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_compose module doesn't parse properly the DOCKER_TIMEOUT environement variable #551

Closed
jknetl opened this issue Jan 12, 2023 · 2 comments · Fixed by #554
Closed
Labels
bug Something isn't working docker-compose-v1 Docker Compose v1 docker-plain plain Docker (no swarm, no compose, no stack) docker-swarm Docker Swarm

Comments

@jknetl
Copy link

jknetl commented Jan 12, 2023

SUMMARY

When I set a DOCKER_TIMEOUT environment variable on a managed node. Then docker_compose module is not able to start or stop containers.

For example, when I set DOCKER_TIMEOUT to 1200 then the variable is detected by Ansible but reported as having a wrong type (the logs contains "timeout value connect was 1200, but it must be an int, float or None."

The issue has a workarounds:

  1. Unset the DOCKER_TIMEOUT variable on the managed node (the default value is then used)
  2. use the timeout: 1200 inside the yaml task definiton to override this

However it would be nice being able to use the managed node default from the environment variable.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_compose

ANSIBLE VERSION
$ ansible --version
ansible [core 2.14.1]
  config file = /home/test/repos/docker-compose/ansible/ansible.cfg
  configured module search path = ['/home/test/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/test/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list community.docker 

# /usr/lib/python3.10/site-packages/ansible_collections
Collection       Version
---------------- -------
community.docker 3.3.1  

# /home/test/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.docker 3.1.0  
CONFIGURATION
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/test/repos/docker-compose/ansible/ansible.cfg
DEFAULT_HOST_LIST(/home/test/repos/docker-compose/ansible/ansible.cfg) = ['/home/test/repos/docker-compose/ansible/hosts.yml']
OS / ENVIRONMENT

Control node: Arch linux
Managed nodes: Ubuntu 22, Arch linux

Docker version:

Client:
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.19.4
 Git commit:        3a2c30b63a
 Built:             Tue Dec 20 20:43:40 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.4
  Git commit:       42c8b31499
  Built:            Tue Dec 20 20:42:46 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.14
  GitCommit:        9ba4b250366a5ddde94bb7c9d1def331423aa323.m
 runc:
  Version:          1.1.4
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

STEPS TO REPRODUCE

Steps to reproduce

  1. create a playbook similar to example below (use an arbitrary compose file)
  2. define DOCKER_TIMEOUT=1200 in /etc/profile on the managed node
  3. run ansible playbook

Example playbook

- name: Start docker containers
  hosts: all
  tasks:
   - name: docker compose up
     docker_compose:
       project_src: /path/to/folder/with/docker-compose/  # REPLACE THE PATH
       state: present
EXPECTED RESULTS

The docker compose up finishes successfully

ACTUAL RESULTS
ansible-playbook tasks.yml

PLAY [Start docker containers] **********************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************
[WARNING]: Platform linux on host localhost is using the discovered Python interpreter at /usr/bin/python3.10, but future installation
of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
core/2.14/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]

TASK [docker compose up] ****************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: Timeout value connect was 1200, but it must be an int, float or None."}

PLAY RECAP ******************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
meout value connect was 1200, but it must be an int, float or None."}
@felixfontein felixfontein added bug Something isn't working docker-plain plain Docker (no swarm, no compose, no stack) docker-compose-v1 Docker Compose v1 docker-swarm Docker Swarm and removed docker-plain plain Docker (no swarm, no compose, no stack) labels Jan 12, 2023
@felixfontein
Copy link
Collaborator

Thanks for reporting this. This is a problem for most modules in this collection BTW, not just docker_compose.

@felixfontein
Copy link
Collaborator

#554 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docker-compose-v1 Docker Compose v1 docker-plain plain Docker (no swarm, no compose, no stack) docker-swarm Docker Swarm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants