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

Update docs for --with-volumes to differentiate from volumes in container.yml (was: run --with-volumes does not mount the volumes) #860

Open pete-fab opened 6 years ago

pete-fab commented 6 years ago

I am aware of similarity to 524 bug, the difference here is the run command.

ISSUE TYPE
container.yml
version: "2"
settings:
  conductor:
    base: ubuntu:xenial
  project_name: ansible-container_test
services:
  test_service:
    from: ubuntu:xenial
    command: "sleep infinity"
registries: {}
OS / ENVIRONMENT
Ansible Container, version 0.9.2
Linux, I0003233, 4.4.0-109-generic, #132-Ubuntu SMP Tue Jan 9 19:52:39 UTC 2018, x86_64
3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] /home/piotr_faba/Workspace/Python_environments/dbio_docker/bin/python3
{
  "Plugins": {
    "Network": [
      "bridge",
      "host",
      "macvlan",
      "null",
      "overlay"
    ],
    "Authorization": [],
    "Volume": [
      "local"
    ]
  },
  "LoggingDriver": "json-file",
  "Name": "I0003233",
  "Architecture": "x86_64",
  "ExperimentalBuild": false,
  "DefaultRuntime": "runc",
  "LiveRestoreEnabled": false,
  "CPUShares": true,
  "KernelVersion": "4.4.0-109-generic",
  "Labels": null,
  "NFd": 32,
  "ClusterAdvertise": "",
  "ContainersPaused": 0,
  "NCPU": 8,
  "DriverStatus": [
    [
      "Root Dir",
      "/var/lib/docker/aufs"
    ],
    [
      "Backing Filesystem",
      "extfs"
    ],
    [
      "Dirs",
      "121"
    ],
    [
      "Dirperm1 Supported",
      "true"
    ]
  ],
  "ContainerdCommit": {
    "Expected": "9048e5e50717ea4497b757314bad98ea3763c145",
    "ID": "9048e5e50717ea4497b757314bad98ea3763c145"
  },
  "HttpProxy": "",
  "OSType": "linux",
  "RegistryConfig": {
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ],
    "IndexConfigs": {
      "docker.io": {
        "Official": true,
        "Secure": true,
        "Name": "docker.io",
        "Mirrors": []
      }
    },
    "Mirrors": []
  },
  "ServerVersion": "17.05.0-ce",
  "IPv4Forwarding": true,
  "ClusterStore": "",
  "CgroupDriver": "cgroupfs",
  "SystemTime": "2018-01-24T15:33:42.638035898+01:00",
  "SystemStatus": null,
  "NoProxy": "",
  "KernelMemory": true,
  "OomKillDisable": true,
  "NEventsListener": 0,
  "SwapLimit": false,
  "ID": "XI6F:4ZF5:3MQC:6O6H:ICST:BRBS:XBJD:VOZ2:BWWX:TK4L:5IVA:IBGC",
  "OperatingSystem": "Ubuntu 16.04.3 LTS",
  "InitCommit": {
    "Expected": "949e6fa",
    "ID": "949e6fa"
  },
  "DockerRootDir": "/var/lib/docker",
  "InitBinary": "docker-init",
  "ContainersStopped": 12,
  "NGoroutines": 35,
  "BridgeNfIp6tables": true,
  "Images": 70,
  "BridgeNfIptables": true,
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  },
  "CPUSet": true,
  "ContainersRunning": 2,
  "SecurityOptions": [
    "name=apparmor",
    "name=seccomp,profile=default"
  ],
  "Swarm": {
    "ControlAvailable": false,
    "NodeAddr": "",
    "NodeID": "",
    "RemoteManagers": null,
    "Error": "",
    "LocalNodeState": "inactive"
  },
  "CpuCfsPeriod": true,
  "RuncCommit": {
    "Expected": "9c2d8d184e5da67c95d601382adf14862e4f2228",
    "ID": "9c2d8d184e5da67c95d601382adf14862e4f2228"
  },
  "Debug": false,
  "MemoryLimit": true,
  "CpuCfsQuota": true,
  "IndexServerAddress": "https://index.docker.io/v1/",
  "MemTotal": 16703336448,
  "Driver": "aufs",
  "Containers": 14,
  "HttpsProxy": "",
  "Isolation": ""
}
{
  "MinAPIVersion": "1.12",
  "ApiVersion": "1.29",
  "Version": "17.05.0-ce",
  "BuildTime": "2017-05-04T22:10:54.638119411+00:00",
  "Arch": "amd64",
  "GoVersion": "go1.7.5",
  "Os": "linux",
  "KernelVersion": "4.4.0-109-generic",
  "GitCommit": "89658be"
}
SUMMARY

