Skip to content

Fix "when" in "debug"#423

Open
widhalmt wants to merge 1 commit intomainfrom
fix/debug-with-when
Open

Fix "when" in "debug"#423
widhalmt wants to merge 1 commit intomainfrom
fix/debug-with-when

Conversation

@widhalmt
Copy link
Member

We used when in debug tasks several times. As of now, this is identified as lint. So I took the freedom to move every debug that had a when into a block using the when.

We used `when` in `debug` tasks several times. As of now, this is identified as lint. So I took the freedom to move every `debug` that had a  `when` into a `block` using the `when`.
@widhalmt widhalmt self-assigned this Mar 10, 2026
@afeefghannam89
Copy link
Member

@widhalmt what do you mean with "this is identified as lint." What is the profit of building blocks including only one task?

@widhalmt
Copy link
Member Author

@afeefghannam89 In https://github.com/NETWAYS/ansible-collection-elasticstack/actions/runs/22856820147/job/66299296182?pr=419#step:6:1622 it says, you can't have when in debug tasks anymore.

So no:

- name: Debug task
   debug:
   [...]
   when: [...]

I thought, this might be a nice workaround. Do you see a better option?

@widhalmt
Copy link
Member Author

I just learned, that newer Ansible versions don't have this specific issue anymore. Seems like I built a workaround for an Ansible bug.

@afeefghannam89
Copy link
Member

@widhalmt I opened your link. I did not see such error under the changed files in this PR, e.g roles/beats/tasks/beats-security.yml, roles/elasticsearch/tasks/elasticsearch-security.yml

@widhalmt
Copy link
Member Author

Sorry, the link is broken.
The failing task is this:

- name: Print the kibana certificate renew message
  ansible.builtin.debug:
    msg: |
      Your kibana certificate will expire in {{ kibana_cert_expiration_days }} days.
      Ansible will renew it.
  when: kibana_cert_expiration_days is defined and kibana_cert_expiration_days | int <= kibana_cert_expiration_buffer | int

This is not a linter rule. But a bug in Ansible 2.13.x . I makes when with debug tasks break.

@afeefghannam89
Copy link
Member

anisble-core 2.13.x is since a long time EOL I think we should use uptodate Ansible version like => 2.19. 2.18 will be in the next time EOL. I think, offering support to not uptodate Python or Ansible in the collection will brig too much work for us upon the support of the functionality of this collection

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 this pull request may close these issues.

2 participants