Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong datatype in ecs_taskdefinition.containers #264

Closed
iljau opened this issue Oct 15, 2020 · 4 comments · Fixed by #284
Closed

Wrong datatype in ecs_taskdefinition.containers #264

iljau opened this issue Oct 15, 2020 · 4 comments · Fixed by #284

Comments

@iljau
Copy link

iljau commented Oct 15, 2020

containers=dict(required=False, type='list', elements='str'),

In current version argument_spec is following:
containers=dict(required=False, type='list', elements='str'),

This causes dicts inside container list to be converted to strings.

If we select some example from documentation ...

- name: Create task definition
  community.aws.ecs_taskdefinition:
    family: nginx
    containers:
    - name: nginx
      essential: true
      image: "nginx"
      portMappings:
      - containerPort: 8080
        hostPort:      8080
      cpu: 512
      memory: 1024
    state: present

... then running it causes following exception:

  File "[..]/debug_dir/ansible_collections/community/aws/plugins/modules/ecs_taskdefinition.py", line 353, in main
    for environment in container.get('environment', []):
AttributeError: 'str' object has no attribute 'get'

To get examples (and container section) working, argument spec needs to be changed to following:
containers=dict(required=False, type='list', elements='dict'),

@emuuli
Copy link

emuuli commented Oct 15, 2020

Yes, it seems to be an issue indeed.
The last time I used it was not in the community edition, but the built-in ecs_taskdefinition.py, in which it worked:
https://github.com/ansible/ansible/blob/stable-2.4/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py

As you can see from there the elements were not forced to be converted into any data format. Now the formatting is forced and it seems that they shouldn't be forced to be strings, but rather dicts if any as the reporter suggested.

Is there anything that we're missing here?

@markuman
Copy link
Member

#251

@markuman
Copy link
Member

@markuman
Copy link
Member

Ah no...
the fix is easy...and not related by what I've linked.
element=str is just wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants