Skip to content

Commit

Permalink
preconfigure roles: Avoid role aborts during assert runs
Browse files Browse the repository at this point in the history
Solves issue #571.

Signed-off-by: Bernd Finger <[email protected]>
  • Loading branch information
berndfinger committed Jan 3, 2024
1 parent 4374d72 commit b5f0410
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
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

0 comments on commit b5f0410

Please sign in to comment.