Skip to content

[3006.x] Added support and tests for Sys V service files for RedHat family #67908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 3006.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/67888.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added service files for specific rpm packages to /etc/init.d
11 changes: 11 additions & 0 deletions pkg/rpm/salt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ install -p -m 0644 %{_salt_src}/doc/man/salt-api.1 %{buildroot}%{_mandir}/man1/s
install -p -m 0644 %{_salt_src}/doc/man/salt-cloud.1 %{buildroot}%{_mandir}/man1/salt-cloud.1
install -p -m 0644 %{_salt_src}/doc/man/salt-ssh.1 %{buildroot}%{_mandir}/man1/salt-ssh.1

# Sys V service files
mkdir -p %{buildroot}%{_sysconfdir}/init.d
install -p -m 0755 %{_salt_src}/pkg/rpm/salt-minion %{buildroot}%{_sysconfdir}/init.d/salt-minion
install -p -m 0755 %{_salt_src}/pkg/rpm/salt-master %{buildroot}%{_sysconfdir}/init.d/salt-master
install -p -m 0755 %{_salt_src}/pkg/rpm/salt-syndic %{buildroot}%{_sysconfdir}/init.d/salt-syndic
install -p -m 0755 %{_salt_src}/pkg/rpm/salt-api %{buildroot}%{_sysconfdir}/init.d/salt-api


%clean
rm -rf %{buildroot}
Expand Down Expand Up @@ -361,6 +368,7 @@ rm -rf %{buildroot}
%dir %attr(0750, salt, salt) %{_var}/cache/salt/master/roots/
%dir %attr(0750, salt, salt) %{_var}/cache/salt/master/syndics/
%dir %attr(0750, salt, salt) %{_var}/cache/salt/master/tokens/
%{_sysconfdir}/init.d/salt-master


%files minion
Expand All @@ -378,19 +386,22 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/salt/pki/minion
%dir %{_sysconfdir}/salt/minion.d
%dir %attr(0750, root, root) %{_var}/cache/salt/minion/
%{_sysconfdir}/init.d/salt-minion


%files syndic
%doc %{_mandir}/man1/salt-syndic.1*
%{_bindir}/salt-syndic
%{_unitdir}/salt-syndic.service
%{_sysconfdir}/init.d/salt-syndic


%files api
%defattr(-,root,root)
%doc %{_mandir}/man1/salt-api.1*
%{_bindir}/salt-api
%{_unitdir}/salt-api.service
%{_sysconfdir}/init.d/salt-api


%files cloud
Expand Down
60 changes: 60 additions & 0 deletions tests/pytests/pkg/upgrade/test_salt_upgrade.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import subprocess
import sys
import time

Expand All @@ -7,6 +9,8 @@
import pytest
from pytestskipmarkers.utils import platform

import salt.utils.path

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -132,6 +136,62 @@ def _get_running_named_salt_pid(process_name):
return pids


def test_salt_sysv_service_files(install_salt):
"""
Test an upgrade of Salt, Minion and Master
"""
if not install_salt.upgrade:
pytest.skip("Not testing an upgrade, do not run")

if sys.platform != "linux":
pytest.skip("Not testing on a Linux platform, do not run")

if not (salt.utils.path.which("dpkg") or salt.utils.path.which("rpm")):
pytest.skip("Not testing on a Debian or RedHat family platform, do not run")

test_pkgs = install_salt.pkgs
for test_pkg_name in test_pkgs:
test_pkg_basename = os.path.basename(test_pkg_name)
# Debian/Ubuntu name typically salt-minion_300xxxxxx
# Redhat name typically salt-minion-300xxxxxx
test_pkg_basename_dash_underscore = test_pkg_basename.split("300")[0]
test_pkg_basename_adj = test_pkg_basename_dash_underscore[:-1]
if test_pkg_basename_adj in (
"salt-minion",
"salt-master",
"salt-syndic",
"salt-api",
):
test_initd_name = f"/etc/init.d/{test_pkg_basename_adj}"
if salt.utils.path.which("dpkg"):
if os.path.exists("/etc/debian_version"):
proc = subprocess.run(
["dpkg", "-c", f"{test_pkg_name}"],
capture_output=True,
check=True,
)
else:
proc = subprocess.run(
["dpkg", "-q", "-c", f"{test_pkg_name}"],
capture_output=True,
check=True,
)
elif salt.utils.path.which("rpm"):
proc = subprocess.run(
["rpm", "-q", "-l", "-p", f"{test_pkg_name}"],
capture_output=True,
check=True,
)
found_line = False
for line in proc.stdout.decode().splitlines():
# If test_initd_name not present we should fail.
if line == test_initd_name:
found_line = True
break

assert found_line


def test_salt_upgrade(salt_call_cli, install_salt):
"""
Test an upgrade of Salt, Minion and Master
Expand Down
Loading