ansible / ansible-builder

An Ansible execution environment builder
Other
292 stars 97 forks source link

ansible builder fails when using dict for galaxy requirements. #568

Closed sean-m-sullivan closed 1 year ago

sean-m-sullivan commented 1 year ago

When using the following definition in a execution_requirements file

dependencies:
  galaxy:
  - name: awx.awx
    version: 21.9.0
  - infra.controller_configuration
  - infra.ah_configuration

Builder will fail with

  jsonschema.exceptions.ValidationError: {'name': 'awx.awx', 'version': '21.9.0'} is not of type 'string'

Failed validating 'type' in schema[2]['items']:
    {'type': 'string'}

On instance[0]:
    {'name': 'awx.awx', 'version': '21.9.0'}

During handling of the above exception, another exception occurred:

ansible_builder.exceptions.DefinitionError: {'name': 'awx.awx', 'version': '21.9.0'} is not of type 'string'

I tried to fix this on my own, but was unable to, I believe its in here, and should allow a list of dicts. file: https://github.com/sean-m-sullivan/ansible-builder/blob/5efe17fbb5c71e1b6dde354350963d598e3d57a6/src/ansible_builder/ee_schema.py#L228

Also this is based on the following galaxy documentation: https://docs.ansible.com/ansible/devel/collections_guide/collections_installing.html#install-multiple-collections-with-a-requirements-file specifically You can specify the following keys for each collection entry: name version signatures source type

kurokobo commented 1 year ago

I think the list should be under collections (or roles):

dependencies:
  galaxy:
    collections:   👈👈👈
      - name: awx.awx
        version: 21.9.0
      - infra.controller_configuration
      - infra.ah_configuration
sean-m-sullivan commented 1 year ago

@kurokobo Nope, additional properties are not allowed. Full error:

jsonschema.exceptions.ValidationError: Additional properties are not allowed ('collections' was unexpected)

Failed validating 'additionalProperties' in schema['properties']['dependencies']:
    {'additionalProperties': False,
     'description': 'The dependency stuff',
     'properties': {'ansible_core': {'additionalProperties': False,
                                     'description': 'Ansible package '
                                                    'installation',
                                     'oneOf': [{'required': ['package_pip']}],
                                     'properties': {'package_pip': {'description': 'Ansible '
                                                                                   'package '
                                                                                   'to '
                                                                                   'install '
                                                                                   'via '
                                                                                   'pip',
                                                                    'type': 'string'}},
                                     'type': 'object'},
                    'ansible_runner': {'additionalProperties': False,
                                       'description': 'Ansible Runner '
                                                      'package '
                                                      'installation',
                                       'oneOf': [{'required': ['package_pip']}],
                                       'properties': {'package_pip': {'description': 'Ansible '
                                                                                     'Runner '
                                                                                     'package '
                                                                                     'to '
                                                                                     'install '
                                                                                     'via '
                                                                                     'pip',
                                                                      'type': 'string'}},
                                       'type': 'object'},
                    'galaxy': {'anyOf': [{'type': 'object'},
                                         {'type': 'string'},
                                         {'items': {'type': 'string'},
                                          'type': 'array'}]},
                    'python': {'anyOf': [{'type': 'string'},
                                         {'items': {'type': 'string'},
                                          'type': 'array'}]},
                    'python_interpreter': {'additionalProperties': False,
                                           'description': 'Python package '
                                                          'name and path',
                                           'properties': {'package_system': {'description': 'The '
                                                                                            'python '
                                                                                            'package '
                                                                                            'to '
                                                                                            'install '
                                                                                            'via '
                                                                                            'system '
                                                                                            'package '
                                                                                            'manager',
                                                                             'type': 'string'},
                                                          'python_path': {'description': 'Path '
                                                                                         'to '
                                                                                         'the '
                                                                                         'python '
                                                                                         'interpreter',
                                                                          'type': 'string'}},
                                           'type': 'object'},
                    'system': {'anyOf': [{'type': 'string'},
                                         {'items': {'type': 'string'},
                                          'type': 'array'}]}},
     'type': 'object'}

On instance['dependencies']:
    {'collections': [{'name': 'awx.awx', 'version': '21.9.0'},
                     'infra.controller_configuration',
                     'infra.ah_configuration'],
     'galaxy': None,
     'python': ['pytz', 'python-dateutil>=2.7.0', 'awxkit'],
     'system': ['python38-requests [platform:centos-8 platform:rhel-8]',
                'python38-pyyaml [platform:centos-8 platform:rhel-8]']}

During handling of the above exception, another exception occurred:

ansible_builder.exceptions.DefinitionError: Additional properties are not allowed ('collections' was unexpected)
kurokobo commented 1 year ago

@sean-m-sullivan Seems you've specified dependencies.collections but my comment is about dependencies.galaxy.collections.

Try appending collections under galaxy.

sean-m-sullivan commented 1 year ago

Sorry, I didn't notice my indent error when i was testing the change, this worked, closing, Thanks!