ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 392 forks source link

import fails when Dockerfile contains tabs instead of spaces #754

Open hans-d opened 7 years ago

hans-d commented 7 years ago
ISSUE TYPE
container.yml

there's no container.yml yet

# ansible-container --project-path target import ./old
OS / ENVIRONMENT
# ansible-container --debug version
Ansible Container, version 0.9.2
Linux, 94d26d51335e, 4.4.0-96-generic, #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017, x86_64
2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] /usr/bin/python
SUMMARY

Import fails when Dockerfile has tabs between directive and payload. As soon as the tabs are replace with spaces, it works.

STEPS TO REPRODUCE

have a dockerfile like

FROM<tab>ubuntu

in ./old run

# ansible-container --project-path target import ./old
EXPECTED RESULTS

No failures, import producing output

ACTUAL RESULTS
ERROR   Unknown exception
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/container/cli.py", line 299, in __call__
    getattr(core, u'hostcmd_{}'.format(args.subcommand))(**vars(args))
  File "/usr/local/lib/python2.7/dist-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/container/core.py", line 475, in hostcmd_import
    engine_obj.import_project(base_path, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/container/docker/engine.py", line 1096, in import_project
    dfi.run()
  File "/usr/local/lib/python2.7/dist-packages/container/docker/importer.py", line 506, in run
    (list(parser), os.path.join(self.role_path, 'tasks', 'main.yml')),
  File "/usr/local/lib/python2.7/dist-packages/container/docker/importer.py", line 170, in __iter__
    for preparsed in self.preparse_iter():
  File "/usr/local/lib/python2.7/dist-packages/container/docker/importer.py", line 146, in preparse_iter
    directive, payload = line.split(u' ', 1)
ValueError: need more than 1 value to unpack
chouseknecht commented 7 years ago

@hans-d

Thanks for reporting this!

We probably need to tweak the shlex command to handle tabs. I'll take a look.