Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WARNING]: TASK: ... "The loop variable 'item' is already in use." is displayed when calling the role from another role #216

Closed
berndfinger opened this issue Dec 7, 2023 · 0 comments · Fixed by #217

Comments

@berndfinger
Copy link
Contributor

When calling the selinux role from another role and looping over variables, as in https://github.com/sap-linuxlab/community.sap_install/blob/5b920752aa818fcd9fe96ce740bffaa314baf99e/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-selinux.yml#L108 (the task is looping over the list sap_general_preconfigure_sap_directories, which is assigned to the selinux variable selinux_restore_dirs), messages like the following are displayed:

[WARNING]: TASK: fedora.linux_system_roles.selinux : Restore SELinux labels on filesystem tree: The loop variable 'item' is already in use.
You should set the `loop_var` value in the `loop_control` option for the task to something else to avoid variable collisions and unexpected behavior.

As indicated in the warning message, we can avoid this message by replacing item in the selinux role with something else, e.g. line_item, and also adding:

  loop_control:
    loop_var: line_item

to the affected tasks.

berndfinger added a commit to berndfinger/selinux that referenced this issue Dec 7, 2023
By using a different loop variable, we can avoid WARNING messages
related to loop variables when calling the selinux role from another
role.

Fixes: linux-system-roles#216

Signed-off-by: Bernd Finger <bfinger@redhat.com>
berndfinger added a commit to berndfinger/selinux that referenced this issue Dec 7, 2023
Relates to linux-system-roles#216 .

Signed-off-by: Bernd Finger <bfinger@redhat.com>
@richm richm closed this as completed in #217 Dec 8, 2023
richm pushed a commit that referenced this issue Dec 8, 2023
By using a different loop variable, we can avoid WARNING messages
related to loop variables when calling the selinux role from another
role.

Fixes: #216

Signed-off-by: Bernd Finger <bfinger@redhat.com>
richm pushed a commit that referenced this issue Dec 8, 2023
Relates to #216 .

Signed-off-by: Bernd Finger <bfinger@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant