Closed luther7 closed 6 years ago
Bug does not occur when roles_path
is an array like so:
settings:
conductor:
base: alpine:3.5
roles_path:
- roles
deployment_output_path: ./ansible_deployment
vars_files:
- vars.yml
The CLI --roles-path
option returns and array. It appears that config.py
returns an array, and expects conductor.roles_path
to be an array. However, our docs indicate that container.yml
expects contuctor.roles_path
to be a string.
We need to fix the docs, and make it clear that roles_path
is an array.
Also note that if roles_path
is a string, it creates empty directories - one for each character in roles_path
.
Example:
container.yml
version: "2"
settings:
conductor:
base: alpine:3.5
roles_path: roles
deployment_output_path: ./ansible_deployment
vars_files:
- vars.yml
services:
nginx:
from: nginx:1.13.6-alpine
roles:
- nginx_reverse_proxy
command: [nginx, -g, daemon off;]
ports:
- "8080:80"
links:
- php-fpm
php-fpm:
from: php:7.0-fpm-alpine
roles:
- install_packages
- install_php_extensions
- purge_package_cache
- postfix
command: [php-fpm]
volumes:
- api:/srv
dev_overrides:
volumes:
- /home/franz/workspace/php/test:/srv
volumes:
api:
docker:
driver: local
After build results in:
➜ api git:(master) ✗ l
total 72K
drwxr-xr-x 11 franz franz 4.0K Nov 16 16:02 .
drwxr-xr-x 4 franz franz 4.0K Nov 16 11:14 ..
-rw-rw-r-- 1 franz franz 205 Nov 16 15:52 ansible.cfg
drwxr-xr-x 2 franz franz 4.0K Nov 16 15:42 ansible_deployment
-rw-rw-r-- 1 franz franz 129 Nov 9 16:31 ansible-requirements.txt
-rw-rw-r-- 1 franz franz 677 Nov 16 16:02 container.yml
drwxr-xr-x 2 root root 4.0K Nov 16 16:02 e
drwxr-xr-x 8 franz franz 4.0K Nov 16 16:07 .git
-rw-rw-r-- 1 franz franz 5 Nov 14 16:58 .gitignore
drwxr-xr-x 2 root root 4.0K Nov 16 16:02 l
-rw-rw-r-- 1 franz franz 1.2K Nov 9 16:31 meta.yml
drwxr-xr-x 2 root root 4.0K Nov 16 16:02 o
drwxr-xr-x 2 root root 4.0K Nov 16 16:02 r
-rw-rw-r-- 1 franz franz 651 Nov 16 13:49 requirements.yml
drwxrwxr-x 2 franz franz 4.0K Nov 16 16:02 roles
drwxr-xr-x 2 root root 4.0K Nov 16 16:02 s
-rw-rw-r-- 1 franz franz 426 Nov 16 14:17 vars.yml
drwxrwxr-x 7 franz franz 4.0K Nov 14 14:03 venv
The empty directory part can likely be fixed by applying the same sort of fail-but-warn strategy we used in #810
FWIW, I came across what @rubberydub came across today, and it leads to a really unexpected error, until you add --debug and notice that there's one path created per character in the passed-in roles_path string. In hindsight it's kinda funny, but the workaround (until you know the real cause) of having to pass roles-path in for every command execution get annoying real fast. You see a stack trace that ends like this:
... APIError: 400 Client Error: Bad Request ("invalid volume spec "/": invalid volume specification: '/': invalid mount config for type "volume": invalid specification: destination can't be '/'")
..which is triggered because one of the "paths" is a slash character in the real path.
Happens with a container.yml like this:
settings: conductor: roles_path: ../../../ansible/fwd-ubuntu/roles/ ...
On 0.9.2, the fix is just to put the roles_path value into an array.
@rubberydub listen, the roles_path
variable is supposed to be a list
(or tupple
), not a str
.
This means even if you have 1 path to add you do it like so:
version: "2"
settings:
conductor:
base: alpine:3.5
roles_path:
- 'roles'
deployment_output_path: ./ansible_deployment
vars_files:
- vars.yml
And on develop, the content of container.yml is checked against a jsonschema, which would prevent you running where roles_path was a string, not a list.
https://github.com/ansible/ansible-container/blob/2b9bbb9/container/schema.yml#L17-L20
So I'm marking this one fixed. HTH!
ISSUE TYPE
container.yml
OS / ENVIRONMENT
SUMMARY
Conductor
roles_path
option does not work.STEPS TO REPRODUCE
Set the
roles_path
option and attempt to build.EXPECTED RESULTS
Roles to be found at
roles_path
ACTUAL RESULTS
Additionally