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 394 forks source link

Default 'command' to /bin/bash or something reasonable #704

Open alexppg opened 7 years ago

alexppg commented 7 years ago
ISSUE TYPE
container.yml
version: "2"
settings:
  conductor:
    base: ubuntu:16.04
  project_name: php7-ubuntu

services:
  base:
    from        : ubuntu:16.04
OS / ENVIRONMENT
Ansible Container, version 0.9.2rc0
Linux, notebook, 4.9.0-3-amd64, #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06), x86_64
2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] /usr/bin/python
{
  "ContainersPaused": 0, 
  "Labels": null, 
  "CgroupDriver": "cgroupfs", 
  "ContainersRunning": 0, 
  "ContainerdCommit": {
    "Expected": "cfb82a876ecc11b5ca0977d1733adbe58599088a", 
    "ID": "cfb82a876ecc11b5ca0977d1733adbe58599088a"
  }, 
  "InitBinary": "docker-init", 
  "NGoroutines": 26, 
  "Swarm": {
    "ControlAvailable": false, 
    "NodeID": "", 
    "Error": "", 
    "RemoteManagers": null, 
    "LocalNodeState": "inactive", 
    "NodeAddr": ""
  }, 
  "LoggingDriver": "json-file", 
  "OSType": "linux", 
  "HttpProxy": "", 
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  }, 
  "DriverStatus": [
    [
      "Backing Filesystem", 
      "extfs"
    ], 
    [
      "Supports d_type", 
      "true"
    ], 
    [
      "Native Overlay Diff", 
      "true"
    ]
  ], 
  "OperatingSystem": "Debian GNU/Linux 9 (stretch)", 
  "Containers": 158, 
  "HttpsProxy": "", 
  "BridgeNfIp6tables": true, 
  "MemTotal": 16760045568, 
  "SecurityOptions": [
    "name=seccomp,profile=default"
  ], 
  "Driver": "overlay2", 
  "IndexServerAddress": "https://index.docker.io/v1/", 
  "ClusterStore": "", 
  "InitCommit": {
    "Expected": "949e6fa", 
    "ID": "949e6fa"
  }, 
  "Isolation": "", 
  "SystemStatus": null, 
  "OomKillDisable": true, 
  "ClusterAdvertise": "", 
  "SystemTime": "2017-08-16T15:28:18.609584191+02:00", 
  "Name": "notebook", 
  "CPUSet": true, 
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [], 
    "Mirrors": [], 
    "IndexConfigs": {
      "docker.io": {
        "Official": true, 
        "Name": "docker.io", 
        "Secure": true, 
        "Mirrors": []
      }
    }, 
    "AllowNondistributableArtifactsHostnames": [], 
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  }, 
  "DefaultRuntime": "runc", 
  "ContainersStopped": 158, 
  "NCPU": 8, 
  "NFd": 17, 
  "Architecture": "x86_64", 
  "KernelMemory": true, 
  "CpuCfsQuota": true, 
  "Debug": false, 
  "ID": "YEYW:FXKT:2HOB:S242:BQCA:E3OB:ADSH:CU6E:JUVN:S66Y:MONE:FNUB", 
  "IPv4Forwarding": true, 
  "KernelVersion": "4.9.0-3-amd64", 
  "BridgeNfIptables": true, 
  "NoProxy": "", 
  "LiveRestoreEnabled": false, 
  "ServerVersion": "17.06.0-ce", 
  "CpuCfsPeriod": true, 
  "ExperimentalBuild": false, 
  "MemoryLimit": true, 
  "SwapLimit": false, 
  "Plugins": {
    "Volume": [
      "local"
    ], 
    "Network": [
      "bridge", 
      "host", 
      "macvlan", 
      "null", 
      "overlay"
    ], 
    "Authorization": null, 
    "Log": [
      "awslogs", 
      "fluentd", 
      "gcplogs", 
      "gelf", 
      "journald", 
      "json-file", 
      "logentries", 
      "splunk", 
      "syslog"
    ]
  }, 
  "Images": 12, 
  "DockerRootDir": "/var/lib/docker", 
  "NEventsListener": 0, 
  "CPUShares": true, 
  "RuncCommit": {
    "Expected": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4", 
    "ID": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
  }
}
{
  "KernelVersion": "4.9.0-3-amd64", 
  "Arch": "amd64", 
  "BuildTime": "2017-06-23T21:16:12.825866885+00:00", 
  "ApiVersion": "1.30", 
  "Version": "17.06.0-ce", 
  "MinAPIVersion": "1.12", 
  "GitCommit": "02c1d87", 
  "Os": "linux", 
  "GoVersion": "go1.8.3"
}
SUMMARY

