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

Fixes for testing with molecule #807

Merged
merged 11 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roles/sap_general_preconfigure/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- name: Remount /dev/shm # noqa command-instead-of-module no-changed-when
ansible.builtin.command: mount -o remount /dev/shm
listen: __sap_general_preconfigure_mount_tmpfs_handler
tags: molecule-idempotence-notest

- name: Check if /dev/shm is available
ansible.builtin.command: df -h /dev/shm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@
loop_control:
loop_var: line_item

# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters
# in sap_general_preconfigure_etc_sysctl_sap_conf so that the "Reload kernel parameters from file ..." task
# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 .
- name: Construct the command for getting all current parameters of file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}'
ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ sap_general_preconfigure_etc_sysctl_sap_conf }}"
register: __sap_general_preconfigure_register_sap_conf_sysctl_command
changed_when: false

# Reason for noqa: The command module tries to run the complete string as a single command
- name: Get all currently active values of the parameters of file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' # noqa command-instead-of-shell
ansible.builtin.shell: "{{ __sap_general_preconfigure_register_sap_conf_sysctl_command.stdout }}"
register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_old
changed_when: false

- name: Reload kernel parameters from file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}'
ansible.builtin.command: sysctl -p "{{ sap_general_preconfigure_etc_sysctl_sap_conf }}"
register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output
changed_when: true
register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new
changed_when: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_old.stdout != __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new.stdout

- name: Display kernel parameters after setting kernel.pid_max
ansible.builtin.debug:
var: __sap_general_preconfigure_register_sap_conf_sysctl_p_output.stdout_lines
var: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new.stdout_lines
3 changes: 3 additions & 0 deletions roles/sap_general_preconfigure/tasks/RedHat/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
# and then having to compare the output against the list of desired repos
- name: Run the subscription-manager command # noqa no-changed-when
ansible.builtin.command: "{{ __sap_general_preconfigure_fact_subscription_manager_command }}"
tags: molecule-idempotence-notest

# Reason for noqa: We need the output of the yum command
- name: Get list of enabled repositories
Expand Down Expand Up @@ -104,6 +105,7 @@
when:
- sap_general_preconfigure_set_minor_release
- __sap_general_preconfigure_register_subscription_manager_release.stdout != ansible_distribution_version
tags: molecule-idempotence-notest

- name: Ensure that the required package groups are installed, RHEL except 8.1
ansible.builtin.package:
Expand All @@ -120,6 +122,7 @@
ansible.builtin.command: "yum install {{ sap_general_preconfigure_packagegroups | join(' ') }} --nobest --exclude=kernel* -y"
register: __sap_general_preconfigure_register_yum_group_install
when: ansible_distribution_version == '8.1'
tags: molecule-idempotence-notest

# possible replacement once we no longer need Ansible 2.9 compatibility:
#- name: Ensure that the required package groups are installed, RHEL 8 and 9
Expand Down
1 change: 1 addition & 0 deletions roles/sap_hana_preconfigure/tasks/RedHat/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- name: Enable required repositories # noqa no-changed-when
ansible.builtin.command: "subscription-manager repos {{ __sap_hana_preconfigure_fact_required_repos_args | map('quote') | join(' ') }}"
register: __sap_hana_preconfigure_register_subscription_enable_repos
tags: molecule-idempotence-notest

- name: Display the output of the subscription-manager repos --enable command
ansible.builtin.debug:
Expand Down
22 changes: 18 additions & 4 deletions roles/sap_hana_preconfigure/tasks/sapnote/2055470.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,25 @@
loop_control:
loop_var: line_item

# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values
- name: Reload kernel parameters from file '/etc/sysctl.d/ibm_largesend.conf' # noqa no-changed-when
# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters
# in '/etc/sysctl.d/ibm_largesend.conf' so that the "Reload kernel parameters from file ..." task
# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 .
- name: Construct the command for getting all current parameters of file '/etc/sysctl.d/ibm_largesend.conf'
ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' /etc/sysctl.d/ibm_largesend.conf
register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_command
changed_when: false

