---

# loop block for sapnote/assert-2382421.yml

- name: 2382421 - Get {{ line_item.name }} from {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}
  command: awk 'BEGIN{FS="="}/{{ line_item.name }}/{print $NF}' {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}
  register: __sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert
  changed_when: no
  ignore_errors: yes
  when: __sap_hana_preconfigure_register_stat_sysctl_saphana_conf_assert.stat.exists

- name: 2382421 - Assert that {{ line_item.name }} is set correctly in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}
  assert:
    that: "__sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout == '{{ line_item.value }}'"
    fail_msg: "FAIL: The value of '{{ line_item.name }}' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is
               '{{ __sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout }}' but the expected value is 'line_item.value'!"
    success_msg: "PASS: The value of '{{ line_item.name }}' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is
                  '{{ __sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout }}'."
  ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"
  when: __sap_hana_preconfigure_register_stat_sysctl_saphana_conf_assert.stat.exists

- name: 2382421 - Get {{ line_item.name }} from sysctl
  shell: sysctl -n {{ line_item.name }} | awk '{gsub ("\t", " "); print}'
  register: __sap_hana_preconfigure_register_sysctl_network_parameter_assert
  changed_when: no
  ignore_errors: yes

- name: 2382421 - Assert that {{ line_item.name }} is set correctly as per sysctl
  assert:
    that: "__sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout == '{{ line_item.value }}'"
    fail_msg: "FAIL: The current value of '{{ line_item.name }}' as per sysctl is
               '{{ __sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout }}' but the expected value is '{{ line_item.value }}'!"
    success_msg: "PASS: The current value of '{{ line_item.name }}' as per sysctl is
                  '{{ __sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout }}'."
  ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"
