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

AttributeError: 'tuple' object has no attribute 'id' #953

Closed 375gnu closed 5 years ago

375gnu commented 6 years ago
ISSUE TYPE
container.yml
version: "2"
settings:
  conductor:
    base: "alpine:3.5"
  project_name: test
services:
  web:
    from: "alpine:3.5"
    ports:
    - "80:80"
    command: ["/usr/bin/dumb-init", "/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
registries: {}
OS / ENVIRONMENT
{
  "ContainersPaused": 0, 
  "Labels": null, 
  "CgroupDriver": "cgroupfs", 
  "ContainersRunning": 1, 
  "ContainerdCommit": {
    "Expected": "06b9cb35161009dcb7123345749fef02f7cea8e0", 
    "ID": "06b9cb35161009dcb7123345749fef02f7cea8e0"
  }, 
  "InitBinary": "docker-init", 
  "NGoroutines": 50, 
  "Swarm": {
    "ControlAvailable": false, 
    "NodeID": "", 
    "Error": "", 
    "RemoteManagers": null, 
    "LocalNodeState": "inactive", 
    "NodeAddr": ""
  }, 
  "LoggingDriver": "json-file", 
  "OSType": "linux", 
  "HttpProxy": "", 
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  },
  "DriverStatus": [
    [
      "Root Dir", 
      "/var/lib/docker/aufs"
    ], 
    [
      "Backing Filesystem", 
      "extfs"
    ], 
    [
      "Dirs", 
      "90"
    ], 
    [
      "Dirperm1 Supported", 
      "true"
    ]
  ], 
  "OperatingSystem": "Devuan GNU/Linux ascii", 
  "Containers": 7, 
  "HttpsProxy": "", 
  "BridgeNfIp6tables": true, 
  "MemTotal": 16740159488, 
  "SecurityOptions": [
    "name=seccomp,profile=default"
  ], 
  "Driver": "aufs", 
  "IndexServerAddress": "https://index.docker.io/v1/", 
  "ClusterStore": "", 
  "InitCommit": {
    "Expected": "949e6fa", 
    "ID": "949e6fa"
  }, 
  "GenericResources": null, 
  "Isolation": "", 
  "SystemStatus": null, 
  "OomKillDisable": true, 
  "ClusterAdvertise": "", 
  "SystemTime": "2018-07-20T17:03:30.532042158+03:00", 
  "Name": "epbyminw3458", 
  "CPUSet": true, 
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [], 
    "Mirrors": [], 
    "IndexConfigs": {
      "192.168.100.3:5000": {
        "Official": false, 
        "Name": "192.168.100.3:5000", 
        "Secure": false, 
        "Mirrors": []
      }, 
      "docker.io": {
        "Official": true, 
        "Name": "docker.io", 
        "Secure": true, 
        "Mirrors": []
      }
    }, 
    "AllowNondistributableArtifactsHostnames": [], 
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  }, 
  "DefaultRuntime": "runc", 
  "ContainersStopped": 6, 
  "NCPU": 4, 
  "NFd": 34, 
  "Architecture": "x86_64", 
  "KernelMemory": true, 
  "CpuCfsQuota": true, 
  "Debug": false, 
  "ID": "GT5Z:5A7A:AMZ6:AONF:GIAP:Y25D:WQYZ:ZLM2:P6SS:OPNV:TQXJ:T6R6", 
  "IPv4Forwarding": true, 
  "KernelVersion": "4.9.0-7-amd64", 
  "BridgeNfIptables": true, 
  "NoProxy": "", 
  "LiveRestoreEnabled": false, 
  "ServerVersion": "17.09.1-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": 78, 
  "DockerRootDir": "/var/lib/docker", 
  "NEventsListener": 0, 
  "CPUShares": true, 
  "RuncCommit": {
    "Expected": "3f2f8b84a77f73d38244dd690525642a72156c64", 
    "ID": "3f2f8b84a77f73d38244dd690525642a72156c64"
  }
}
{
  "KernelVersion": "4.9.0-7-amd64", 
  "Arch": "amd64", 
  "BuildTime": "2017-12-07T22:22:56.000000000+00:00", 
  "ApiVersion": "1.32", 
  "Version": "17.09.1-ce", 
  "MinAPIVersion": "1.12", 
  "GitCommit": "19e2cf6", 
  "Os": "linux", 
  "GoVersion": "go1.8.3"
}
SUMMARY

ansible-container build fails with the error:

ERROR   Unknown exception   
Traceback (most recent call last):
  File ".../venv/local/lib/python2.7/site-packages/container/cli.py", line 299, in __call__
    getattr(core, u'hostcmd_{}'.format(args.subcommand))(**vars(args))
  File ".../venv/local/lib/python2.7/site-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File ".../venv/local/lib/python2.7/site-packages/container/core.py", line 181, in hostcmd_build
    environment=env_vars
  File ".../venv/local/lib/python2.7/site-packages/container/docker/engine.py", line 105, in __wrapped__
    return fn(self, *args, **kwargs)
  File ".../venv/local/lib/python2.7/site-packages/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File ".../venv/local/lib/python2.7/site-packages/container/docker/engine.py", line 1071, in build_conductor_image
    return image.id
AttributeError: 'tuple' object has no attribute 'id'
STEPS TO REPRODUCE

install ansible-container using official guide but downgrading pip to 9.0.3

ansible-container init
vim containers.yml
ansible-container build

I added print image before return image.id, it shows:

(<Image: 'test-conductor:latest'>, <itertools.tee object at 0x7f9a03b22e18>)
EXPECTED RESULTS
ACTUAL RESULTS

see above

ansible-container --debug build works fine though

375gnu commented 6 years ago

I've replaced return image.id with return self.get_image_id_by_tag(tag) used in debug mode and now build finishes succesfuly.

Voronenko commented 6 years ago

@375gnu Alternatively you can pin docker to 2.7.0 at a moment

sebastienbonami commented 5 years ago

Same problem here. Using Docker 2.7.0 works, but this version is dated from 1 year ago and it's been 5 months @Voronenko suggested this workaround.

Is this project under active development or what?

Voronenko commented 5 years ago

Docker version unpinned in scope of https://github.com/ansible/ansible-container/pull/977