Skip to content

Commit b9c91e1

Browse files
authored
Merge pull request #14596 from ggbecker/fix-sq-command-not-found
Guard SQ inspect command for RHEL>=10.1 only
2 parents c97c7cc + 2419d29 commit b9c91e1

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

  • linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed

linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
failed_when: False
2020
check_mode: no
2121
register: gpg_fingerprints
22+
when: ansible_distribution_version is version('10.1', '>=')
23+
24+
- name: "{{{ rule_title }}}: Read signatures in GPG key"
25+
# According to /usr/share/doc/gnupg2/DETAILS fingerprints are in "fpr" record in field 10
26+
ansible.builtin.command: gpg --show-keys --with-fingerprint --with-colons "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release"
27+
changed_when: False
28+
register: gpg_fingerprints
29+
failed_when: False
30+
check_mode: no
31+
when: ansible_distribution_version is version('10.1', '<')
2232

2333
- name: "{{{ rule_title }}}: Set Fact - Installed GPG Fingerprints (sq format)"
2434
ansible.builtin.set_fact:

linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/bash/shared.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ then
1717
# If they are safe, try to obtain fingerprints from the key file
1818
# (to ensure there won't be e.g. CRC error).
1919
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
20-
readarray -t GPG_OUT < <(sq inspect "$REDHAT_RELEASE_KEY" | grep Fingerprint: | cut -d ":" -f 2)
20+
if {{{ bash_os_linux_conditional("rhel", expected_ver="10.1", op=">=") | trim }}}
21+
then
22+
readarray -t GPG_OUT < <(sq inspect "$REDHAT_RELEASE_KEY" | grep Fingerprint: | cut -d ":" -f 2)
23+
else
24+
readarray -t GPG_OUT < <(gpg --show-keys --with-fingerprint --with-colons "$REDHAT_RELEASE_KEY" | grep -A1 "^pub" | grep "^fpr" | cut -d ":" -f 10)
25+
fi
2126
{{% else %}}
2227
readarray -t GPG_OUT < <(gpg --show-keys --with-fingerprint --with-colons "$REDHAT_RELEASE_KEY" | grep -A1 "^pub" | grep "^fpr" | cut -d ":" -f 10)
2328
{{% endif %}}

0 commit comments

Comments
 (0)