Description
If I pass an image id along with the platform configuration, I get the following error:
The task includes an option with an undefined variable. The error was: {{ item.image or platform_generated_image_id }}: {{ (ami_info.results[index].images | sort(attribute='creation_date', reverse=True))[0].image_id }}: 'dict object' has no attribute 'images'
The problem seems to be that if I do pass in an image, the lookup play is skipped: https://github.com/ansible-community/molecule-ec2/blob/0.4/molecule_ec2/cookiecutter/%7B%7Bcookiecutter.molecule_directory%7D%7D/%7B%7Bcookiecutter.scenario_name%7D%7D/create.yml#L138-L147
As a result, Ansible hits this line: https://github.com/ansible-community/molecule-ec2/blob/0.4/molecule_ec2/cookiecutter/%7B%7Bcookiecutter.molecule_directory%7D%7D/%7B%7Bcookiecutter.scenario_name%7D%7D/create.yml#L221
platform_image_id: "{{ item.image or platform_generated_image_id }}"
And even though item.image
exists, Ansible still tries to run the line above it: https://github.com/ansible-community/molecule-ec2/blob/0.4/molecule_ec2/cookiecutter/%7B%7Bcookiecutter.molecule_directory%7D%7D/%7B%7Bcookiecutter.scenario_name%7D%7D/create.yml#L220
platform_generated_image_id: "{{ (ami_info.results[index].images | sort(attribute='creation_date', reverse=True))[0].image_id }}"
And that's where the error happens.
If I set platform_image_id to just platform_image_id: "{{ item.image }}"
everything works fine
Activity