Add a test for deduplicating dependencies with include_role (#75259)

pull/75277/head
Sloane Hertel 3 years ago committed by GitHub
parent feed68f6f0
commit 1fc1ab89ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,3 +17,13 @@
tasks: tasks:
- name: execute role c which depends on a - name: execute role c which depends on a
import_role: name=c import_role: name=c
- name: play should only show 1 invocation of a, as dependencies in this play are deduped by include_role
hosts: testhost
gather_facts: false
tags: [ 'intasks' ]
tasks:
- name: execute role b which depends on a
include_role: name=b
- name: execute role c which also depends on a
include_role: name=c

@ -5,9 +5,10 @@ set -eux
# test no dupes when dependencies in b and c point to a in roles: # test no dupes when dependencies in b and c point to a in roles:
[ "$(ansible-playbook no_dupes.yml -i ../../inventory --tags inroles "$@" | grep -c '"msg": "A"')" = "1" ] [ "$(ansible-playbook no_dupes.yml -i ../../inventory --tags inroles "$@" | grep -c '"msg": "A"')" = "1" ]
[ "$(ansible-playbook no_dupes.yml -i ../../inventory --tags acrossroles "$@" | grep -c '"msg": "A"')" = "1" ] [ "$(ansible-playbook no_dupes.yml -i ../../inventory --tags acrossroles "$@" | grep -c '"msg": "A"')" = "1" ]
[ "$(ansible-playbook no_dupes.yml -i ../../inventory --tags intasks "$@" | grep -c '"msg": "A"')" = "1" ]
# but still dupe across plays # but still dupe across plays
[ "$(ansible-playbook no_dupes.yml -i ../../inventory "$@" | grep -c '"msg": "A"')" = "2" ] [ "$(ansible-playbook no_dupes.yml -i ../../inventory "$@" | grep -c '"msg": "A"')" = "3" ]
# include/import can execute another instance of role # include/import can execute another instance of role
[ "$(ansible-playbook allowed_dupes.yml -i ../../inventory --tags importrole "$@" | grep -c '"msg": "A"')" = "2" ] [ "$(ansible-playbook allowed_dupes.yml -i ../../inventory --tags importrole "$@" | grep -c '"msg": "A"')" = "2" ]

Loading…
Cancel
Save