allow_duplicates does not appear to be working in my use case

Hello,

See https://github.com/ansible/ansible/issues/8559 for additional details, but in brief I have 3 roles:

roles/apache2/meta/main.yml:


allow_duplicates: yes

roles/apache2-php/meta/main.yml:


allow_duplicates: yes
dependencies:

  • { role: apache2 }

roles/apache2-ssl/meta/main.yml:


allow_duplicates: yes

dependencies:

  • { role: apache2-php, when: include_php == True }
  • { role: apache2, when: include_php == False }

I would like to be able to use the apache2-ssl role in a playbook and have it recursively call the apache2-php and apache2 dependent roles. This works for the most part, except with handlers in the base apache2 role. Even with allow_duplicates: yes everywhere, when I call the apache2-ssl role with include_php == False, the “reload apache” handler still gets skipped:

excerpt from roles/apache2/tasks/main.yml:

  • name: copy apache configuration (12.04)
    template: src=000-default.j2 dest=/etc/apache2/sites-enabled/000-default
    when: ansible_distribution_version == “12.04”
    notify: reload apache2

excerpt from roles/apache2/handlers/main.yml:

  • name: reload apache2
    service: name=apache2 state=reloaded enabled=true

The handler is NOTIFIED, but skipped:

NOTIFIED: [apache2 | reload apache2] ******************************************
skipping: [apachetest]

I think this occurs because the first dependent role, apache2-php, is skipped because include_php is False. It then recusively marks all tasks and handlers in apache2-php and apache2 as skipped, and then when it goes to apache2 a second time (when it hits the second dependent role), it is already marked as skipped and so the handler doesn’t execute. Any ideas on what is going on here, and how to fix it?

Thanks!

So the first thing I notice is this ticket was filed on 1.6.2.

The current released version of Ansible is 1.7.0, have you checked on the latest?

Not saying this is not a thing, but would save us time and we’d appreciate the updated report.

Thanks!

I tried this test again after upgrading to 1.7 and the behavior is the same: the task is listed as changed and the handler as NOTIFIED, but it is skipped

Ok, good deal, thanks for checking on the latest - can you please file a github ticket on this one?

Thanks!

Filed here, thanks!
https://github.com/ansible/ansible/issues/8684