When building an image without a command section, there's no problem. But when trying to start the image, it gives an error.

STEPS TO REPRODUCE

Use the above container.yml (changing the role to whaterver you want), build the image and then execute it with either docker run $image or ansible-container run. It will return:

Parsing conductor CLI args.
Engine integration loaded. Preparing run.   engine=Docker™ daemon
Verifying service image service=base

PLAY [Deploy php7-ubuntu] ******************************************************

TASK [docker_service] **********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "errors": ["ERROR: for 33f4f36089b2_33f4f36089b2_33f4f36089b2_33f4f36089b2_php7ubuntu_base_1  Cannot start service base: oci runtime error: container_linux.go:262: starting container process caused \"exec: \\\"ping\\\": executable file not found in $PATH\"", "ERROR: for base  Cannot start service base: oci runtime error: container_linux.go:262: starting container process caused \"exec: \\\"ping\\\": executable file not found in $PATH\""], "failed": true, "module_stderr": "Recreating 33f4f36089b2_33f4f36089b2_33f4f36089b2_33f4f36089b2_php7ubuntu_base_1 ... \r\n\r\u001b[1B\nERROR: for 33f4f36089b2_33f4f36089b2_33f4f36089b2_33f4f36089b2_php7ubuntu_base_1  Cannot start service base: oci runtime error: container_linux.go:262: starting container process caused \"exec: \\\"ping\\\": executable file not found in $PATH\"\n\nERROR: for base  Cannot start service base: oci runtime error: container_linux.go:262: starting container process caused \"exec: \\\"ping\\\": executable file not found in $PATH\"\n", "module_stdout": "", "msg": "Error starting project ERROR: for base  Cannot start service base: oci runtime error: container_linux.go:262: starting container process caused \"exec: \\\"ping\\\": executable file not found in $PATH\""}
    to retry, use: --limit @/media/.syncthing/php7/tests/ansible-deployment/playbook.retry

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    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 392, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 828, in conductorcmd_run
    'Error executing the run command. Not all containers may be running.'
container.exceptions.AnsibleContainerException: Error executing the run command. Not all containers may be running.
Conductor terminated. Cleaning up.  command_rc=1 conductor_id=b0fe5f042e370e3d38ed8cd0065dd46990e1395ca14fa66d7c37fe1f2776a45e save_container=False
ERROR   Conductor exited with status 1  
EXPECTED RESULTS

It may be a sane default to assume that when a command is not declared, it should point to /bin/bash.

ACTUAL RESULTS

The ones said before.

chouseknecht commented 7 years ago

@alexppg

If we decide to provide a default command value, it seems like we should probably use the value found on the base image, assuming there is one.

alexppg commented 7 years ago

Oh sure, that would make even more sense.

chouseknecht commented 7 years ago

@alexppg

By the way, thank you for pointing this out, and for taking the time to open an issue. We appreciate the feedback.

We'll put this on the list of possibilities after 1.0.0. Also, the container working group meets on IRC in the #ansible-container channel every Monday at 12:00 PM eastern. Please consider joining us, and help shape the future direction of the project.

alexppg commented 7 years ago

No problem, that's the less I could do for your awesome job.

I'll try to pass there, but I do not have that many knowledge to contribute enough.