ansible-container icon indicating copy to clipboard operation
ansible-container copied to clipboard

import from Dockerfile does not handle multiline ADD correctly

Open dchsueh opened this issue 7 years ago • 2 comments

ISSUE TYPE
  • Bug Report
container.yml

not applicable

OS / ENVIRONMENT
$ ansible-container --debug version
Ansible Container, version 0.9.3rc0
Linux, ubuntu, 4.4.0-101-generic, #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017, x86_64
2.7.12 (default, Nov 20 2017, 18:23:56) 
[GCC 5.4.0 20160609] /home/ubuntu/ansible-container/bin/python2

using virtualenv, ansible-container installed from github repo checkout from 2017-12-13 also confirmed with current pip-installed ansible-container version (0.9.2?)

SUMMARY

importing a docker context dir with Dockerfile containing multiline ADD command, e.g.

FROM centos:7

RUN yum update -y \
  && yum install -y wget unzip \
  && yum clean all

results in a <currentdir>/roles/<docker-context-dir>/tasks/main.yml containing:

- shell: yum update -y
- shell: '&& yum install -y wget unzip'
- shell: '&& yum clean all'
STEPS TO REPRODUCE

as per summary above

EXPECTED RESULTS

a correct shell task, either concatenated into one line, or a single multiline shell task

ACTUAL RESULTS

resulting .../roles/.../tasks/main.yml shown in summary above the import will succeed but the yml needs editing in order to run

dchsueh avatar Dec 14 '17 16:12 dchsueh

Interesting - never seen:

/bin/foo \
&& /bin/bar

Is this, in your experience, a common pattern? We've always seen:

/bin/foo && \
/bin/bar

j00bar avatar Jan 25 '18 11:01 j00bar

I don't think there is any pattern or requirement that individual run commands be on a line, or the && token be at the beginning or at the end. For example, see https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run "Below is a well-formed RUN instruction..." where the first cmd is part of the first line, the second command starts on the first line and runs for another n-2, and the last command is on its own line with && in front.

The backslashed-newline just means "not done yet". For ansible-container import, maybe everything can just be dumped into one shell call with backslash-newline removed and everything concatenated.

dchsueh avatar Jan 26 '18 19:01 dchsueh