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

sap_general_preconfigure: Regression after PR #697 #736

Closed
berndfinger opened this issue May 10, 2024 · 2 comments
Closed

sap_general_preconfigure: Regression after PR #697 #736

berndfinger opened this issue May 10, 2024 · 2 comments
Assignees

Comments

@berndfinger
Copy link
Member

The new code of #697 is not correctly matching the hostname as a full string separated by white space(s). It also matches the hostname as a substring of a longer string.

A possible solution is to replace the line

when: __sap_general_preconfigure_line_item | regex_search("(\s)*" + sap_general_preconfigure_hostname + "($|\s)*" )

by:

  when: __sap_general_preconfigure_line_item | regex_search('(\s)' + sap_general_preconfigure_hostname + '($|\s)' )

.

I tested this with a sample /etc/hosts file containing:

  • a line with ipv4 adress, the FQDN, the hostname and an alias, all separated by a tab, one, or two spaces, and a space at the end or not space at the end of the line.
  • and another line with a different ipv4 address, the FQDN with a hostname starting with the same characters as the previous one but with 3 more characters, and the hostname without the DNS domain, and an alias.

To be done: Find out why the original pattern incorrectly matched the second line as well.

@berndfinger berndfinger self-assigned this May 10, 2024
@berndfinger
Copy link
Member Author

Also, an Ansible-only solution should limit the amount of output lines: When looping over a long /etc/hosts file, there will be many output lines, even when optimizing the output with the label variable in loop_control. So an Ansible-only solution should use Ansible filters like count. However, I do currently not have enough time to test and analyze any issues related to constructing regex patterns from multiple strings, which would be a requirement. So I'll now revert back to the awk method, which is easy to understand and analyze and also can easily produce lean output.

berndfinger added a commit to berndfinger/community.sap_install that referenced this issue May 13, 2024
Solves issue sap-linuxlab#736.

It's essentially a backout of PR sap-linuxlab#697, especially of commit 1fc1459.

Signed-off-by: Bernd Finger <bfinger@redhat.com>
@berndfinger
Copy link
Member Author

Fixed in #737.

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