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

Task "Remove labels from swarm node" fails when labels are configured outside this role #96

Open
juanluisbaptiste opened this issue May 20, 2021 · 1 comment

Comments

@juanluisbaptiste
Copy link

Hi,

When docker labels are added to nodes of an already provisioned cluster with this role without using the swarm_labels variable in the inventory file, but by for example, adding them manually, the role will fail with the following error:

TASK [atosatto.docker-swarm : Remove labels from swarm node.] ******************
fatal: [swarm_manager_preprod_1]: FAILED! => {"msg": "The conditional check 'item not in swarm_labels' failed. The error was: error while evaluating conditional (item not in swarm_labels): 'swarm_labels' is undefined\n\nThe error appears to be in '/builds/karisma.org.co/pub/ansible/roles/atosatto.docker-swarm/tasks/setup-swarm-labels.yml': line 15, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Remove labels from swarm node.\n  ^ here\n"}

The issue arises because the item variable will be not empty containing the manually added labels, but swarm_labels variable will be empty, as any label has not been configured using that variable, so the when: condition of that task will fail.

This is fixed by also checking that swarm_labels is also defined on that task.

juanluisbaptiste added a commit to juanluisbaptiste/ansible-dockerswarm that referenced this issue May 20, 2021
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.
juanluisbaptiste added a commit to juanluisbaptiste/ansible-dockerswarm that referenced this issue May 20, 2021
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.
juanluisbaptiste added a commit to juanluisbaptiste/ansible-dockerswarm that referenced this issue May 20, 2021
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.
@juanluisbaptiste
Copy link
Author

Sorry for the multiple commits, I had to do some reabsing to have this change in its own branch so it could be commited to a PR containing this single fix.

juanluisbaptiste added a commit to juanluisbaptiste/ansible-dockerswarm that referenced this issue May 20, 2021
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.
juanluisbaptiste added a commit to juanluisbaptiste/ansible-dockerswarm that referenced this issue May 20, 2021
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.
f4bio added a commit to f4bio/ansible-dockerswarm that referenced this issue Feb 14, 2022
when removing labels as they could have been added outside this role,
thus making swarm_labels undefined.

Fixes upstream issue atosatto#96.

Co-authored-by: Juan Luis Baptiste <[email protected]>
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

No branches or pull requests

1 participant