Open PREM1980 opened 7 years ago
@PREM1980
Thanks for your interest in Ansible Container, and for taking the time to share your feedback.
Not sure what you mean by "Just followed the steps from here" with a reference to the "Dipping a toe in" topic. All that does is initialize a project with no services defined.
You should head down that page a bit further to Starting from a working base setup.
I installed Docker for Mac Beta (that seems to be what you're using), and did the following with no issues:
$ mkdir test
$ cd test
$ ansible-container init ansible.django-template
That initialized the project with a container.yml
that actually defines some service. Then I ran the following to build the images for each service:
$ ansible-container --debug build
Here are the built images:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test-nginx 20170615202652 7dea654789e8 54 seconds ago 262MB
test-nginx latest 7dea654789e8 54 seconds ago 262MB
test-django 20170615202530 fdf1fa13b160 2 minutes ago 425MB
test-django latest fdf1fa13b160 2 minutes ago 425MB
test-conductor latest 6eae3ebfde5d 4 minutes ago 523MB
centos 7 3bee3060bfc8 10 days ago 193MB
With the images successfully built, I executed run
as follows:
$ ansible-container --debug run
And the containers started as expected:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25d260303210 test-django:20170615202530 "/usr/bin/dumb-ini..." 7 seconds ago Up 5 seconds 0.0.0.0:32769->8080/tcp test_django_1
cc3951fef965 postgres:9.6 "docker-entrypoint..." 8 seconds ago Up 6 seconds 5432/tcp test_postgres_1
The error message you're getting is coming from the Python docker module. It's complaining that it cannot connect to the Docker daemon. There must be something not quite right in your environment.
The value of the DOCKER_HOST
environment variable might be probative.
Hi,
I am facing the exact same problem, trying to start a container using the docker_container module. I get a "Error connecting: Error while fetching server API version: hostname 'localhost' doesn't match u'${THIS_WOULD_BE_THE_INVENTORY_HOSTNAME}'"
. The play is:
- name: Deploying the RabbitMQ {{ cell_name }} ({{ rabbit_version }})
docker_container:
docker_url: https://{{ inventory_hostname }}:2376
name: rabbit
hostname: rabbit-{{ domain }}
image: "{{ registry_host }}:{{ registry_port }}/rabbitmq:{{ rabbit_version }}"
pull: "{{ pull }}"
network_mode: bridge
ports:
- 5672
- 15672
log_options:
max-size: 5m
max-file: 5
tls_verify: true
tls_ca_cert: "{{ ansible_env.HOME }}/.docker/ca.pem"
tls_client_cert: "{{ ansible_env.HOME }}/.docker/cert.pem"
tls_client_key: "{{ ansible_env.HOME }}/.docker/key.pem"
tags:
- deploy
The value of the DOCKER_HOST env var is identical with the inventory_hostname.
As described in ansible/ansible#29471 in more detail, we fixed this problem in our setup by defining tls_hostname
explicitly (or use tls
instead of tls_verify
). Maybe that helps here as well.
I have the same problem since weeks...i can't use ansible to install my setup..it all started with the new docker version 17.xx
Error connection: Error while fetching server API version: Timout value connect was Timeout(connect=60, read=60,total=none)
is this here related to ansible-container? because I didn't set it up. I just have in my playbook docker_container: and it worked till docker got the new versions.
@FlorianLiers Indeed, by adding the tls_hostname it works. Thanks a lot!
What and Where do you mention this ?
tls_hostname
@FlorianLiers Can you tell me where to set tls_hostname property ? I am stuck in the same issue.
@FlorianLiers Can you tell me where to set tls_hostname property ? I am stuck in the same issue.
@karthik-arris and @wandermyz: tls_hostname
is a parameter for the docker_container
module. You can find more details in the docs.
ISSUE TYPE
COMPONENT NAME
anisble-container
ANSIBLE VERSION
ansible 2.3.0.0
CONFIGURATION
Nothing changed
OS / ENVIRONMENT
MAC ..I did try a ubuntu setup and its working fine.
SUMMARY
Trying to create a ansible-container as given in this tutorial but get an error while running anisble-container run.
http://docs.ansible.com/ansible-container/getting_started.html#dipping-a-toe-in-starting-from-scratch
DOcker version (bossa)PREMs-MacBook-Pro:ansible-container-example prem$ docker version Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: darwin/amd64
Server: Version: 17.03.1-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: c6d412e Built: Fri Mar 24 00:00:50 2017 OS/Arch: linux/amd64 Experimental: true
Error:-
2017-06-14T17:57:35.236681 In conductorcmd_run [container.core] caller_file=/_ansible/container/core.py caller_func=conductorcmd_run caller_line=772 kwargs={u'with_volumes': [], 'repository_data': {}, u'service': [], u'settings': {u'pwd': u'/Users/prem/Documents/bossanova/ansible-container-example', u'conductor_base': u'centos:7'}, u'with_variables': [], u'selinux': True, u'subcommand': u'run', u'debug': True, u'devel': False, u'deployment_output_path': u'/Users/prem/Documents/bossanova/ansible-container-example/ansible-deployment', u'production': False, u'host_user_uid': 501, u'host_user_gid': 20, u'detached': False, 'volume_data': {}, u'roles_path': None} 2017-06-14T17:57:35.247794 GENERATE DEPLOYMENT [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=569 namespace=None url=None Traceback (most recent call last): File "/usr/bin/conductor", line 11, in
load_entry_point('ansible-container', 'console_scripts', 'conductor')()
File "/_ansible/container/init.py", line 19, in wrapped
return fn(args, kwargs)
File "/_ansible/container/cli.py", line 366, in conductor_commandline
params)
File "/_ansible/container/init.py", line 19, in wrapped
return fn(args, kwargs)
File "/_ansible/container/core.py", line 773, in conductorcmd_run
playbook = engine.generate_orchestration_playbook(kwargs)
File "/_ansible/container/init.py", line 19, in wrapped
return fn(*args, kwargs)
File "/_ansible/container/docker/engine.py", line 637, in generate_orchestration_playbook
for image in self.client.images.list(name=image_name):
File "/_ansible/container/docker/engine.py", line 123, in client
self._client = docker.from_env(version='auto')
File "/usr/lib/python2.7/site-packages/docker/client.py", line 79, in from_env
kwargs_from_env(*kwargs))
File "/usr/lib/python2.7/site-packages/docker/client.py", line 36, in init
self.api = APIClient(args, **kwargs)
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 141, in init
self._version = self._retrieve_server_version()
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 168, in _retrieve_server_version
'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: Timeout value connect was Timeout(connect=None, read=None, total=None), but it must be an int, float or None.
2017-06-14T13:57:35.887098 Conductor terminated. Cleaning up. [container.docker.engine] caller_file=/Users/prem/.virtualenvs/bossa/src/ansible-container/container/docker/engine.py caller_func=await_conductor_command caller_line=348 command_rc=1 conductor_id=u'9197051f2d14a22a3ea52ebdf60ab6642d4b03ff5f379859238697323b878879' save_container=False
2017-06-14T13:57:36.889002 Conductor exited with status 1 [container.cli] caller_file=/Users/prem/.virtualenvs/bossa/src/ansible-container/container/cli.py caller_func=call caller_line=286
STEPS TO REPRODUCE Just followed the steps from here..Nothing changed.
http://docs.ansible.com/ansible-container/getting_started.html#dipping-a-toe-in-starting-from-scratch
EXPECTED RESULTS
The build run should work fine.