-
Notifications
You must be signed in to change notification settings - Fork 755
Open
Labels
needs_triageNeeds a first human triage before being processed.Needs a first human triage before being processed.new_contributorThis PR is the first contribution by a new community member.This PR is the first contribution by a new community member.
Description
π Defect Description
When invoking the same role (test) multiple times in an Ansible playbook using the roles: keyword, variables such as components and operation are not passed correctly in the second invocation. This results in undefined errors inside the role.
Example:
- name: Role Testing variable passing
hosts: all
remote_user: root
any_errors_fatal: true
roles:
- role: test
vars:
components: ["rep"]
operation: "start"
- name: Role Testing2 variable passing
hosts: all
remote_user: root
any_errors_fatal: true
roles:
- role: test
vars:
components: ["rep"]
operation: "start"In the second block, components and operation are not accessible inside the test role.
Workaround:
Replacing roles: with include_role: resolves the issue, and variables are passed correctly.
πΌ Justification for Business Impact
- Causes unexpected behavior and runtime errors during playbook execution.
- Breaks modularity and reusability of roles.
- Increases debugging time and complexity for developers.
- Impacts automation reliability in production environments.
π§ͺ Environment Details
- Ansible Version: 9.7.0
- Ansible Core Version: 2.16.8
- Base Image:
docker.io/library/alpine:3.20
β Suggested Action
- Investigate variable scoping behavior in repeated
roles:declarations. - Consider switching to
include_rolefor dynamic variable passing. - Document this behavior in the role usage guidelines to prevent future issues.
Metadata
Metadata
Assignees
Labels
needs_triageNeeds a first human triage before being processed.Needs a first human triage before being processed.new_contributorThis PR is the first contribution by a new community member.This PR is the first contribution by a new community member.
Type
Projects
Status
π Triage