I noticed you guys got rid of the requirement to have the ansible-container definition in the compose file, but for some reason it looks like when going to run the ansible scripts, it has trouble finding the orchestration container. ansible-container gets built properly, and templated out properly. But then this occurs:
No container with the name ansible-container
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/cli.py", line 178, in commandline
**vars(args))
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/engine.py", line 244, in cmdrun_build
touched_hosts = engine_obj.hosts_touched_by_playbook()
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 56, in hosts_touched_by_playbook
builder_container_id = self.get_builder_container_id()
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 172, in get_builder_container_id
return self.get_container_id_by_name(self.builder_container_img_name)
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 132, in get_container_id_by_name
raise NameError('No container with the name %s' % name)
NameError: No container with the name ansible-container
Adding the container back to the containers.yml file helps, but then I run into a hang issue (will deal with that separately):
ansible-container:
image: python:2.7
$ sudo ansible-container --debug build
Project name is example
Initialized with params: {'purge_last': True, 'subcommand': 'build', 'engine_args': {'engine_name': 'docker', 'purge_last': True, 'subcommand': 'build', 'engine_args': {...}, 'base_path': '/home/ubuntu/ansible-container/example', 'ansible_options': u'', 'flatten': True, 'kwargs': {'debug': True, 'subcommand': 'build', 'no_purge_last': True}, 'debug': True, 'rebuild': False, 'no_purge_last': True}, 'no_purge_last': True, 'ansible_options': u'', 'flatten': True, 'kwargs': {'debug': True, 'subcommand': 'build', 'no_purge_last': True}, 'debug': True, 'rebuild': False}
(Re)building the Ansible Container image.
Using temporary directory /tmp/tmpPzeAbA...
Building Docker Engine context...
Rendered Jinja Template:
FROM python:2.7
# Add the dockerproject repo
RUN apt-get update -y
RUN apt-get install -y apt-transport-https ca-certificates
RUN echo "deb https://apt.dockerproject.org/repo debian-jessie main">/etc/apt/sources.list.d/docker.list
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# Install required packages, including docker-engine which gives us access a docker client
RUN apt-get update -y && \
apt-get install -y python-setuptools git python-pip docker-engine && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD hosts /etc/ansible/inventory/hosts
ADD ansible /ansible-tmp/
# RUN pip install -q --no-cache-dir 'ansible=='
RUN pip install -q --no-cache-dir -e git+https://github.com/ansible/ansible.git@devel#egg=ansible
RUN test '(! -f /ansible-tmp/requirements.txt)' || pip install --no-cache-dir -r /ansible-tmp/requirements.txt
RUN rm -rf /ansible-tmp/
Rendered Jinja Template:
[docker]
gulp ansible_host=ansible_gulp_1
static ansible_host=ansible_static_1
postgresql ansible_host=ansible_postgresql_1
django ansible_host=ansible_django_1
Starting Docker build of Ansible Container image...
Cleaning up temporary directory /tmp/tmpPzeAbA...
{"stream":"Step 1 : FROM python:2.7\n"}
{"status":"Pulling from library/python","id":"2.7"}
{"status":"Digest: sha256:53ececa6c98c67079fc019644b364608f7fa4ae06cff372a5cb2fc82c90961d4"}
{"status":"Status: Image is up to date for python:2.7"}
{"stream":" ---\u003e a047e3d0ae2b\n"}
{"stream":"Step 2 : RUN apt-get update -y\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 668ba94034ca\n"}
{"stream":"Step 3 : RUN apt-get install -y apt-transport-https ca-certificates\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 3ac2349a75d5\n"}
{"stream":"Step 4 : RUN echo \"deb https://apt.dockerproject.org/repo debian-jessie main\"\u003e/etc/apt/sources.list.d/docker.list\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e a018778e0717\n"}
{"stream":"Step 5 : RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 71707cb1f3db\n"}
{"stream":"Step 6 : RUN apt-get update -y \u0026\u0026 apt-get install -y python-setuptools git python-pip docker-engine \u0026\u0026 apt-get clean \u0026\u0026 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 8a31d2e0fad4\n"}
{"stream":"Step 7 : ADD hosts /etc/ansible/inventory/hosts\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e eb6488041be3\n"}
{"stream":"Step 8 : ADD ansible /ansible-tmp/\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 2b3220a6a157\n"}
{"stream":"Step 9 : RUN pip install -q --no-cache-dir -e git+https://github.com/ansible/ansible.git@devel#egg=ansible\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 1ef4452829a3\n"}
{"stream":"Step 10 : RUN test '(! -f /ansible-tmp/requirements.txt)' || pip install --no-cache-dir -r /ansible-tmp/requirements.txt\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e b2177d3d2a2b\n"}
{"stream":"Step 11 : RUN rm -rf /ansible-tmp/\n"}
{"stream":" ---\u003e Using cache\n"}
{"stream":" ---\u003e 4e8f6481e17d\n"}
{"stream":"Successfully built 4e8f6481e17d\n"}
Ansible Container image has ID sha256:4e8f6481e17d352c13054fd0a7547c48f9e99a837cf6b4746411e7ba9e287f45
Using temporary directory /tmp/tmp8onRD2...
Starting Docker Compose engine to build your images...
Using temporary directory /tmp/tmpjOZgym...
Compose derived from config:
{'gulp': {'image': 'centos:7', 'links': ['django'], 'command': '/bin/false', 'user': 'node'}, 'postgresql': {'image': 'centos:7', 'command': ['/usr/bin/dumb-init', 'postgres', '-h', '0.0.0.0', '-D', '/var/lib/pgsql/data'], 'ports': ['5432'], 'volumes': ['/var/lib/pgsql'], 'user': 'postgres'}, 'static': {'command': ['/usr/bin/dumb-init', 'nginx', '-c', '/etc/nginx/nginx.conf'], 'links': ['django'], 'image': 'centos:7', 'ports': ['80:8080'], 'user': 'nginx'}, 'django': {'working_dir': '/django', 'command': ['/usr/bin/dumb-init', '/venv/bin/gunicorn', '-w', '2', '-b', '0.0.0.0:8080', 'example.wsgi:application'], 'links': ['postgresql'], 'image': 'centos:7', 'ports': ['8080'], 'user': 'django'}}
{'gulp': {'command': 'sh -c "while true; do sleep 1; done"', 'user': 'node', 'links': ['django'], 'image': 'centos:7'}, 'postgresql': {'command': 'sh -c "while true; do sleep 1; done"', 'user': 'postgres', 'volumes': ['/var/lib/pgsql'], 'image': 'centos:7', 'ports': ['5432']}, 'static': {'command': 'sh -c "while true; do sleep 1; done"', 'links': ['django'], 'image': 'centos:7', 'ports': ['80:8080'], 'user': 'nginx'}, 'django': {'working_dir': '/django', 'command': 'sh -c "while true; do sleep 1; done"', 'links': ['postgresql'], 'image': 'centos:7', 'ports': ['8080'], 'user': 'django'}}
Config YAML is
django:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [postgresql]
ports: ['8080']
user: django
working_dir: /django
gulp:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [django]
user: node
postgresql:
command: sh -c "while true; do sleep 1; done"
image: centos:7
ports: ['5432']
user: postgres
volumes: [/var/lib/pgsql]
static:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [django]
ports: ['80:8080']
user: nginx
Rendered Jinja Template:
ansible-container:
image: "sha256:4e8f6481e17d352c13054fd0a7547c48f9e99a837cf6b4746411e7ba9e287f45"
command: ansible-playbook -i /etc/ansible/inventory/hosts -c docker --list-hosts main.yml
environment:
- DOCKER_HOST
- DOCKER_TLS_VERIFY
- DOCKER_CERT_PATH=/docker-certs/
- COMPOSE_HTTP_TIMEOUT=3000
volumes:
- $DOCKER_CERT_PATH:/docker-certs/
- /home/ubuntu/ansible-container/example:/ansible-container/
working_dir: /ansible-container/ansible/
stdin_open: true
tty: true
django:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [postgresql]
ports: ['8080']
user: django
working_dir: /django
gulp:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [django]
user: node
postgresql:
command: sh -c "while true; do sleep 1; done"
image: centos:7
ports: ['5432']
user: postgres
volumes: [/var/lib/pgsql]
static:
command: sh -c "while true; do sleep 1; done"
image: centos:7
links: [django]
ports: ['80:8080']
user: nginx
The DOCKER_CERT_PATH variable is not set. Defaulting to a blank string.
ERROR: for ansible-container create .: volume name invalid: "." includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed
Attaching to
Cleaning up Ansible Container builder...
Cleaning up temporary directory /tmp/tmpjOZgym...
Cleaning up temporary directory /tmp/tmp8onRD2...
No container with the name ansible-container
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/cli.py", line 178, in commandline
**vars(args))
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/engine.py", line 244, in cmdrun_build
touched_hosts = engine_obj.hosts_touched_by_playbook()
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 56, in hosts_touched_by_playbook
builder_container_id = self.get_builder_container_id()
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 172, in get_builder_container_id
return self.get_container_id_by_name(self.builder_container_img_name)
File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/docker/engine.py", line 132, in get_container_id_by_name
raise NameError('No container with the name %s' % name)
NameError: No container with the name ansible-container