Running container does not mount the volumes defined on the cli using --with-volumes.

STEPS TO REPRODUCE
ansible-container --devel --debug run --with-volumes $(pwd)/test:/mnt/host/test/:rw
EXPECTED RESULTS

In given container I should have /mnt/host/test/ directory available for read a write. This can be verified with $ docker inspect container_name and the mount should be visible in the Mounts section. This works, when running the image with docker that was built with ansible-container, like so:

$ docker run -v $(pwd)/test:/mnt/host/test/:rw -d ansible-abgenesis-abgenesis sleep infinity

ACTUAL RESULTS
2018-01-24T15:31:25.926357 Got extra args to `run` command [container.core] arguments={'subcommand': 'run', 'with_volumes': ['/home/user/Workspace/projects/ansible-container_test/test:/mnt/host/test/:rw'], 'detached': False, 'vault_files': [], 'with_variables': [], 'devel': True, 'roles_path': [], 'production': False, 'service': [], 'debug': True, 'volume_driver': None, 'selinux': True, 'vault_password_file': None} caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/core.py caller_func=hostcmd_run caller_line=238
2018-01-24T15:31:25.932592 The default type is            [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_resolve_defaults caller_line=189 config=<class 'ruamel.yaml.comments.CommentedMap'> defaults=<class 'ruamel.yaml.compat.ordereddict'>
2018-01-24T15:31:25.933218 Getting environment variables... [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_get_environment_variables caller_line=205
2018-01-24T15:31:25.933995 Read environment variables     [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_get_environment_variables caller_line=210 env_vars={}
2018-01-24T15:31:25.934564 Resolved template variables    [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_resolve_defaults caller_line=194 template_vars={}
2018-01-24T15:31:25.935132 Parsed config                  [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=set_env caller_line=148 config={"version": "2", "settings": {"conductor": {"base": "ubuntu:xenial"}, "project_name": "ansible-container_test", "pwd": "/home/user/Workspace/projects/ansible-container_test"}, "services": {"test_service": {"from": "ubuntu:xenial", "command": "sleep infinity"}}, "registries": {}, "defaults": {}}
2018-01-24T15:31:25.939335 The default type is            [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_resolve_defaults caller_line=189 config=<class 'ruamel.yaml.comments.CommentedMap'> defaults=<class 'ruamel.yaml.compat.ordereddict'>
2018-01-24T15:31:25.939852 Getting environment variables... [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_get_environment_variables caller_line=205
2018-01-24T15:31:25.940548 Read environment variables     [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_get_environment_variables caller_line=210 env_vars={}
2018-01-24T15:31:25.941149 Resolved template variables    [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=_resolve_defaults caller_line=194 template_vars={}
2018-01-24T15:31:25.941853 Parsed config                  [container.config] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/config.py caller_func=set_env caller_line=148 config={"version": "2", "settings": {"conductor": {"base": "ubuntu:xenial"}, "project_name": "ansible-container_test", "pwd": "/home/user/Workspace/projects/ansible-container_test"}, "services": {"test_service": {"from": "ubuntu:xenial", "command": "sleep infinity"}}, "registries": {}, "defaults": {}}
2018-01-24T15:31:25.942565 hostcmd_run configuration      [container.core] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/core.py caller_func=hostcmd_run caller_line=243 config={'cli_vault_files': None, 'cli_vars_files': [], '_config': CommentedMap([('version', '2'), ('settings', CommentedMap([('conductor', CommentedMap([('base', 'ubuntu:xenial')])), ('project_name', 'ansible-container_test'), ('pwd', '/home/user/Workspace/projects/ansible-container_test')])), ('services', ordereddict([('test_service', CommentedMap([('from', 'ubuntu:xenial'), ('command', 'sleep infinity')]))])), ('registries', CommentedMap()), ('defaults', ordereddict())]), 'config_path': '/home/user/Workspace/projects/ansible-container_test/container.yml', 'cli_project_name': None, 'base_path': '/home/user/Workspace/projects/ansible-container_test', 'remove_engines': {'openshift', 'k8s'}, 'engine_name': 'docker'}
2018-01-24T15:31:25.943251 Loading engine capabilities    [container.utils.loader] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/utils/loader.py caller_func=load_engine caller_line=14 capabilities=['RUN'] engine=docker
2018-01-24T15:31:25.973177 Setting Docker client timeout to 60 [container.docker.engine] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=get_timeout caller_line=122
2018-01-24T15:31:25.983260 Could not find container for conductor [container.docker.engine] all_containers=[<Container: 3c9e8567b0>] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=get_container_id_for_service caller_line=531 container=ansible-container_test_conductor
2018-01-24T15:31:25.985567 Params passed to conductor for run [container.core] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/core.py caller_func=hostcmd_run caller_line=260 params={'subcommand': 'run', 'vault_files': [], 'host_user_gid': 1000, 'host_user_uid': 1000, 'devel': True, 'production': False, 'debug': True, 'deployment_output_path': '/home/user/Workspace/projects/ansible-container_test/ansible-deployment', 'detached': False, 'vault_password_file': None, 'with_volumes': ['/home/user/Workspace/projects/ansible-container_test/test:/mnt/host/test/:rw'], 'volume_driver': None, 'selinux': True, 'settings': CommentedMap([('conductor', CommentedMap([('base', 'ubuntu:xenial')])), ('project_name', 'ansible-container_test'), ('pwd', '/home/user/Workspace/projects/ansible-container_test')]), 'roles_path': [], 'service': [], 'with_variables': []}
2018-01-24T15:31:25.995666 Call: Engine.run_conductor     [container.docker.engine] args=('run', {'settings': CommentedMap([('conductor', CommentedMap([('base', 'ubuntu:xenial')])), ('project_name', 'ansible-container_test'), ('pwd', '/home/user/Workspace/projects/ansible-container_test')]), 'version': '2', 'services': ordereddict([('test_service', CommentedMap([('from', 'ubuntu:xenial'), ('command', 'sleep infinity')]))]), 'defaults': ordereddict(), 'registries': CommentedMap()}, '/home/user/Workspace/projects/ansible-container_test', {'subcommand': 'run', 'vault_files': [], 'host_user_gid': 1000, 'host_user_uid': 1000, 'devel': True, 'production': False, 'debug': True, 'deployment_output_path': '/home/user/Workspace/projects/ansible-container_test/ansible-deployment', 'detached': False, 'vault_password_file': None, 'with_volumes': ['/home/user/Workspace/projects/ansible-container_test/test:/mnt/host/test/:rw'], 'volume_driver': None, 'selinux': True, 'settings': CommentedMap([('conductor', CommentedMap([('base', 'ubuntu:xenial')])), ('project_name', 'ansible-container_test'), ('pwd', '/home/user/Workspace/projects/ansible-container_test')]), 'roles_path': [], 'service': [], 'with_variables': []}) caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=Engine.run_conductor caller_line=278 kwargs={}
2018-01-24T15:31:26.003436 Binding Ansible Container code at /home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container into conductor container [container.docker.engine] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=run_conductor caller_line=396
2018-01-24T15:31:26.004185 Docker run:                    [container.docker.engine] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=run_conductor caller_line=435 image=sha256:2f28401d70266856e0b303a87bb3a89a1307fa05b4a7cba5ddb785b49a5426ca params={'volumes': {'/home/user/Workspace/projects/ansible-container_test/test': {'bind': '/mnt/host/test/', 'mode': 'rw'}, '/home/user/Workspace/projects/ansible-container_test/ansible-deployment': {'bind': '/home/user/Workspace/projects/ansible-container_test/ansible-deployment', 'mode': 'rw'}, '/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}, '/home/user/Workspace/projects/ansible-container_test': {'bind': '/src', 'mode': 'ro'}, 'ansible-container_test_secrets': {'bind': '/run/secrets', 'mode': 'rw'}, '/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container': {'bind': '/_ansible/container', 'mode': 'rw'}}, 'name': 'ansible-container_test_conductor', 'cap_add': ['SYS_ADMIN'], 'environment': {'DOCKER_HOST': 'unix:///var/run/docker.sock', 'ANSIBLE_ROLES_PATH': '/src/roles:/etc/ansible/roles'}, 'command': ['conductor', 'run', '--project-name', 'ansible-container_test', '--engine', 'docker', '--params', 'eyJzdWJjb21tYW5kIjogInJ1biIsICJ2YXVsdF9maWxlcyI6IFtdLCAiaG9zdF91c2VyX2dpZCI6IDEwMDAsICJob3N0X3VzZXJfdWlkIjogMTAwMCwgImRldmVsIjogdHJ1ZSwgInByb2R1Y3Rpb24iOiBmYWxzZSwgImRlYnVnIjogdHJ1ZSwgImRlcGxveW1lbnRfb3V0cHV0X3BhdGgiOiAiL2hvbWUvcGlvdHJfZmFiYS9Xb3Jrc3BhY2UvcHJvamVjdHMvYW5zaWJsZS1jb250YWluZXJfdGVzdC9hbnNpYmxlLWRlcGxveW1lbnQiLCAiZGV0YWNoZWQiOiBmYWxzZSwgInZhdWx0X3Bhc3N3b3JkX2ZpbGUiOiBudWxsLCAid2l0aF92b2x1bWVzIjogWyIvaG9tZS9waW90cl9mYWJhL1dvcmtzcGFjZS9wcm9qZWN0cy9hbnNpYmxlLWNvbnRhaW5lcl90ZXN0L3Rlc3Q6L21udC9ob3N0L3Rlc3QvOnJ3Il0sICJ2b2x1bWVfZHJpdmVyIjogbnVsbCwgInNlbGludXgiOiB0cnVlLCAic2V0dGluZ3MiOiB7ImNvbmR1Y3RvciI6IHsiYmFzZSI6ICJ1YnVudHU6eGVuaWFsIn0sICJwcm9qZWN0X25hbWUiOiAiYW5zaWJsZS1jb250YWluZXJfdGVzdCIsICJwd2QiOiAiL2hvbWUvcGlvdHJfZmFiYS9Xb3Jrc3BhY2UvcHJvamVjdHMvYW5zaWJsZS1jb250YWluZXJfdGVzdCJ9LCAicm9sZXNfcGF0aCI6IFtdLCAic2VydmljZSI6IFtdLCAid2l0aF92YXJpYWJsZXMiOiBbXX0=', '--config', 'eyJ2ZXJzaW9uIjogIjIiLCAicmVnaXN0cmllcyI6IFtdLCAic2V0dGluZ3MiOiBbWyJjb25kdWN0b3IiLCB7ImJhc2UiOiAidWJ1bnR1OnhlbmlhbCJ9XSwgWyJwcm9qZWN0X25hbWUiLCAiYW5zaWJsZS1jb250YWluZXJfdGVzdCJdLCBbInB3ZCIsICIvaG9tZS9waW90cl9mYWJhL1dvcmtzcGFjZS9wcm9qZWN0cy9hbnNpYmxlLWNvbnRhaW5lcl90ZXN0Il1dLCAic2VydmljZXMiOiBbWyJ0ZXN0X3NlcnZpY2UiLCB7ImZyb20iOiAidWJ1bnR1OnhlbmlhbCIsICJjb21tYW5kIjogInNsZWVwIGluZmluaXR5In1dXSwgImRlZmF1bHRzIjogW119', '--encoding', 'b64json'], 'working_dir': '/src', 'privileged': True, 'user': 'root', 'detach': True}
Parsing conductor CLI args.
2018-01-24T14:31:28.540585 Processing defaults section... [container.config] caller_file=/_ansible/container/config.py caller_func=_process_defaults caller_line=325
2018-01-24T14:31:28.542190 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=334 section=volumes
2018-01-24T14:31:28.543902 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=334 section=registries
2018-01-24T14:31:28.546087 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=334 section=secrets
2018-01-24T14:31:28.550796 Processing service...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_services caller_line=340 service=u'test_service' service_data={u'command': u'sleep infinity', u'from': u'ubuntu:xenial'}
2018-01-24T14:31:28.552728 Rendering service keys from defaults [container.config] caller_file=/_ansible/container/config.py caller_func=_process_services caller_line=363 defaults={} service=u'test_service'
2018-01-24T14:31:28.554568 Starting Ansible Container Conductor: run [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=391 services={"test_service": {"command": "sleep infinity", "from": "ubuntu:xenial", "defaults": {}}}
2018-01-24T14:31:28.556493 Loading engine capabilities    [container.utils.loader] caller_file=/_ansible/container/utils/loader.py caller_func=load_engine caller_line=14 capabilities=['RUN'] engine=docker
2018-01-24T14:31:28.569577 Engine integration loaded. Preparing run. [container.core] caller_file=/_ansible/container/core.py caller_func=conductorcmd_run caller_line=844 engine=u'Docker\u2122 daemon'
2018-01-24T14:31:28.575439 Setting Docker client timeout to 60 [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=get_timeout caller_line=122
2018-01-24T14:31:28.583836 Adding new service to definition [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=760 definition={u'image': u'ubuntu:xenial', 'command': u'sleep infinity'} service=u'test_service'
2018-01-24T14:31:28.604545 Found image for service        [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=815 id=u'sha256:00fd29ccc6' tags=[u'ubuntu:xenial']
2018-01-24T14:31:28.606479 Adding task to destroy image   [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=817 tag=u'ubuntu:xenial'
2018-01-24T14:31:28.628207 Found image for service        [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=815 id=u'sha256:2f28401d70' tags=[u'ansible-container_test-conductor:latest']
2018-01-24T14:31:28.630197 Adding task to destroy image   [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=817 tag=u'ansible-container_test-conductor:latest'
2018-01-24T14:31:28.631913 Created playbook to run project [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=830 playbook=[ordereddict([(u'name', 'Deploy ansible-container_test'), (u'hosts', u'localhost'), (u'gather_facts', False), (u'tasks', [{u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test'}, u'tags': ['start']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test', u'restarted': True}, u'tags': ['restart']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test', u'stopped': True}, u'tags': ['stop']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'absent', u'project_name': 'ansible-container_test', u'remove_volumes': u'yes'}, u'tags': ['destroy']}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'ubuntu:xenial'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'ansible-container_test-conductor:latest'}, u'tags': u'destroy'}])])]
2018-01-24T14:31:28.634121 writing playbook to /home/user/Workspace/projects/ansible-container_test/ansible-deployment/playbook.yml [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=551
2018-01-24T14:31:28.635600 playbook                       [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=552 playbook=[ordereddict([(u'name', 'Deploy ansible-container_test'), (u'hosts', u'localhost'), (u'gather_facts', False), (u'tasks', [{u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test'}, u'tags': ['start']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test', u'restarted': True}, u'tags': ['restart']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'present', u'project_name': 'ansible-container_test', u'stopped': True}, u'tags': ['stop']}, {u'docker_service': {u'definition': {u'services': {u'test_service': {u'image': u'ubuntu:xenial', 'command': u'sleep infinity'}}, u'version': u'2'}, u'state': u'absent', u'project_name': 'ansible-container_test', u'remove_volumes': u'yes'}, u'tags': ['destroy']}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'ubuntu:xenial'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'ansible-container_test-conductor:latest'}, u'tags': u'destroy'}])])]
2018-01-24T14:31:28.658450 Running Ansible Playbook       [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=621 command=ansible-playbook -vvvv  --tags=start  -i /home/user/Workspace/projects/ansible-container_test/ansible-deployment/hosts  -c local /home/user/Workspace/projects/ansible-container_test/ansible-deployment/playbook.yml  cwd=/src
ansible-playbook 2.5.0
  config file = /src/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Using /src/ansible.cfg as config file
setting up inventory plugins
Parsed /home/user/Workspace/projects/ansible-container_test/ansible-deployment/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: playbook.yml *********************************************************
1 plays in /home/user/Workspace/projects/ansible-container_test/ansible-deployment/playbook.yml

PLAY [Deploy ansible-container_test] *******************************************
META: ran handlers

TASK [docker_service] **********************************************************
task path: /home/user/Workspace/projects/ansible-container_test/ansible-deployment/playbook.yml:5
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/docker/docker_service.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398 `" && echo ansible-tmp-1516804289.49-44801792340398="` echo /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpQgG9TN TO /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398/docker_service.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398/ /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398/docker_service.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398/docker_service.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1516804289.49-44801792340398/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "ansible_facts": {
        "test_service": {
            "ansiblecontainertest_test_service_1": {
                "cmd": [
                    "sleep",
                    "infinity"
                ],
                "image": "ubuntu:xenial",
                "labels": {
                    "com.docker.compose.config-hash": "879457918c091adac93b96d3cefa082c53729c57af04bb45d887eba79dc3fb3e",
                    "com.docker.compose.container-number": "1",
                    "com.docker.compose.oneoff": "False",
                    "com.docker.compose.project": "ansiblecontainertest",
                    "com.docker.compose.service": "test_service",
                    "com.docker.compose.version": "1.16.1"
                },
                "networks": {
                    "ansiblecontainertest_default": {
                        "IPAddress": "172.19.0.2",
                        "IPPrefixLen": 16,
                        "aliases": [
                            "66b1149a0da8",
                            "test_service"
                        ],
                        "globalIPv6": "",
                        "globalIPv6PrefixLen": 0,
                        "links": null,
                        "macAddress": "02:42:ac:13:00:02"
                    }
                },
                "state": {
                    "running": true,
                    "status": "running"
                }
            }
        }
    },
    "changed": true,
    "failed": false,
    "invocation": {
        "module_args": {
            "api_version": null,
            "build": false,
            "cacert_path": null,
            "cert_path": null,
            "debug": false,
            "definition": {
                "services": {
                    "test_service": {
                        "command": "sleep infinity",
                        "image": "ubuntu:xenial"
                    }
                },
                "version": "2"
            },
            "dependencies": true,
            "docker_host": null,
            "files": null,
            "filter_logger": false,
            "hostname_check": false,
            "key_path": null,
            "nocache": false,
            "project_name": "ansible-container_test",
            "project_src": null,
            "pull": false,
            "recreate": "smart",
            "remove_images": null,
            "remove_orphans": false,
            "remove_volumes": false,
            "restarted": false,
            "scale": null,
            "services": null,
            "ssl_version": null,
            "state": "present",
            "stopped": false,
            "timeout": 10,
            "tls": null,
            "tls_hostname": null,
            "tls_verify": null
        }
    }
}
META: ran handlers
META: ran handlers

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

2018-01-24T14:31:30.537024 All services running.          [container.core] caller_file=/_ansible/container/core.py caller_func=conductorcmd_run caller_line=856 playbook_rc=0
2018-01-24T15:31:30.886231 Conductor terminated. Cleaning up. [container.docker.engine] caller_file=/home/user/Workspace/Python_environments/test_docker/lib/python3.5/site-packages/container/docker/engine.py caller_func=await_conductor_command caller_line=462 command_rc=0 conductor_id=9ca2ce12f1cf002711266fe6af055c162c41fbfb21c31b1843d1ec539893384a save_container=False
j00bar commented 6 years ago

Howdy!

You're misunderstanding the purpose of --with-volumes, which mounts a local directory into the Conductor container for use during builds. It does not make extra volumes available to your target containers. For that, you'd need to use the volumes: section of the container.yml file.

If this can be made clearer in the documentation somehow, I'm open to suggestions.

Thanks!

pete-fab commented 6 years ago

Hi J00bar.

Thanks for the clarification. I guess for noobs like me, adding a statement that makes this distinction would help. I would place something of the sort in command reference for the --with-volumes option for run:

For mounting volumes in containers themselves, rather than the Conductor, use volumes: section of the container.yml.

Thanks :)

j00bar commented 6 years ago

I'll take it. Thanks!