The conditional in the delete_network task always evaluates to false causing the removal of docker networks to always be skipped.
Cause
The task for deleting docker networks (residing in src/molecule_docker/playbooks/tasks/delete_network.yml) executes based on a list of conditionals defined in the when option:
- name: Delete docker network(s)
community.docker.docker_network:
name: "{{ item.name }}"
state: "absent"
when:
- docker_netname.exists
- docker_netname.network.Labels.owner is not defined
- docker_netname.network.Labels.owner == 'molecule'
Ansible uses an and operator between the list items to calculate the final conditional value. And because the label "owner" cannot be undefined and set to "molecule" at the same time. Currently this causes the when option to always evaluate to false.
Depending on the desired behaviour this should be changed to either:
check if owner is not defined or set to molecule
check if owner is defined and set to molecule
Steps to reproduce the issue
create docker network under platforms in molecule.yml
Issue description
The conditional in the delete_network task always evaluates to false causing the removal of docker networks to always be skipped.
Cause
The task for deleting docker networks (residing in src/molecule_docker/playbooks/tasks/delete_network.yml) executes based on a list of conditionals defined in the when option:
Ansible uses an and operator between the list items to calculate the final conditional value. And because the label "owner" cannot be undefined and set to "molecule" at the same time. Currently this causes the when option to always evaluate to false. Depending on the desired behaviour this should be changed to either:
Steps to reproduce the issue
create docker network under platforms in molecule.yml
create platform
destroy platform
Expected behaviour
Molecule should delete the network after destroying docker containers. stdout for
molecule destroy
in verbose mode:Actual behaviour
Delete docker network(s) task is skipped. stdout for `molecule destroy' in verbose mode"