# Reason for noqa: The command module tries to run the complete string as a single command
- name: Get all currently active values of the parameters of file '/etc/sysctl.d/ibm_largesend.conf' # noqa command-instead-of-shell
ansible.builtin.shell: "{{ __sap_hana_preconfigure_register_ibm_largesend_sysctl_command.stdout }}"
register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_old
changed_when: false

- name: Reload kernel parameters from file '/etc/sysctl.d/ibm_largesend.conf'
ansible.builtin.command: sysctl -p /etc/sysctl.d/ibm_largesend.conf
register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output
register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new
changed_when: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new.stdout

- name: Display largesend kernel parameters
ansible.builtin.debug:
var: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output.stdout_lines
var: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new.stdout_lines
23 changes: 18 additions & 5 deletions roles/sap_hana_preconfigure/tasks/sapnote/2382421.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
when: sap_hana_preconfigure_config_all | d(true) or sap_hana_preconfigure_2382421 | d(false)
block:

- name: Modify entries in file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}'
- name: Ensure correct entries in file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}'
ansible.builtin.lineinfile:
path: "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}"
create: yes
Expand Down Expand Up @@ -67,11 +67,24 @@
line: "net.core.rmem_max={{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem.stdout.split()[-1] }}"
state: present

# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values
- name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' # noqa no-changed-when
# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters
# in __sap_hana_preconfigure_etc_sysctl_saphana_conf so that the "Reload kernel parameters from file ..." task
# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 .
- name: Construct the command for getting all current parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}'
ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}"
register: __sap_hana_preconfigure_register_saphana_conf_sysctl_command
changed_when: false

- name: Get all currently active values of the parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}'
ansible.builtin.command: "{{ __sap_hana_preconfigure_register_saphana_conf_sysctl_command.stdout }}"
register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_old
changed_when: false

- name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}'
ansible.builtin.command: sysctl -p "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}"
register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output
register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new
changed_when: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new.stdout

- name: Display kernel parameters for network tuning
ansible.builtin.debug:
var: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output.stdout_lines
var: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new.stdout_lines
26 changes: 21 additions & 5 deletions roles/sap_hana_preconfigure/tasks/sapnote/3024346.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- sap_hana_preconfigure_config_all|d(true) or sap_hana_preconfigure_3024346|d(false)
block:

- name: Modify entries in file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
- name: Ensure correct entries in file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
ansible.builtin.lineinfile:
path: "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}"
create: yes
Expand All @@ -25,14 +25,30 @@
loop_control:
loop_var: line_item

# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values
- name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' # noqa no-changed-when
# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters
# in __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf so that the "Reload kernel parameters from file ..." task
# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 .
- name: Construct the command for getting all current parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}"
register: __sap_hana_preconfigure_register_netapp_sysctl_command
changed_when: false

# Reason for noqa - risky-shell-pipe: when adding 'set -o pipefail', the complete string is attempted to be executed as a single command.
# Also the command after the pipe is not expected to fail.
# Reason for noqa - no-tabs: This is a false positive in ansible-lint 6.22.2, removed in 24.5.0. See https://github.com/ansible/ansible-lint/issues/4020
- name: Get all currently active values of the parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' # noqa risky-shell-pipe no-tabs
ansible.builtin.shell: "{{ __sap_hana_preconfigure_register_netapp_sysctl_command.stdout }} | sed 's,\t, ,g'"
register: __sap_hana_preconfigure_register_netapp_sysctl_p_output_old
changed_when: false

- name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
ansible.builtin.command: sysctl -p "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}"
register: __sap_hana_preconfigure_register_netapp_sysctl_p_output
register: __sap_hana_preconfigure_register_netapp_sysctl_p_output_new
changed_when: __sap_hana_preconfigure_register_netapp_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_netapp_sysctl_p_output_new.stdout

- name: Display kernel parameters for NetApp NFS
ansible.builtin.debug:
var: __sap_hana_preconfigure_register_netapp_sysctl_p_output.stdout_lines
var: __sap_hana_preconfigure_register_netapp_sysctl_p_output_new.stdout_lines

- name: Set kernel tunable for NFSv3 as per SAP note 3024346
ansible.builtin.lineinfile:
Expand Down
Loading