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

[Bug] beats_metricbeat_package newline character issue #357

Open
cbeaujoin-stellar opened this issue Jan 17, 2025 · 3 comments · May be fixed by #358
Open

[Bug] beats_metricbeat_package newline character issue #357

cbeaujoin-stellar opened this issue Jan 17, 2025 · 3 comments · May be fixed by #358
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cbeaujoin-stellar
Copy link

cbeaujoin-stellar commented Jan 17, 2025

Please try to fill out as much of the information below as you can. Thank you!

Yes, I've searched similar issues on GitHub and didn't find any.

Which version contains the bug?
Current

Describe the bug

beats_metricbeat_package is being constructed with a newline character at the end (\n), which is causing a JSON parsing error. in the Install Metricbeat - * tasks.

This is happening because of the > YAML folded scalar operator used in the set_fact task.

We can manage it with the YAML scalar operator by using >- instead of >.
The minus sign tells YAML to strip the trailing newline.

- name: Construct exact name of Metricbeat package
  ansible.builtin.set_fact:
    beats_metricbeat_package: >-
      {{
      'metricbeat' +
      (elasticstack_versionseparator +
      elasticstack_version |
      string if elasticstack_version is defined else '') |
      replace(' ', '')
      }}

How to recreate the bug?

ansible_os_family == "Debian"
ansible_distribution_major_version: '12'
elasticstack_release: 7
elasticstack_version: 7.17.23
elasticstack_variant: 'oss'
@cbeaujoin-stellar cbeaujoin-stellar changed the title beats_metricbeat_package newline character issue [Bug] beats_metricbeat_package newline character issue Jan 17, 2025
@widhalmt
Copy link
Member

Great find! I'll look into it and I'll see if there's something similar elsewhere in the code. Then I'll try to provide a fix.

@widhalmt widhalmt added the bug Something isn't working label Jan 20, 2025
@widhalmt widhalmt added this to the 0.1.0 milestone Jan 20, 2025
@widhalmt widhalmt self-assigned this Jan 20, 2025
@widhalmt
Copy link
Member

I can't reproduce the error. Ok, I tried it with Ubuntu 24.04 but Metricbeat installed without problems with the options you've given.

Because it's a simple fix, I'll provide a PR but we have to test a bit more before we can merge it.

widhalmt added a commit that referenced this issue Jan 22, 2025
* Use '>-' instead of '>' for YAML multline when creating package names.

The extra newline at the end of the string can cause JSON parsing errors as reported by @cbeaujoin-stellar .

This change will strip the newline character after the name

fixes #357
@widhalmt widhalmt linked a pull request Jan 22, 2025 that will close this issue
@cbeaujoin-stellar
Copy link
Author

cbeaujoin-stellar commented Jan 23, 2025

Hello,

I'm using:

  • ansible [core 2.16.3]
  • python version = 3.12.3
  • jinja version = 3.1.2
  • libyaml = True

tbauriedel pushed a commit that referenced this issue Jan 31, 2025
* Use '>-' instead of '>' for YAML multline when creating package names.

The extra newline at the end of the string can cause JSON parsing errors as reported by @cbeaujoin-stellar .

This change will strip the newline character after the name

fixes #357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants