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

preconfigure roles: Avoid role aborts during assert runs #572

Merged
merged 1 commit into from
Jan 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@
### # /opt/ibm/lop/configure
### # yum -y install ibm-power-managed-rhel7
###
- name: Get install status of required IBM packages
# Reasons for noqa:
# command-instead-of-module: I need to examine the output of the yum info command.
# risky-shell-pipe: If a package is not installed, the shell command will fail. But I want the command to
# succeed so that the awk command can examine the result.
- name: Get install status of required IBM packages # noqa command-instead-of-module risky-shell-pipe
ansible.builtin.shell: |
set -o pipefail && yum info installed {{ __sap_hana_preconfigure_required_ppc64le | map('quote') | join(' ') }} |
yum info installed {{ __sap_hana_preconfigure_required_ppc64le | map('quote') | join(' ') }} |
awk '/Name/{n=$NF}/Version/{v=$NF}/Release/{r=$NF}/Description/{printf ("%s\n", n)}'
register: __sap_hana_preconfigure_register_required_ppc64le_packages_assert
changed_when: no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
sap_hana_preconfigure_assert_all_config)"

- name: Get active tuned profile
ansible.builtin.shell: /usr/sbin/tuned-adm active | grep ":" | cut -d ":" -f 2 | awk '{$1=$1;print}'
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | awk '/:/{print $NF}'
check_mode: no
register: __sap_hana_preconfigure_register_current_tuned_profile_assert
ignore_errors: yes
Expand Down
8 changes: 4 additions & 4 deletions roles/sap_netweaver_preconfigure/tasks/sapnote/2526952.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
ansible.builtin.service:
name: tuned
state: started
enabled: yes
enabled: true

- name: Show currently active tuned profile
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | awk '/:/{print $NF}'
check_mode: no
check_mode: false
register: __sap_netweaver_preconfigure_register_current_tuned_profile
changed_when: false

Expand All @@ -39,8 +39,8 @@
changed_when: true

- name: Show new active tuned profile
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | awk '{print $NF}'
check_mode: no
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | awk '/:/{print $NF}'
check_mode: false
register: __sap_netweaver_preconfigure_register_new_tuned_profile
changed_when: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@
when: "'tuned-profiles-sap' in ansible_facts.packages"

- name: Get active tuned profile
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | grep ":" | cut -d ":" -f 2 | awk '{$1=$1;print}'
check_mode: no
ansible.builtin.shell: set -o pipefail && /usr/sbin/tuned-adm active | awk '/:/{print $NF}'
check_mode: false
register: __sap_netweaver_preconfigure_register_current_tuned_profile
ignore_errors: true
changed_when: false

- name: Assert - Display the output of the tuned-adm active command
ansible.builtin.debug:
var: __sap_netweaver_preconfigure_register_current_tuned_profile.stdout_lines,
__sap_netweaver_preconfigure_register_current_tuned_profile.stderr_lines
ignore_errors: true

- name: Assert that tuned profile sap-netweaver is currently active
- name: Assert that tuned profile 'sap-netweaver' is currently active
ansible.builtin.assert:
that: __sap_netweaver_preconfigure_register_current_tuned_profile.stdout == 'sap-netweaver'
fail_msg: "FAIL: The tuned profile 'sap-netweaver' is currently not active!
Expand Down