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

Error to 'run' ansible-container #912

Open Ilmn-Ybi opened 6 years ago

Ilmn-Ybi commented 6 years ago
ISSUE TYPE
container.yml
version: "2"
settings:

  conductor:
    # The Conductor container does the heavy lifting, and provides a portable
    # Python runtime for building your target containers. It should be derived
    # from the same distribution as you're building your target containers with.
    base: centos:7
    # roles_path:   # Specify a local path containing Ansible roles
    # volumes:      # Provide a list of volumes to mount
    # environment:  # List or mapping of environment variables

  # Set the name of the project. Defaults to basename of the project directory.
  # For built services, concatenated with service name to form the built image name.
  project_name: MyTest

  # The deployment_output_path is mounted to the Conductor container, and the 
  # `run` and `deployment` commands then write generated Ansible playbooks to it.
  # deployment_output_path: ./ansible-deployment

  # When using the k8s or openshift engines, use the following to authorize with the API.
  # Values set here will be passed to the Ansible modules. Any file paths will be mounted
  # to the conductor container, allowing the `run` command to access the API.
  #k8s_auth:
    # path to a K8s config file
    #config_file:
    # name of a context found within the config file
    #context:
    # URL for accessing the K8s API
    #host:
    # An API authentication token
    #api_key:
    # Path to a ca cert file
    #ssl_ca_cert:
    # Path to a cert file
    #cert_file:
    # Path to a key file
    #key_file:
    # boolean, indicating if SSL certs should be validated
    #verify_ssl:

  # When using the k8s or openshift engines, use the following to set the namespace.
  # If not set, the project name will be used. For openshift, the namespace maps to a project,
  # and description and display_name are supported.
  #k8s_namespace:
  #  name:
  #  description:
  #  display_name:

