Skip to content

role allow_duplicates behaviour incorrectly described #90

@torched99

Description

@torched99
SUMMARY

allow_duplicates: no for import_role appears to do nothing as there appears to be no way to pass role parameters.

allow_duplicate: no for include_role appears to work for vars: dict passing, and also matches those defined via roles: keyword with vars: dict.

The behaviour between between roles included/imported via the different methods, and ways to pass parameters/vars is not documented, and is not at all clear. parameter passing via play role: keyword or dependencies meta/main.yml entry appear to not match with passing identical via vars: dict.

Below is example play omitting only the meta/main.yml method to pull in role. Assuming role meta/main.yml is empty in this case.

- name: first play
  hosts: bla
  roles:
   # one of these will be actioned
    - { role: role1, testvar: 1 }
    - { role: role1, testvar: 1 }
   # one of these will also be actioned
    - role: role1
      vars:
          testvar: 1
    - role: role1
      vars:
          testvar: 1
   tasks:
    # both of these will be actioned
     - name: import role role1, testvar=1
       include_role:
          name: role1
          allow_duplicates: no
       vars:
           testvar: 1
     - name: import role role1, testvar=1, again
       include_role:
          name: role1
          allow_duplicates: no
       vars:
           testvar: 1
     # none of these will be actioned (due to roles section matching)
     - name: include role role1, testvar=1
       include_role:
           name: role1
           allow_duplicates: no
       vars:
           testvar: 1
     - name: include role role1, testvar=1, again
       include_role:
           name: role1
           allow_duplicates: no
       vars:
           testvar: 1
ISSUE TYPE
  • Documentation Report
COMPONENT NAME

roles
include_role
import_role
role dependencies

ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT

Oracle Linux 6

ADDITIONAL INFORMATION

Metadata

Metadata

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions