Skip to content

Commit

Permalink
Add support for SUSE (#89)
Browse files Browse the repository at this point in the history
* Add support for SUSE

* attempt to make the beta version optional

the intent is to allow a named beta, such as 7.50.0~beta~suse~arm64, which is
currently rejected as far as the beta block is concerned.
It then tries to install it as a stable version which is nowhere to be found in
the prod repository

* CI: add SUSE tests

* auto accept repo gpg key
  • Loading branch information
chouquette authored Oct 31, 2023
1 parent c63e6d8 commit 4d1db41
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
28 changes: 25 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ commands:

setup_centos:
steps:
- run: yum -y update
- run: yum install -y curl sudo
- run: yum -y update && yum install -y curl sudo
- run: cp test/utils/systemctl.py /usr/bin/systemctl
- run: cp test/utils/systemctl.py /usr/bin/systemd
- setup_common

setup_suse:
steps:
- run: zypper refresh && zypper -n install curl sudo python3
- setup_common
- run: cp test/utils/systemctl.py /usr/bin/systemctl
- run: cp test/utils/systemctl.py /usr/bin/systemd

install:
steps:
- run: cp /srv/salt/base/top{_install,}.sls
- run: salt-call --local state.highstate -l debug

check_installed_version:
parameters:
version:
Expand Down Expand Up @@ -159,6 +165,21 @@ jobs:
- check_uninstalled:
repo_type: "yum"

agent7_suse:
docker:
- image: opensuse/leap:15
steps:
- checkout
- setup_installed_version:
version: "7"
- setup_suse
- install
- check_installed_version:
version: "7"
repo_type: "rpm"
- uninstall
- check_uninstalled:
repo_type: "rpm"

workflows:
version: 2.1
Expand All @@ -170,3 +191,4 @@ workflows:
- agent6_centos
- agent5_ubuntu
- agent5_centos
- agent7_suse
10 changes: 8 additions & 2 deletions datadog/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ datadog-repo:
- require:
- pkg: datadog-apt-https
{%- elif grains['os_family'].lower() == 'redhat' %}
{%- elif grains['os_family'].lower() in ['redhat', 'suse'] %}
datadog-repo:
pkgrepo.managed:
Expand All @@ -108,6 +108,9 @@ datadog-repo:
{%- else %}
{% set path = 'rpm' %}
{%- endif %}
{%- if grains['os_family'].lower() == 'suse' %}
{% set path = 'suse/' + path %}
{%- endif %}
{%- if latest_agent_version or parsed_version[1] != '5' %}
- repo_gpgcheck: '1'
{%- else %}
Expand All @@ -117,6 +120,7 @@ datadog-repo:
- baseurl: https://yum.datadoghq.com/{{ path }}/{{ grains['cpuarch'] }}
- gpgcheck: '1'
- gpgkey: https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
- gpgautoimport: True
- sslverify: '1'
{%- endif %}
Expand All @@ -134,13 +138,15 @@ datadog-pkg:
- version: 1:{{ datadog_install_settings.agent_version }}-1
{%- elif grains['os_family'].lower() == 'redhat' %}
- version: {{ datadog_install_settings.agent_version }}-1
{%- elif grains['os_family'].lower() == 'suse' %}
- version: 1:{{ datadog_install_settings.agent_version }}-1
{%- endif %}
- ignore_epoch: True
- refresh: True
{%- if grains['os_family'].lower() == 'debian' %}
- require:
- file: datadog-repo
{%- elif grains['os_family'].lower() == 'redhat' %}
{%- elif grains['os_family'].lower() in ['redhat', 'suse'] %}
- require:
- pkgrepo: datadog-repo
{%- endif %}
Expand Down
3 changes: 2 additions & 1 deletion datadog/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% set os_family_map = salt['grains.filter_by']({
'Debian': {},
'RedHat': {},
'Suse': {},
},
grain="os_family")
%}
Expand Down Expand Up @@ -45,7 +46,7 @@
{%- set latest_agent_version = true %}
{%- else %}
{%- set latest_agent_version = false %}
{%- set parsed_version = datadog_install_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)\.([0-9]+))?') %}
{%- set parsed_version = datadog_install_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)(\.([0-9]+))?)?') %}
{%- endif %}

{# Determine defaults depending on specified version #}
Expand Down
52 changes: 52 additions & 0 deletions test/utils/check_rpm_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python

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


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


def get_rpm_package_version(package_name):
try:
if not is_rpm_package_installed(package_name):
return None
return subprocess.check_output('rpm -qi {} | grep -E "Version[[:space:]]+:" | cut -d: -f2 | xargs'.format(package_name),
shell=True)
except subprocess.CalledProcessError:
return None



def main(argv):
expected_major_version = get_options(argv[1:])
print("Expected major version: {}".format(expected_major_version))

installed_version = get_rpm_package_version("datadog-agent")
print("Installed Agent version: {}".format(installed_version))

result = check_major_version(installed_version, expected_major_version)
assert result
print("Agent version check successful!")

# expected_major_version
if expected_major_version:
assert check_install_info(expected_major_version)
print("install_info check successful!")
else:
print("Skipping install_info check.")

assert not is_rpm_package_installed("gpg-pubkey-4172a230-55dd14f6")
print("GPG key 4172a230 is not installed.")

sys.exit()


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

0 comments on commit 4d1db41

Please sign in to comment.