services: {}
  # Add your containers here, specifying the base image you want to build from.
  # To use this example, uncomment it and delete the curly braces after services key.
  # You may need to run `docker pull ubuntu:trusty` for this to work.

  web:
     from: "centos:7"
     ports:
       - "80:80"
     command: ["/usr/bin/dumb-init", "/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
     dev_overrides:
       environment:
         - "DEBUG=1"
registries: {}
  # Add optional registries used for deployment. For example:
  #  google:
  #    url: https://gcr.io
  #    namespace: my-cool-project-xxxxxx   
OS / ENVIRONMENT
Ansible Container, version 0.9.3rc0
Linux, f24-ll-02, 3.10.0-693.5.2.el7.x86_64, #1 SMP Fri Oct 20 20:32:50 UTC 2017, x86_64
2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] /usr/bin/python2
{
  "ContainersPaused": 0, 
  "Labels": null, 
  "CgroupDriver": "systemd", 
  "ClusterAdvertise": "", 
  "ContainersRunning": 0, 
  "ContainerdCommit": {
    "Expected": "aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1", 
    "ID": ""
  }, 
  "InitBinary": "docker-init", 
  "NGoroutines": 24, 
  "Swarm": {
    "Managers": 0, 
    "ControlAvailable": false, 
    "NodeID": "", 
    "Cluster": {
      "Spec": {
        "TaskDefaults": {}, 
        "Orchestration": {}, 
        "EncryptionConfig": {
          "AutoLockManagers": false
        }, 
        "Raft": {
          "HeartbeatTick": 0, 
          "ElectionTick": 0
        }, 
        "CAConfig": {}, 
        "Dispatcher": {}
      }, 
      "Version": {}, 
      "ID": "", 
      "CreatedAt": "0001-01-01T00:00:00Z", 
      "UpdatedAt": "0001-01-01T00:00:00Z"
    }, 
    "Nodes": 0, 
    "Error": "", 
    "RemoteManagers": null, 
    "LocalNodeState": "inactive", 
    "NodeAddr": ""
  }, 
  "LoggingDriver": "journald", 
  "OSType": "linux", 
  "HttpProxy": "http://contractorproxywest.northgrum.com:80", 
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }, 
    "docker-runc": {
      "path": "/usr/libexec/docker/docker-runc-current"
    }
  }, 
  "DriverStatus": [
    [
      "Backing Filesystem", 
      "xfs"
    ], 
    [
      "Supports d_type", 
      "true"
    ], 
    [
      "Native Overlay Diff", 
      "true"
    ]
  ], 
  "OperatingSystem": "CentOS Linux 7 (Core)", 
  "Containers": 9, 
  "HttpsProxy": "http://contractorproxywest.northgrum.com:80", 
  "BridgeNfIp6tables": true, 
  "MemTotal": 33225084928, 
  "SecurityOptions": [
    "name=seccomp,profile=/etc/docker/seccomp.json"
  ], 
  "Driver": "overlay2", 
  "IndexServerAddress": "https://index.docker.io/v1/", 
  "ClusterStore": "", 
  "InitCommit": {
    "Expected": "949e6facb77383876aeff8a6944dde66b3089574", 
    "ID": "N/A"
  }, 
  "Isolation": "", 
  "Registries": [
    {
      "Name": "docker.io", 
      "Secure": true
    }
  ], 
  "SystemStatus": null, 
  "OomKillDisable": true, 
  "PkgVersion": "<unknown>", 
  "SystemTime": "2018-04-04T10:52:42.699078762-07:00", 
  "Name": "f24-ll-02", 
  "CPUSet": true, 
  "RegistryConfig": {
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ], 
    "IndexConfigs": {
      "docker.io": {
        "Official": true, 
        "Name": "docker.io", 
        "Secure": true, 
        "Mirrors": null
      }
    }, 
    "Mirrors": []
  }, 
  "DefaultRuntime": "docker-runc", 
  "ContainersStopped": 9, 
  "NCPU": 8, 
  "NFd": 16, 
  "Architecture": "x86_64", 
  "KernelMemory": true, 
  "CpuCfsQuota": true, 
  "Debug": false, 
  "IndexServerName": "docker.io", 
  "ID": "7B3C:NDQN:S373:KEUV:7SHB:B2F4:4EH2:62OE:QOVA:SGTR:WI7T:DUVP", 
  "IPv4Forwarding": true, 
  "KernelVersion": "3.10.0-693.5.2.el7.x86_64", 
  "BridgeNfIptables": true, 
  "NoProxy": "localhost,127.0.0.1", 
  "LiveRestoreEnabled": false, 
  "ServerVersion": "1.13.1", 
  "CpuCfsPeriod": true, 
  "ExperimentalBuild": false, 
  "MemoryLimit": true, 
  "SwapLimit": true, 
  "Plugins": {
    "Volume": [
      "local"
    ], 
    "Network": [
      "bridge", 
      "host", 
      "macvlan", 
      "null", 
      "overlay"
    ], 
    "Authorization": null
  }, 
  "Images": 15, 
  "DockerRootDir": "/var/lib/docker", 
  "NEventsListener": 0, 
  "CPUShares": true, 
  "RuncCommit": {
    "Expected": "9df8b306d01f59d3a8029be411de015b7304dd8f", 
    "ID": "N/A"
  }
}
{
  "KernelVersion": "3.10.0-693.5.2.el7.x86_64", 
  "PkgVersion": "<unknown>", 
  "Arch": "amd64", 
  "BuildTime": "2018-03-07T17:06:16.441560971+00:00", 
  "ApiVersion": "1.26", 
  "Version": "1.13.1", 
  "MinAPIVersion": "1.12", 
  "GitCommit": "774336d/1.13.1", 
  "Os": "linux", 
  "GoVersion": "go1.8.3"
}
SUMMARY

The container.xml file was original (downloaded from github). Ansible-container init and build fine. It can be urn with the 'web' section commented (i.e. no web service). When 'web' section was uncommented, 'ansible-container run' threw errors

STEPS TO REPRODUCE
ansible-container build
ansible-container run (or ansible-container --debug run)
EXPECTED RESULTS

Run without error(s)

