Skip to content

Commit 4d1db41

Browse files
authored
Add support for SUSE (#89)
* 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
1 parent c63e6d8 commit 4d1db41

4 files changed

Lines changed: 87 additions & 6 deletions

File tree

.circleci/config.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@ commands:
2727

2828
setup_centos:
2929
steps:
30-
- run: yum -y update
31-
- run: yum install -y curl sudo
30+
- run: yum -y update && yum install -y curl sudo
3231
- run: cp test/utils/systemctl.py /usr/bin/systemctl
3332
- run: cp test/utils/systemctl.py /usr/bin/systemd
3433
- setup_common
3534

35+
setup_suse:
36+
steps:
37+
- run: zypper refresh && zypper -n install curl sudo python3
38+
- setup_common
39+
- run: cp test/utils/systemctl.py /usr/bin/systemctl
40+
- run: cp test/utils/systemctl.py /usr/bin/systemd
41+
3642
install:
3743
steps:
3844
- run: cp /srv/salt/base/top{_install,}.sls
3945
- run: salt-call --local state.highstate -l debug
40-
46+
4147
check_installed_version:
4248
parameters:
4349
version:
@@ -159,6 +165,21 @@ jobs:
159165
- check_uninstalled:
160166
repo_type: "yum"
161167

168+
agent7_suse:
169+
docker:
170+
- image: opensuse/leap:15
171+
steps:
172+
- checkout
173+
- setup_installed_version:
174+
version: "7"
175+
- setup_suse
176+
- install
177+
- check_installed_version:
178+
version: "7"
179+
repo_type: "rpm"
180+
- uninstall
181+
- check_uninstalled:
182+
repo_type: "rpm"
162183

163184
workflows:
164185
version: 2.1
@@ -170,3 +191,4 @@ workflows:
170191
- agent6_centos
171192
- agent5_ubuntu
172193
- agent5_centos
194+
- agent7_suse

datadog/install.sls

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ datadog-repo:
8787
- require:
8888
- pkg: datadog-apt-https
8989
90-
{%- elif grains['os_family'].lower() == 'redhat' %}
90+
{%- elif grains['os_family'].lower() in ['redhat', 'suse'] %}
9191
9292
datadog-repo:
9393
pkgrepo.managed:
@@ -108,6 +108,9 @@ datadog-repo:
108108
{%- else %}
109109
{% set path = 'rpm' %}
110110
{%- endif %}
111+
{%- if grains['os_family'].lower() == 'suse' %}
112+
{% set path = 'suse/' + path %}
113+
{%- endif %}
111114
{%- if latest_agent_version or parsed_version[1] != '5' %}
112115
- repo_gpgcheck: '1'
113116
{%- else %}
@@ -117,6 +120,7 @@ datadog-repo:
117120
- baseurl: https://yum.datadoghq.com/{{ path }}/{{ grains['cpuarch'] }}
118121
- gpgcheck: '1'
119122
- 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
123+
- gpgautoimport: True
120124
- sslverify: '1'
121125
{%- endif %}
122126
@@ -134,13 +138,15 @@ datadog-pkg:
134138
- version: 1:{{ datadog_install_settings.agent_version }}-1
135139
{%- elif grains['os_family'].lower() == 'redhat' %}
136140
- version: {{ datadog_install_settings.agent_version }}-1
141+
{%- elif grains['os_family'].lower() == 'suse' %}
142+
- version: 1:{{ datadog_install_settings.agent_version }}-1
137143
{%- endif %}
138144
- ignore_epoch: True
139145
- refresh: True
140146
{%- if grains['os_family'].lower() == 'debian' %}
141147
- require:
142148
- file: datadog-repo
143-
{%- elif grains['os_family'].lower() == 'redhat' %}
149+
{%- elif grains['os_family'].lower() in ['redhat', 'suse'] %}
144150
- require:
145151
- pkgrepo: datadog-repo
146152
{%- endif %}

datadog/map.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{% set os_family_map = salt['grains.filter_by']({
44
'Debian': {},
55
'RedHat': {},
6+
'Suse': {},
67
},
78
grain="os_family")
89
%}
@@ -45,7 +46,7 @@
4546
{%- set latest_agent_version = true %}
4647
{%- else %}
4748
{%- set latest_agent_version = false %}
48-
{%- set parsed_version = datadog_install_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)\.([0-9]+))?') %}
49+
{%- set parsed_version = datadog_install_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)(\.([0-9]+))?)?') %}
4950
{%- endif %}
5051

5152
{# Determine defaults depending on specified version #}

test/utils/check_rpm_install.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess
4+
import sys
5+
from helpers import get_options, check_major_version, check_install_info
6+
7+
8+
def is_rpm_package_installed(package_name):
9+
try:
10+
subprocess.check_output(["rpm", "-q", package_name])
11+
return True
12+
except subprocess.CalledProcessError:
13+
return False
14+
15+
16+
def get_rpm_package_version(package_name):
17+
try:
18+
if not is_rpm_package_installed(package_name):
19+
return None
20+
return subprocess.check_output('rpm -qi {} | grep -E "Version[[:space:]]+:" | cut -d: -f2 | xargs'.format(package_name),
21+
shell=True)
22+
except subprocess.CalledProcessError:
23+
return None
24+
25+
26+
27+
def main(argv):
28+
expected_major_version = get_options(argv[1:])
29+
print("Expected major version: {}".format(expected_major_version))
30+
31+
installed_version = get_rpm_package_version("datadog-agent")
32+
print("Installed Agent version: {}".format(installed_version))
33+
34+
result = check_major_version(installed_version, expected_major_version)
35+
assert result
36+
print("Agent version check successful!")
37+
38+
# expected_major_version
39+
if expected_major_version:
40+
assert check_install_info(expected_major_version)
41+
print("install_info check successful!")
42+
else:
43+
print("Skipping install_info check.")
44+
45+
assert not is_rpm_package_installed("gpg-pubkey-4172a230-55dd14f6")
46+
print("GPG key 4172a230 is not installed.")
47+
48+
sys.exit()
49+
50+
51+
if __name__ == "__main__":
52+
main(sys.argv)

0 commit comments

Comments
 (0)