Skip to content

Commit

Permalink
Remove old 4172a230 GPG key (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSerrania authored Jan 12, 2023
1 parent 8683a0b commit 916cac2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 5 additions & 4 deletions datadog/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ datadog-repo:
- name: datadog
- baseurl: https://yum.datadoghq.com/{{ path }}/{{ grains['cpuarch'] }}
- gpgcheck: '1'
{%- if latest_agent_version or parsed_version[1] == '7' %}
- gpgkey: https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
{%- else %}
- gpgkey: https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public https://keys.datadoghq.com/DATADOG_RPM_KEY.public
{%- endif %}
- sslverify: '1'
{%- endif %}
key-4172a230-removal:
cmd.run:
- name: rpm --erase gpg-pubkey-4172a230-55dd14f6
- onlyif: rpm -q gpg-pubkey-4172a230-55dd14f6
datadog-pkg:
pkg.installed:
- name: datadog-agent
Expand Down
16 changes: 14 additions & 2 deletions test/utils/check_yum_install.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#!/usr/bin/env python

import subprocess
import yum, sys
from helpers import get_options, check_major_version, check_install_info

def get_yum_package_version(package_name):
yb = yum.YumBase()
try:
# Use next to stop at the first match
pkg = next(p for p in yb.rpmdb.returnPackages() if p.name == "datadog-agent")
pkg = next(p for p in yb.rpmdb.returnPackages() if p.name == package_name)
installed_version = pkg.version
except StopIteration:
# datadog-agent is not in the list of installed packages
installed_version = None

return installed_version

def is_rpm_package_installed(package_name):
try:
subprocess.check_output(["rpm", "-q", package_name])
return True
except subprocess.CalledProcessError as e:
return False

def main(argv):
expected_major_version = get_options(argv[1:])
Expand All @@ -40,8 +47,13 @@ def main(argv):
else:
print("Skipping install_info check.")

sys.exit()
if is_rpm_package_installed("gpg-pubkey-4172a230-55dd14f6"):
print("GPG key 4172a230 is installed, but shouldn't.")
sys.exit(1)
else:
print("GPG key 4172a230 is not installed.")

sys.exit()

if __name__ == "__main__":
main(sys.argv)

0 comments on commit 916cac2

Please sign in to comment.