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

Lock ruamel.yaml version to [0.15.34; 0.15.51]. Fixes #958 #959

Closed tzok closed 6 years ago

tzok commented 6 years ago
ISSUE TYPE
SUMMARY

Versions of ruamel.yaml >=0.15.52 cause ansible-container build to fail with 'CommentedMap' is not JSON serializable error. See issue #958

To reproduce the issue:

$ virtualenv venv
$ source venv/bin/activate
$ git clone https://github.com/ansible/ansible-container.git
$ pip install -e ansible-container
$ ansible-container init
$ ansible-container build

Before the change:

$ ansible-container build
ERROR   The container.yml file is invalid: ordereddict([('version', '2'), ('settings', ordereddict([('conductor', ordereddict([('base', 'centos:7')])), ('project_name', 'tmp.sKmOGhyCo7')])), ('services', ordereddict()), ('registries', ordereddict())]) is not of type 'object' 
Building Docker Engine context...   
Starting Docker build of Ansible Container Conductor image (please be patient)...   
ERROR   Unknown exception   
Traceback (most recent call last):
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/cli.py", line 302, in __call__
    getattr(core, u'hostcmd_{}'.format(args.subcommand))(**vars(args))
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/core.py", line 204, in hostcmd_build
    'build', dict(config), base_path, kwargs, save_container=save_container)
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/docker/engine.py", line 468, in await_conductor_command
    conductor_id = self.run_conductor(command, config, base_path, params)
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/docker/engine.py", line 107, in __wrapped__
    return fn(self, *args, **kwargs)
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/__init__.py", line 28, in __wrapped__
    return fn(*args, **kwargs)
  File "/tmp/tmp.sKmOGhyCo7/ansible-container/container/docker/engine.py", line 422, in run_conductor
    serialized_config = base64.b64encode(json.dumps(ordereddict_to_list(config)).encode("utf-8")).decode()
  File "/usr/lib64/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'CommentedMap' is not JSON serializable

After the change: (i.e. change git clone to tzok/ansible-container)

$ ansible-container build
Building Docker Engine context...   
Starting Docker build of Ansible Container Conductor image (please be patient)...   
Parsing conductor CLI args.
Copying build context into Conductor container.
Docker™ daemon integration engine loaded. Build starting.   project=tmp.HWGEm38Ly1
All images successfully built.
Conductor terminated. Cleaning up.  command_rc=0 conductor_id=4f6a7596886ba7adb75c8f8ea4dc67de4b7204e534c161c70fa9607550321eea save_container=False
linkebon commented 6 years ago

Until new version of ansible-container is released we fixed this by adding the same line to ansible-requirements.txt

ruamel.yaml>=0.15.34,<=0.15.51

Voronenko commented 6 years ago

@linkebon I recommend trying to reach one of 3 maintainers : https://pypi.org/project/ansible-container/

@j00bar seems busy at a moment. Not sure about @ryansb Only they can release new version on a pypi.