ACTUAL RESULTS
issues/709 Got error. I read through existing related reports, but didn't see clear solution or fix.
[root@f24-ll-02 MyTest]# ansible-container --debug run
2018-04-04T09:41:53.093348 Got extra args to `run` command [container.core] arguments={'with_volumes': [], 'vault_password_file': None, 'service': [], 'with_variables': [], 'selinux': True, 'subcommand': 'run', 'devel': False, 'roles_path': [], 'volume_driver': None, 'production': False, 'debug': True, 'detached': False, 'vault_files': []} caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/core.py caller_func=hostcmd_run caller_line=242
2018-04-04T09:41:53.141310 The default type is            [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_resolve_defaults caller_line=255 config=<class 'ruamel.yaml.comments.CommentedMap'> defaults=<type '_ordereddict.ordereddict'>
2018-04-04T09:41:53.141894 Getting environment variables... [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_get_environment_variables caller_line=271
2018-04-04T09:41:53.142519 Read environment variables     [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_get_environment_variables caller_line=276 env_vars={}
2018-04-04T09:41:53.143135 Resolved template variables    [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_resolve_defaults caller_line=260 template_vars={}
2018-04-04T09:41:53.143650 Parsed config                  [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=set_env caller_line=196 config={"version": "2", "settings": {"conductor": {"base": "centos:7"}, "project_name": "MyTest", "pwd": "/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest"}, "services": {"web": {"from": "centos:7", "ports": ["80:80"], "command": ["/usr/bin/dumb-init", "/usr/sbin/apache2ctl", "-D", "FOREGROUND"]}}, "registries": {}, "defaults": {}}
2018-04-04T09:41:53.189911 The default type is            [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_resolve_defaults caller_line=255 config=<class 'ruamel.yaml.comments.CommentedMap'> defaults=<type '_ordereddict.ordereddict'>
2018-04-04T09:41:53.190492 Getting environment variables... [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_get_environment_variables caller_line=271
2018-04-04T09:41:53.191050 Read environment variables     [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_get_environment_variables caller_line=276 env_vars={}
2018-04-04T09:41:53.191562 Resolved template variables    [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=_resolve_defaults caller_line=260 template_vars={}
2018-04-04T09:41:53.192082 Parsed config                  [container.config] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/config.py caller_func=set_env caller_line=196 config={"version": "2", "settings": {"conductor": {"base": "centos:7"}, "project_name": "MyTest", "pwd": "/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest"}, "services": {"web": {"from": "centos:7", "ports": ["80:80"], "command": ["/usr/bin/dumb-init", "/usr/sbin/apache2ctl", "-D", "FOREGROUND"], "environment": ["DEBUG=1"]}}, "registries": {}, "defaults": {}}
2018-04-04T09:41:53.192602 hostcmd_run configuration      [container.core] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/core.py caller_func=hostcmd_run caller_line=254 config={'_config': ordereddict([('version', '2'), ('settings', ordereddict([('conductor', ordereddict([('base', 'centos:7'), ('environment', {})])), ('project_name', 'MyTest'), ('pwd', '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest')])), ('services', ordereddict([('web', ordereddict([('from', 'centos:7'), ('ports', ['80:80']), ('command', ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND']), ('environment', ['DEBUG=1'])]))])), ('registries', ordereddict([])), ('defaults', ordereddict([]))]), 'config_path': '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/container.yml', 'engine_name': 'docker', 'base_path': '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest', 'cli_vault_files': None, 'remove_engines': set(['k8s', 'openshift']), 'cli_vars_files': [], 'cli_project_name': None}
2018-04-04T09:41:53.193329 Loading engine capabilities    [container.utils.loader] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/utils/loader.py caller_func=load_engine caller_line=14 capabilities=['RUN'] engine=docker
2018-04-04T09:41:53.272987 Setting Docker client timeout to 60 [container.docker.engine] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/docker/engine.py caller_func=get_timeout caller_line=124
2018-04-04T09:41:53.300337 Could not find container for MyTest_conductor [container.docker.engine] all_containers=[u'mytest_web_1', u'apacheweb1', u'serene_hawking', u'festive_jennings', u'confident_wiles', u'heuristic_fermi', u'thirsty_khorana', u'test_instance', u'dreamy_rosalind'] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/docker/engine.py caller_func=get_container_id_by_name caller_line=570
2018-04-04T09:41:53.302347 Params passed to conductor for run [container.core] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/core.py caller_func=hostcmd_run caller_line=271 params={'selinux': True, 'subcommand': 'run', 'devel': False, 'debug': True, 'volume_driver': None, 'roles_path': [], 'with_volumes': [], 'vault_password_file': None, 'settings': ordereddict([('conductor', ordereddict([('base', 'centos:7'), ('environment', {})])), ('project_name', 'MyTest'), ('pwd', '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest')]), 'with_variables': [], 'deployment_output_path': '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment', 'production': False, 'host_user_uid': 0, 'host_user_gid': 0, 'detached': False, 'vault_files': []}
2018-04-04T09:41:53.303116 Call: Engine.run_conductor     [container.docker.engine] args=('run', {'services': ordereddict([('web', ordereddict([('from', 'centos:7'), ('ports', ['80:80']), ('command', ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND']), ('environment', ['DEBUG=1'])]))]), 'version': '2', 'registries': ordereddict([]), 'defaults': ordereddict([]), 'settings': ordereddict([('conductor', ordereddict([('base', 'centos:7'), ('environment', {})])), ('project_name', 'MyTest'), ('pwd', '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest')])}, '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest', {'selinux': True, 'subcommand': 'run', 'devel': False, 'debug': True, 'volume_driver': None, 'roles_path': [], 'with_volumes': [], 'vault_password_file': None, 'settings': ordereddict([('conductor', ordereddict([('base', 'centos:7'), ('environment', {})])), ('project_name', 'MyTest'), ('pwd', '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest')]), 'with_variables': [], 'deployment_output_path': '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment', 'production': False, 'host_user_uid': 0, 'host_user_gid': 0, 'detached': False, 'vault_files': []}) caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/docker/engine.py caller_func=Engine.run_conductor caller_line=23 kwargs={}
2018-04-04T09:41:53.307707 Docker run:                    [container.docker.engine] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/docker/engine.py caller_func=run_conductor caller_line=449 image=u'sha256:9ae5a6db3a1bce8648c56794b78ed1a7554ed83ed7fe6dc63d695e82a5a3c415' params={'name': u'MyTest_conductor', 'cap_add': ['SYS_ADMIN'], 'environment': {'DOCKER_HOST': 'unix:///var/run/docker.sock', 'ANSIBLE_ROLES_PATH': '/src/roles:/etc/ansible/roles'}, 'working_dir': '/src', 'command': ['conductor', 'run', '--project-name', 'MyTest', '--engine', 'docker', '--params', u'eyJzZWxpbnV4IjogdHJ1ZSwgInN1YmNvbW1hbmQiOiAicnVuIiwgImRldmVsIjogZmFsc2UsICJkZWJ1ZyI6IHRydWUsICJ2b2x1bWVfZHJpdmVyIjogbnVsbCwgInJvbGVzX3BhdGgiOiBbXSwgIndpdGhfdm9sdW1lcyI6IFtdLCAidmF1bHRfcGFzc3dvcmRfZmlsZSI6IG51bGwsICJzZXR0aW5ncyI6IHsiY29uZHVjdG9yIjogeyJiYXNlIjogImNlbnRvczo3IiwgImVudmlyb25tZW50Ijoge319LCAicHJvamVjdF9uYW1lIjogIk15VGVzdCIsICJwd2QiOiAiL2hvbWUvNGozNjMwMS9EZXNrdG9wL0RvY2tlclRlc3QvQW5zaWJsZV9jb250YWluZXJfdGVzdC9NeVRlc3QifSwgIndpdGhfdmFyaWFibGVzIjogW10sICJkZXBsb3ltZW50X291dHB1dF9wYXRoIjogIi9ob21lLzRqMzYzMDEvRGVza3RvcC9Eb2NrZXJUZXN0L0Fuc2libGVfY29udGFpbmVyX3Rlc3QvTXlUZXN0L2Fuc2libGUtZGVwbG95bWVudCIsICJwcm9kdWN0aW9uIjogZmFsc2UsICJob3N0X3VzZXJfdWlkIjogMCwgImhvc3RfdXNlcl9naWQiOiAwLCAiZGV0YWNoZWQiOiBmYWxzZSwgInZhdWx0X2ZpbGVzIjogW119', '--config', u'eyJzZXJ2aWNlcyI6IFtbIndlYiIsIHsiZnJvbSI6ICJjZW50b3M6NyIsICJwb3J0cyI6IFsiODA6ODAiXSwgImNvbW1hbmQiOiBbIi91c3IvYmluL2R1bWItaW5pdCIsICIvdXNyL3NiaW4vYXBhY2hlMmN0bCIsICItRCIsICJGT1JFR1JPVU5EIl0sICJlbnZpcm9ubWVudCI6IFsiREVCVUc9MSJdfV1dLCAic2V0dGluZ3MiOiBbWyJjb25kdWN0b3IiLCB7ImJhc2UiOiAiY2VudG9zOjciLCAiZW52aXJvbm1lbnQiOiB7fX1dLCBbInByb2plY3RfbmFtZSIsICJNeVRlc3QiXSwgWyJwd2QiLCAiL2hvbWUvNGozNjMwMS9EZXNrdG9wL0RvY2tlclRlc3QvQW5zaWJsZV9jb250YWluZXJfdGVzdC9NeVRlc3QiXV0sICJ2ZXJzaW9uIjogIjIiLCAiZGVmYXVsdHMiOiBbXSwgInJlZ2lzdHJpZXMiOiBbXX0=', '--encoding', 'b64json'], 'user': 'root', 'volumes': {'MyTest_secrets': {'bind': '/docker/secrets', 'mode': 'rw'}, '/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}, '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest': {'bind': '/_src', 'mode': 'ro'}, '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment': {'bind': '/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment', 'mode': 'rw'}}, 'detach': True, 'privileged': True}
Parsing conductor CLI args.
2018-04-04T16:42:12.303770 Copying build context into Conductor container. [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=401
2018-04-04T16:42:12.312095 sending incremental file list
 [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.314181 ./
                            [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.315855 .dockerignore
                 [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.317308 ansible-requirements.txt
      [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.318630 ansible.cfg
                   [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.320476 container.yml
                 [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.321662 container.yml_bak
             [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.322819 meta.yml
                      [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.323968 requirements.yml
              [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.361135
                              [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.362655 sent 7250 bytes  received 148 bytes  14796.00 bytes/sec
 [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.363985 total size is 6785  speedup is 0.92
 [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=405
2018-04-04T16:42:12.366974 Processing defaults section... [container.config] caller_file=/_ansible/container/config.py caller_func=_process_defaults caller_line=387
2018-04-04T16:42:12.368432 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=396 section=volumes
2018-04-04T16:42:12.370028 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=396 section=registries
2018-04-04T16:42:12.371612 Processing section...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_top_level_sections caller_line=396 section=secrets
2018-04-04T16:42:12.373203 Processing service...          [container.config] caller_file=/_ansible/container/config.py caller_func=_process_services caller_line=402 service=u'web' service_data={u'environment': [u'DEBUG=1'], u'command': [u'/usr/bin/dumb-init', u'/usr/sbin/apache2ctl', u'-D', u'FOREGROUND'], u'from': u'centos:7', u'ports': [u'80:80']}
2018-04-04T16:42:12.375074 Rendering service keys from defaults [container.config] caller_file=/_ansible/container/config.py caller_func=_process_services caller_line=426 defaults={} service=u'web'
2018-04-04T16:42:12.380086 Starting Ansible Container Conductor: run [container.cli] caller_file=/_ansible/container/cli.py caller_func=conductor_commandline caller_line=415 services={"web": {"environment": ["DEBUG=1"], "command": ["/usr/bin/dumb-init", "/usr/sbin/apache2ctl", "-D", "FOREGROUND"], "from": "centos:7", "ports": ["80:80"], "defaults": {}}}
2018-04-04T16:42:12.383129 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-04-04T16:42:12.447854 Engine integration loaded. Preparing run. [container.core] caller_file=/_ansible/container/core.py caller_func=conductorcmd_run caller_line=933 engine=u'Docker\u2122 daemon'
2018-04-04T16:42:12.454343 Setting Docker client timeout to 60 [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=get_timeout caller_line=124
2018-04-04T16:42:12.459770 Adding new service to definition [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=820 definition={'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']} service=u'web'
2018-04-04T16:42:12.483807 Found image for service        [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=875 id=u'sha256:2d194b392d' tags=[u'docker.io/centos:7', u'docker.io/centos:latest']
2018-04-04T16:42:12.485723 Adding task to destroy image   [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=877 tag=u'docker.io/centos:7'
2018-04-04T16:42:12.487368 Adding task to destroy image   [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=877 tag=u'docker.io/centos:latest'
2018-04-04T16:42:12.495629 Found image for service        [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=875 id=u'sha256:9ae5a6db3a' tags=[u'mytest-conductor:latest']
2018-04-04T16:42:12.497519 Adding task to destroy image   [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=877 tag=u'mytest-conductor:latest'
2018-04-04T16:42:12.499306 Created playbook to run project [container.docker.engine] caller_file=/_ansible/container/docker/engine.py caller_func=generate_orchestration_playbook caller_line=890 playbook=[ordereddict([(u'name', 'Deploy MyTest'), (u'hosts', u'localhost'), (u'gather_facts', False), (u'tasks', [{u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest'}, u'tags': ['start']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest', u'restarted': True}, u'tags': ['restart']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest', u'stopped': True}, u'tags': ['stop']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'absent', u'project_name': 'MyTest', u'remove_volumes': u'yes'}, u'tags': ['destroy']}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'docker.io/centos:7'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'docker.io/centos:latest'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'mytest-conductor:latest'}, u'tags': u'destroy'}])])]
2018-04-04T16:42:12.501906 writing playbook to /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/tmpRt5kBd.yml [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=573
2018-04-04T16:42:12.503452 playbook                       [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=574 playbook=[ordereddict([(u'name', 'Deploy MyTest'), (u'hosts', u'localhost'), (u'gather_facts', False), (u'tasks', [{u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest'}, u'tags': ['start']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest', u'restarted': True}, u'tags': ['restart']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'present', u'project_name': 'MyTest', u'stopped': True}, u'tags': ['stop']}, {u'docker_service': {u'definition': {u'services': {u'web': {'environment': ['DEBUG=1'], u'image': u'docker.io/centos:7', 'command': ['/usr/bin/dumb-init', '/usr/sbin/apache2ctl', '-D', 'FOREGROUND'], 'ports': ['80:80']}}, u'version': u'2'}, u'state': u'absent', u'project_name': 'MyTest', u'remove_volumes': u'yes'}, u'tags': ['destroy']}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'docker.io/centos:7'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'docker.io/centos:latest'}, u'tags': u'destroy'}, {u'docker_image': {u'state': u'absent', u'force': u'yes', u'name': u'mytest-conductor:latest'}, u'tags': u'destroy'}])])]
2018-04-04T16:42:12.516713 Running Ansible Playbook       [container.core] caller_file=/_ansible/container/core.py caller_func=run_playbook caller_line=631 command=ansible-playbook -vvvv  --tags=start  -i /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/hosts-_QOAjv  -c local /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/tmpRt5kBd.yml  cwd=/src
ansible-playbook 2.4.3.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/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /src/ansible.cfg as config file
setting up inventory plugins
Parsed /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/hosts-_QOAjv inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc
PLAYBOOK: tmpRt5kBd.yml ********************************************************
1 plays in /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/tmpRt5kBd.yml
PLAY [Deploy MyTest] ***********************************************************
META: ran handlers
TASK [docker_service] **********************************************************
task path: /home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/tmpRt5kBd.yml:5
Using module file /usr/lib/python2.7/site-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-1522860133.46-249563444814122 `" && echo ansible-tmp-1522860133.46-249563444814122="` echo /root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpDQQ0Cm TO /root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122/docker_service.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122/ /root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122/docker_service.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122/docker_service.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1522860133.46-249563444814122/" > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_TPKhs8/ansible_module_docker_service.py", line 746, in cmd_up
    timeout=self.timeout)
  File "/usr/lib/python2.7/site-packages/compose/project.py", line 499, in up
    'Encountered errors while bringing up the project.'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "errors": [],
    "invocation": {
        "module_args": {
            "api_version": null,
            "build": false,
            "cacert_path": null,
            "cert_path": null,
            "debug": false,
            "definition": {
                "services": {
                    "web": {
                        "command": [
                            "/usr/bin/dumb-init",
                            "/usr/sbin/apache2ctl",
                            "-D",
                            "FOREGROUND"
                        ],
                        "environment": [
                            "DEBUG=1"
                        ],
                        "image": "docker.io/centos:7",
                        "ports": [
                            "80:80"
                        ]
                    }
                },
                "version": "2"
            },
            "dependencies": true,
            "docker_host": null,
            "files": null,
            "filter_logger": false,
            "hostname_check": false,
            "key_path": null,
            "nocache": false,
            "project_name": "MyTest",
            "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
        }
    },
    "module_stderr": "Starting mytest_web_1 ... \r\n\r\u001b[1B",
    "module_stdout": "",
    "msg": "Error starting project unknown cause"
}
    to retry, use: --limit @/home/4j36301/Desktop/DockerTest/Ansible_container_test/MyTest/ansible-deployment/tmpRt5kBd.retry
PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1
Traceback (most recent call last):
  File "/usr/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 423, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 943, 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.
2018-04-04T09:42:14.716686 Conductor terminated. Cleaning up. [container.docker.engine] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/docker/engine.py caller_func=await_conductor_command caller_line=476 command_rc=1 conductor_id=u'c2c49040115255086c3189b7b214d24d42f7476de37e936a6aedc191db36aa7e' save_container=False
2018-04-04T09:42:15.073571 Conductor exited with status 1 [container.cli] caller_file=/home/4j36301/Desktop/DockerTest/Ansible_container_test/ansible-container/container/cli.py caller_func=__call__ caller_line=314
Ilmn-Ybi commented 6 years ago

Correction - there are no brackets ('{}') after 'Services', I copied from an incorrect copy of .yml file.

services: {}

Ilmn-Ybi commented 6 years ago

For those who may want to know, it turned out that I need to set up 'dumb-init' to kill the error.

jochenparm commented 6 years ago

Hey @Ilmn-Ybi , could you explain what you mean by "I need to set up 'dumb-init' to kill the error" What exactly did you do to kill the error? I'm experiencing the same issue and it's blocking me on my project

Voronenko commented 6 years ago

@Ilmn-Ybi Is issue resolved now? Do you have objections for this issue to be closed?

jochenparm commented 6 years ago

@Voronenko If you think the issue is resolved, could you explain what the resolution is? I have the same issue and it's not resolved for me yet @Ilmn-Ybi isn't answering my question.

Voronenko commented 6 years ago

@jochenparm In this specific case, I understand that there were no dumb-init installed inside container. For your scenario issue might be different

jochenparm commented 6 years ago

Okay, can you explain to me why I need to install a dumb-init in my container to use Ansible Container with it if it wasn't necessary to do this when using a dockerfile? And if it is needed for compatibility with Ansible Container, is this documented somewhere?

Voronenko commented 6 years ago

It is not linked to ansible-container, but about unix systems in general (most often used base image in docker )

https://docs.docker.com/v17.09/engine/reference/run/#specify-an-init-process

Quoting some article:

Why valid init for containers is important

Although people say, that proper docker microservice should run single dedicated process, it is not always achievable in real world. More correct to say, that Docker suggests the philosophy of running a single logical service per container. A logical service can consist of multiple OS processes. Sometimes you really need to run more than one service in a docker container. This is especially true, if you are adapting some application that previously was running in standalone vps environment.

Why init process is important: running processes can be visualized are ordered in a tree: each process can spawn child processes, and each process has a parent except for the top-most process. This top-most process is the init process. It is started when you start your container and always has PID 1. This init process is responsible for starting the rest of the system, including starting your application. When some process terminates, it turns into smth referred as “defunct process”, also known as a “zombie process” (https://en.wikipedia.org/wiki/Zombie_process). In simple words, these are ones that are terminated but have not (yet) been waited for by their parent processes.

But what if parent process terminates (intentionally, or unintentionally)? What happens then to its spawned processes? They no longer have a parent process, so they become “orphaned” (https://en.wikipedia.org/wiki/Orphan_process).

And this is where the init process kicks in. It becomes new parent (adopts) orphaned child processes, even though they were never created directly by the init process. The operating system kernel automatically handles adoption. Moreover: the operating system expects the init process to reap adopted children too.

What if not? As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes in the host system itself. Also, init system implemented wrong often leads to incorrect handling of processes and signals, and can result in problems such as containers which can’t be gracefully stopped, or leaking containers which should have been destroyed.

More reading on a topic:

Upstart, Systemd, SysV usually are too heavy (overkill) to be used inside docker (+ not always easily possible). What are the options ?

Candidates for container init process

At a time of article writing, most often used init approaches were:

Custom written init script

as per docker documentation, https://docs.docker.com/engine/admin/multi-service_container/ Take a look on a Proof-of-concept example of such script below

Will work, but really does not guarantee reaping… Let’s examine more robust alternatives.

Dumb-init

dumb-init is a simple process supervisor and init system designed to run as PID 1 inside minimal container environments (such as Docker). It is deployed as a small, statically-linked binary written in C.

dumb-init enables you to simply prefix your command with dumb-init. It acts as PID 1 and immediately spawns your command as a child process, taking care to properly handle and forward signals as they are received.

Project repo: https://github.com/Yelp/dumb-init

Tini

Tini advertises itself as a tiny but valid init for containers. Promises:

Shipped as precompiled binary for hugh variety of platforms.

Project repo: https://github.com/krallin/tini

Runit

Runit is a cross-platform Unix init scheme with service supervision, a replacement for sysvinit, and other init schemes. It runs on GNU/Linux, BSD, can easily be adapted to other Unix operating systems. The program runit is intended to run as Unix process no 1, it is automatically started by the runit-init /sbin/init-replacement if this is started by the kernel.

Project website: http://smarden.org/runit/

S6

S6 is project, actually sibling of the RUnit by http://skarnet.org/software/s6/overview.html. S6 contains collection of utilities revolving around process supervision and management, logging, and system initialization. More over, specifically for a docker exists helper project, so-called “s6-overlay” https://github.com/just-containers/s6-overlay

S6 provides:

My_Init

Part of the Phusion baseimage project https://github.com/phusion/baseimage-docker, which currently targets Ubuntu 16:04, Ubuntu 14:04 OS-es. Consists of custom written py file and wrapped optional runit.

Provides

Requires: python inside your container. In present form limited to Ubuntu base system only.

Supervisord ?

This is known process manager usually used with python applications. I often saw people trying to use it as init system. But: supervisor explicitly mentions that it is not meant to be run as your init process. If you have some subprocess fork itself off, it won’t be cleaned up by Supervisor. Thus you anyway would need to choose different init system.

Good if you anyway used it with your application earlier.

Candidates for running multiple services inside container.

From mentioned above and at the same time lightweight, worse to mention:

SupervisorD

Classic supervisor which does not even require root privileges. Ctl script that acts similar to systemd’s systemctl. Supports processes restarting, as well as event handlers based on shell protocols.

RUnit

Runit ships with swiss-knife set of utilities, one of them is runsvdir (http://smarden.org/runit/runsvdir.8.html) It allows defining set of "service definitions" in some directory, and makes care on launching them at startup.

Typical interaction examples:

/usr/bin/sv status /etc/service/ - get status of services listed in configuration folder

/usr/bin/sv -w 10 down /etc/service/* - shutdown all services with timeout 10

S6 (in scope of S6-overlay project)

Unlike supervisor, s6 uses a folder structure to control services, similar to RUnit. S6-overlay requires them under /etc/services.d before running init (it then copies them over to /var/run/s6/services).

Now, each of those run files is an executable that s6 executes to start the process.

Services are controlled by s6-svc binary. It has number of options, but the main idea is that you give it the directory of the service. So for example, if I wanted to send SIGHUP to nginx, I would do s6-svc -h /var/run/s6/services/nginx. Note: that it’s /var/run and not /etc/services.d; This is hugh difference from RUnit. And lastly, the -h is for SIGHUP.

s6-overlay comes with a number of built versions, so you can download the one that matches your Linux setup. If you want to use s6 directly, users of Alpine and a few other flavors of Linux can just install it from their package manager. We’re running Debian and there’s no PPA for it, so we would have to compile s6 on our own