convcert tags dict tags list?

For some reason, the ec2_asg module does not handle tags the same way as other modules.

Most modules let you do this:

tags:
fred: wilma
barney: betty

In the ec2_asg module, that results in an error message about not being able to convert a dict to a list.

In the ec2_asg module, I have to do something like this:

tags: [{fred: wilma}, {barney:betty}]

How can I do this automatically? How can I convert the former type to a variable I can use with ec2_asg?

Regards, k.

I figured it out. Given a set of tags in a dict as per usual, this generates a variable all_tags which is a list of tags:

  • set_fact:
    tag_list:

  • set_fact:
    tag_list: “{{ tag_list + [ {item.key: item.value} ] }}”
    with_dict: “{{ all_tags }}”

The “tags” attribute in the ec2_asg module accepts all_tags and the ASG is then correctly tagged.

I think this is a bug in ec2_asg. It should work the same as other modules.

Regards, K.