ansible-community / molecule-docker

🚧 Assimilated into molecule-plugins
https://github.com/ansible-community/molecule-plugins
MIT License
77 stars 39 forks source link

delete_network.yml conditional always returns false #96

Closed cursedclock closed 3 years ago

cursedclock commented 3 years ago

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:

- 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:


Steps to reproduce the issue