When using the docker plugin, if multiple platforms are specified with the same network, the create and destroy playbooks loop through the same network multiple times, trying to create / delete the docker network. This doesn't cause any major problem, as the create / delete network operation is idempotent, but it's inefficient, especially when there are lots of platforms in the same molecule scenario, all sharing the same network.
A minimal example of the molecule.yml to produce this is below:
When molecule create is run with the above, it gives the following output (other output removed for clarity) - note that it calls the "create_network.yml" twice:
When using the docker plugin, if multiple platforms are specified with the same network, the create and destroy playbooks loop through the same network multiple times, trying to create / delete the docker network. This doesn't cause any major problem, as the create / delete network operation is idempotent, but it's inefficient, especially when there are lots of platforms in the same molecule scenario, all sharing the same network.
A minimal example of the molecule.yml to produce this is below:
When
molecule create
is run with the above, it gives the following output (other output removed for clarity) - note that it calls the "create_network.yml" twice:This could be easily solved by adding a
unique
filter to thewith_items
statements increate.yml
anddestroy.yml
playbooks - i.e. in https://github.com/ansible-community/molecule-plugins/blob/main/src/molecule_plugins/docker/playbooks/create.yml#L90 , change:to
and in https://github.com/ansible-community/molecule-plugins/blob/main/src/molecule_plugins/docker/playbooks/destroy.yml#L49 , change
to
Happy to submit a PR for this if helpful?