Compare commits
No commits in common. 'e9' and 'i10cf' have entirely different histories.
@ -1,4 +1 @@
|
|||||||
salt-*.tar.gz
|
SOURCES/salt-3006.8.tar.gz
|
||||||
SaltTesting-*.tar.gz
|
|
||||||
*.src.rpm
|
|
||||||
results_salt/
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
cff6fe9151cc8d1c231ce166aac975450d72c118 SOURCES/salt-3006.8.tar.gz
|
@ -0,0 +1,267 @@
|
|||||||
|
From 1d1b727772b4c866cabacb0a6b942285c4c31be9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergey Cherevko <s.cherevko@msvsphere-os.ru>
|
||||||
|
Date: Mon, 20 Jan 2025 16:25:50 +0300
|
||||||
|
Subject: [PATCH 1/2] Added MSVSphere support
|
||||||
|
|
||||||
|
---
|
||||||
|
salt/cloud/deploy/bootstrap-salt.sh | 87 ++++++++++++++++++-
|
||||||
|
salt/grains/core.py | 4 +-
|
||||||
|
.../pkg/integration/test_enabled_disabled.py | 1 +
|
||||||
|
.../pytests/pkg/integration/test_salt_user.py | 1 +
|
||||||
|
tests/pytests/pkg/integration/test_version.py | 1 +
|
||||||
|
tests/support/pkg.py | 7 +-
|
||||||
|
6 files changed, 95 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/salt/cloud/deploy/bootstrap-salt.sh b/salt/cloud/deploy/bootstrap-salt.sh
|
||||||
|
index c632146..d530c3f 100644
|
||||||
|
--- a/salt/cloud/deploy/bootstrap-salt.sh
|
||||||
|
+++ b/salt/cloud/deploy/bootstrap-salt.sh
|
||||||
|
@@ -1081,7 +1081,7 @@ __strip_duplicates() {
|
||||||
|
__sort_release_files() {
|
||||||
|
KNOWN_RELEASE_FILES=$(echo "(arch|alpine|centos|debian|ubuntu|fedora|redhat|suse|\
|
||||||
|
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|void|lsb|system|\
|
||||||
|
- oracle|os|almalinux|rocky)(-|_)(release|version)" | sed -E 's:[[:space:]]::g')
|
||||||
|
+ oracle|os|almalinux|rocky|msvsphere)(-|_)(release|version)" | sed -E 's:[[:space:]]::g')
|
||||||
|
primary_release_files=""
|
||||||
|
secondary_release_files=""
|
||||||
|
# Sort know VS un-known files first
|
||||||
|
@@ -1095,7 +1095,7 @@ __sort_release_files() {
|
||||||
|
done
|
||||||
|
|
||||||
|
# Now let's sort by know files importance, max important goes last in the max_prio list
|
||||||
|
- max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release"
|
||||||
|
+ max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release sphere-release"
|
||||||
|
for entry in $max_prio; do
|
||||||
|
if [ "$(echo "${primary_release_files}" | grep "$entry")" != "" ]; then
|
||||||
|
primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\\(.*\\)\\($entry\\)\\(.*\\):\\2 \\1 \\3:g")
|
||||||
|
@@ -1226,6 +1226,7 @@ __gather_linux_system_info() {
|
||||||
|
oracle ) n="Oracle Linux" ;;
|
||||||
|
almalinux ) n="AlmaLinux" ;;
|
||||||
|
rocky ) n="Rocky Linux" ;;
|
||||||
|
+ rocky ) n="MSVSphere" ;;
|
||||||
|
system )
|
||||||
|
while read -r line; do
|
||||||
|
[ "${n}x" != "systemx" ] && break
|
||||||
|
@@ -1973,14 +1974,14 @@ elif [ "${DISTRO_NAME_L}" = "debian" ]; then
|
||||||
|
__debian_codename_translation
|
||||||
|
fi
|
||||||
|
|
||||||
|
-if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then
|
||||||
|
+if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky|msvsphere)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then
|
||||||
|
echoerror "${DISTRO_NAME} does not have major version pegged packages support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Only RedHat based distros have testing support
|
||||||
|
if [ "${ITYPE}" = "testing" ]; then
|
||||||
|
- if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky)')" = "" ]; then
|
||||||
|
+ if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky|msvsphere)')" = "" ]; then
|
||||||
|
echoerror "${DISTRO_NAME} does not have testing packages support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
@@ -5719,6 +5720,84 @@ install_almalinux_check_services() {
|
||||||
|
#
|
||||||
|
#######################################################################################################################
|
||||||
|
|
||||||
|
+#######################################################################################################################
|
||||||
|
+#
|
||||||
|
+# MSVSphere Install Functions
|
||||||
|
+#
|
||||||
|
+install_msvsphere_stable_deps() {
|
||||||
|
+ install_centos_stable_deps || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_git_deps() {
|
||||||
|
+ install_centos_git_deps || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_onedir_deps() {
|
||||||
|
+ install_centos_onedir_deps || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_testing_deps() {
|
||||||
|
+ install_centos_testing_deps || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_stable() {
|
||||||
|
+ install_centos_stable || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_git() {
|
||||||
|
+ install_centos_git || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_onedir() {
|
||||||
|
+ install_centos_onedir || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_testing() {
|
||||||
|
+ install_centos_testing || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_stable_post() {
|
||||||
|
+ install_centos_stable_post || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_git_post() {
|
||||||
|
+ install_centos_git_post || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_onedir_post() {
|
||||||
|
+ install_centos_onedir_post || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_testing_post() {
|
||||||
|
+ install_centos_testing_post || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_restart_daemons() {
|
||||||
|
+ install_centos_restart_daemons || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+install_msvsphere_check_services() {
|
||||||
|
+ install_centos_check_services || return 1
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+#
|
||||||
|
+# Ended MSVSphere Install Functions
|
||||||
|
+#
|
||||||
|
+#######################################################################################################################
|
||||||
|
+
|
||||||
|
#######################################################################################################################
|
||||||
|
#
|
||||||
|
# Rocky Linux Install Functions
|
||||||
|
diff --git a/salt/grains/core.py b/salt/grains/core.py
|
||||||
|
index 17a1d68..bbd3830 100644
|
||||||
|
--- a/salt/grains/core.py
|
||||||
|
+++ b/salt/grains/core.py
|
||||||
|
@@ -1772,6 +1772,7 @@ _OS_NAME_MAP = {
|
||||||
|
"cloudserve": "CloudLinux",
|
||||||
|
"cloudlinux": "CloudLinux",
|
||||||
|
"almalinux": "AlmaLinux",
|
||||||
|
+ "msvsphere": "MSVSphere",
|
||||||
|
"pidora": "Fedora",
|
||||||
|
"scientific": "ScientificLinux",
|
||||||
|
"synology": "Synology",
|
||||||
|
@@ -2145,7 +2146,7 @@ def _os_release_quirks_for_oscodename(os_release):
|
||||||
|
# Astra Linux has no version codename, but Salt used
|
||||||
|
# to report the variant ID as oscodename.
|
||||||
|
return os_release.get("VARIANT_ID")
|
||||||
|
- if os_release["ID"] in ("almalinux", "rocky"):
|
||||||
|
+ if os_release["ID"] in ("almalinux", "rocky", "msvsphere"):
|
||||||
|
# VERSION_CODENAME is not set, but the codename is
|
||||||
|
# mentioned in PRETTY_NAME and VERSION.
|
||||||
|
match = _VERSION_RE.match(os_release.get("VERSION", ""))
|
||||||
|
@@ -2234,6 +2235,7 @@ def _linux_distribution_data():
|
||||||
|
"debian",
|
||||||
|
"linuxmint",
|
||||||
|
"mendel",
|
||||||
|
+ "msvsphere",
|
||||||
|
"pop",
|
||||||
|
"rocky",
|
||||||
|
"ubuntu",
|
||||||
|
diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py
|
||||||
|
index 99097b1..b4eef3c 100644
|
||||||
|
--- a/tests/pytests/pkg/integration/test_enabled_disabled.py
|
||||||
|
+++ b/tests/pytests/pkg/integration/test_enabled_disabled.py
|
||||||
|
@@ -14,6 +14,7 @@ def test_services(install_salt, salt_cli, salt_minion):
|
||||||
|
elif install_salt.distro_id in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
diff --git a/tests/pytests/pkg/integration/test_salt_user.py b/tests/pytests/pkg/integration/test_salt_user.py
|
||||||
|
index 74bf458..2f50614 100644
|
||||||
|
--- a/tests/pytests/pkg/integration/test_salt_user.py
|
||||||
|
+++ b/tests/pytests/pkg/integration/test_salt_user.py
|
||||||
|
@@ -191,6 +191,7 @@ def test_paths_log_rotation(
|
||||||
|
if install_salt.distro_id not in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py
|
||||||
|
index 24a665d..61e967c 100644
|
||||||
|
--- a/tests/pytests/pkg/integration/test_version.py
|
||||||
|
+++ b/tests/pytests/pkg/integration/test_version.py
|
||||||
|
@@ -128,6 +128,7 @@ def test_compare_pkg_versions_redhat_rc(version, install_salt):
|
||||||
|
if install_salt.distro_id not in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
diff --git a/tests/support/pkg.py b/tests/support/pkg.py
|
||||||
|
index d9c6487..eed579a 100644
|
||||||
|
--- a/tests/support/pkg.py
|
||||||
|
+++ b/tests/support/pkg.py
|
||||||
|
@@ -114,6 +114,7 @@ class SaltPkgInstall:
|
||||||
|
if self.distro_id in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
@@ -131,6 +132,7 @@ class SaltPkgInstall:
|
||||||
|
if self.distro_id in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
@@ -147,6 +149,7 @@ class SaltPkgInstall:
|
||||||
|
if self.distro_id in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
@@ -171,6 +174,7 @@ class SaltPkgInstall:
|
||||||
|
if self.distro_id in (
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"centos",
|
||||||
|
"redhat",
|
||||||
|
"amzn",
|
||||||
|
@@ -611,7 +615,7 @@ class SaltPkgInstall:
|
||||||
|
"3006.0"
|
||||||
|
)
|
||||||
|
distro_name = self.distro_name
|
||||||
|
- if distro_name in ("almalinux", "rocky", "centos", "fedora"):
|
||||||
|
+ if distro_name in ("almalinux", "rocky", "centos", "fedora", "msvsphere"):
|
||||||
|
distro_name = "redhat"
|
||||||
|
root_url = "salt/py3/"
|
||||||
|
if self.classic:
|
||||||
|
@@ -620,6 +624,7 @@ class SaltPkgInstall:
|
||||||
|
if self.distro_name in [
|
||||||
|
"almalinux",
|
||||||
|
"rocky",
|
||||||
|
+ "msvsphere",
|
||||||
|
"redhat",
|
||||||
|
"centos",
|
||||||
|
"amazon",
|
||||||
|
--
|
||||||
|
2.43.5
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
From 82fd2b26deb3dd04d08576415622f017527ba072 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergey Cherevko <s.cherevko@msvsphere-os.ru>
|
||||||
|
Date: Wed, 22 Jan 2025 16:23:32 +0300
|
||||||
|
Subject: [PATCH 2/2] Using timezone-aware objects to represent datetimes in
|
||||||
|
UTC
|
||||||
|
|
||||||
|
---
|
||||||
|
salt/grains/core.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/salt/grains/core.py b/salt/grains/core.py
|
||||||
|
index bbd3830..42f5ef5 100644
|
||||||
|
--- a/salt/grains/core.py
|
||||||
|
+++ b/salt/grains/core.py
|
||||||
|
@@ -2904,7 +2904,7 @@ def ip_fqdn():
|
||||||
|
if not ret["ipv" + ipv_num]:
|
||||||
|
ret[key] = []
|
||||||
|
else:
|
||||||
|
- start_time = datetime.datetime.utcnow()
|
||||||
|
+ start_time = datetime.datetime.now(datetime.UTC)
|
||||||
|
try:
|
||||||
|
info = socket.getaddrinfo(_fqdn, None, socket_type)
|
||||||
|
ret[key] = list({item[4][0] for item in info})
|
||||||
|
--
|
||||||
|
2.43.5
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
--- salt-3006.1/requirements/base.txt~ 2023-05-05 12:53:34.000000000 -0500
|
||||||
|
+++ salt-3006.1/requirements/base.txt 2023-05-24 09:59:08.874838801 -0500
|
||||||
|
@@ -9,4 +9,3 @@
|
||||||
|
packaging>=21.3
|
||||||
|
looseversion
|
||||||
|
# We need contextvars for salt-ssh
|
||||||
|
-contextvars
|
||||||
|
--- a/requirements/zeromq.txt~ 2024-02-20 16:04:07.000000000 -0600
|
||||||
|
+++ b/requirements/zeromq.txt 2024-02-22 14:27:46.531045353 -0600
|
||||||
|
@@ -2,5 +2,3 @@
|
||||||
|
-r crypto.txt
|
||||||
|
|
||||||
|
pyzmq>=20.0.0
|
||||||
|
-pyzmq==25.0.2 ; sys_platform == "win32"
|
||||||
|
-pyzmq==25.1.2 ; sys_platform == "darwin"
|
@ -0,0 +1,24 @@
|
|||||||
|
--- a/salt/ext/tornado/netutil.py~ 2023-05-05 12:53:34.000000000 -0500
|
||||||
|
+++ b/salt/ext/tornado/netutil.py 2023-07-24 11:27:02.376824349 -0500
|
||||||
|
@@ -54,8 +54,8 @@
|
||||||
|
elif ssl is None:
|
||||||
|
ssl_match_hostname = SSLCertificateError = None # type: ignore
|
||||||
|
else:
|
||||||
|
- import backports.ssl_match_hostname
|
||||||
|
- ssl_match_hostname = backports.ssl_match_hostname.match_hostname
|
||||||
|
+ import urllib3.util.ssl_match_hostname
|
||||||
|
+ ssl_match_hostname = urllib3.util.ssl_match_hostname
|
||||||
|
SSLCertificateError = backports.ssl_match_hostname.CertificateError # type: ignore
|
||||||
|
|
||||||
|
if hasattr(ssl, 'SSLContext'):
|
||||||
|
--- a/salt/ext/tornado/netutil.py~ 2023-07-24 11:50:02.836988664 -0500
|
||||||
|
+++ b/salt/ext/tornado/netutil.py 2023-07-24 11:50:52.217539638 -0500
|
||||||
|
@@ -56,7 +56,7 @@
|
||||||
|
else:
|
||||||
|
import urllib3.util.ssl_match_hostname
|
||||||
|
ssl_match_hostname = urllib3.util.ssl_match_hostname
|
||||||
|
- SSLCertificateError = backports.ssl_match_hostname.CertificateError # type: ignore
|
||||||
|
+ SSLCertificateError = urllib3.util.ssl_match_hostname.CertificateError # type: ignore
|
||||||
|
|
||||||
|
if hasattr(ssl, 'SSLContext'):
|
||||||
|
if hasattr(ssl, 'create_default_context'):
|
@ -0,0 +1,3 @@
|
|||||||
|
#Type Name ID GECOS Home directory Shell
|
||||||
|
u salt - "Salt" /etc/salt /bin/bash
|
||||||
|
g salt -
|
@ -1,20 +0,0 @@
|
|||||||
--- salt-3005/requirements/base.txt.fix 2022-08-25 17:13:58.740984435 -0600
|
|
||||||
+++ salt-3005/requirements/base.txt 2022-08-25 17:14:14.428036445 -0600
|
|
||||||
@@ -4,5 +4,4 @@ PyYAML
|
|
||||||
MarkupSafe
|
|
||||||
requests>=1.0.0
|
|
||||||
distro>=1.0.1
|
|
||||||
-contextvars
|
|
||||||
psutil>=5.0.0
|
|
||||||
--- salt-3005.2/requirements/zeromq.txt~ 2023-08-03 12:27:49.000000000 -0500
|
|
||||||
+++ salt-3005.2/requirements/zeromq.txt 2023-09-05 15:00:22.172125782 -0500
|
|
||||||
@@ -1,8 +1,4 @@
|
|
||||||
-r base.txt
|
|
||||||
-r crypto.txt
|
|
||||||
|
|
||||||
-pyzmq<=20.0.0; python_version < "3.6"
|
|
||||||
-pyzmq>=20.0.0; python_version >= "3.6"
|
|
||||||
-# We can't use 23+ on Windows until they fix this:
|
|
||||||
-# https://github.com/zeromq/pyzmq/issues/1472
|
|
||||||
-pyzmq>=20.0.0,<=22.0.3 ; sys_platform == "win32"
|
|
||||||
+pyzmq>=20.0.0
|
|
@ -1,214 +0,0 @@
|
|||||||
diff -Naur a/salt/modules/rpmbuild_pkgbuild.py b/salt/modules/rpmbuild_pkgbuild.py
|
|
||||||
--- a/salt/modules/rpmbuild_pkgbuild.py 2019-07-02 10:15:07.035874718 -0600
|
|
||||||
+++ b/salt/modules/rpmbuild_pkgbuild.py 2019-07-02 10:55:34.147934899 -0600
|
|
||||||
@@ -140,7 +140,9 @@
|
|
||||||
tgtattrs = tgt.split('-')
|
|
||||||
if tgtattrs[0] == 'amzn':
|
|
||||||
distset = '--define "dist .{0}1"'.format(tgtattrs[0])
|
|
||||||
- elif tgtattrs[1] in ['6', '7']:
|
|
||||||
+ elif tgtattrs[0] == 'amzn2':
|
|
||||||
+ distset = '--define "dist .{0}"'.format(tgtattrs[0])
|
|
||||||
+ elif tgtattrs[1] in ['6', '7', '8']:
|
|
||||||
distset = '--define "dist .el{0}"'.format(tgtattrs[1])
|
|
||||||
else:
|
|
||||||
distset = ''
|
|
||||||
@@ -173,6 +175,19 @@
|
|
||||||
return deps_list
|
|
||||||
|
|
||||||
|
|
||||||
+def _check_repo_gpg_phrase_utils():
|
|
||||||
+ '''
|
|
||||||
+ Check for /usr/libexec/gpg-preset-passphrase is installed
|
|
||||||
+ '''
|
|
||||||
+ util_name = '/usr/libexec/gpg-preset-passphrase'
|
|
||||||
+ if __salt__['file.file_exists'](util_name):
|
|
||||||
+ return True
|
|
||||||
+ else:
|
|
||||||
+ raise CommandExecutionError(
|
|
||||||
+ 'utility \'{0}\' needs to be installed'.format(util_name)
|
|
||||||
+ )
|
|
||||||
+
|
|
||||||
+
|
|
||||||
def make_src_pkg(dest_dir, spec, sources, env=None, template=None, saltenv='base', runas='root'):
|
|
||||||
'''
|
|
||||||
Create a source rpm from the given spec file and sources
|
|
||||||
@@ -450,8 +465,14 @@
|
|
||||||
|
|
||||||
Use a passphrase with the signing key presented in ``keyid``.
|
|
||||||
Passphrase is received from Pillar data which could be passed on the
|
|
||||||
- command line with ``pillar`` parameter. For example:
|
|
||||||
+ command line with ``pillar`` parameter.
|
|
||||||
|
|
||||||
+ .. versionadded:: 2018.2.1
|
|
||||||
+
|
|
||||||
+ RHEL 8 and above leverages gpg-agent and gpg-preset-passphrase for
|
|
||||||
+ caching keys, etc.
|
|
||||||
+
|
|
||||||
+ For example:
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
pillar='{ "gpg_passphrase" : "my_passphrase" }'
|
|
||||||
@@ -485,10 +506,27 @@
|
|
||||||
'''
|
|
||||||
SIGN_PROMPT_RE = re.compile(r'Enter pass phrase: ', re.M)
|
|
||||||
|
|
||||||
- define_gpg_name = ''
|
|
||||||
+ local_keygrip_to_use = None
|
|
||||||
+ local_key_fingerprint = None
|
|
||||||
local_keyid = None
|
|
||||||
local_uids = None
|
|
||||||
+ define_gpg_name = ''
|
|
||||||
phrase = ''
|
|
||||||
+ retrc = 0
|
|
||||||
+ use_gpg_agent = False
|
|
||||||
+
|
|
||||||
+ res = {
|
|
||||||
+ 'retcode': 1,
|
|
||||||
+ 'stdout': '',
|
|
||||||
+ 'stderr': 'initialization value'
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if gnupghome and env is None:
|
|
||||||
+ env = {}
|
|
||||||
+ env['GNUPGHOME'] = gnupghome
|
|
||||||
+
|
|
||||||
+ if __grains__.get('osmajorrelease') >= 7:
|
|
||||||
+ use_gpg_agent = True
|
|
||||||
|
|
||||||
if keyid is not None:
|
|
||||||
# import_keys
|
|
||||||
@@ -517,8 +555,29 @@
|
|
||||||
if keyid == gpg_key['keyid'][8:]:
|
|
||||||
local_uids = gpg_key['uids']
|
|
||||||
local_keyid = gpg_key['keyid']
|
|
||||||
+ if use_gpg_agent:
|
|
||||||
+ local_keygrip_to_use = gpg_key['fingerprint']
|
|
||||||
+ local_key_fingerprint = gpg_key['fingerprint']
|
|
||||||
break
|
|
||||||
|
|
||||||
+ if use_gpg_agent:
|
|
||||||
+ cmd = 'gpg --with-keygrip --list-secret-keys'
|
|
||||||
+ local_keys2_keygrip = __salt__['cmd.run'](cmd, runas=runas, env=env)
|
|
||||||
+ local_keys2 = iter(local_keys2_keygrip.splitlines())
|
|
||||||
+ try:
|
|
||||||
+ for line in local_keys2:
|
|
||||||
+ if line.startswith('sec'):
|
|
||||||
+ line_fingerprint = next(local_keys2).lstrip().rstrip()
|
|
||||||
+ if local_key_fingerprint == line_fingerprint:
|
|
||||||
+ lkeygrip = next(local_keys2).split('=')
|
|
||||||
+ local_keygrip_to_use = lkeygrip[1].lstrip().rstrip()
|
|
||||||
+ break
|
|
||||||
+ except StopIteration:
|
|
||||||
+ raise SaltInvocationError(
|
|
||||||
+ 'unable to find keygrip associated with fingerprint \'{0}\' for keyid \'{1}\''
|
|
||||||
+ .format(local_key_fingerprint, local_keyid)
|
|
||||||
+ )
|
|
||||||
+
|
|
||||||
if local_keyid is None:
|
|
||||||
raise SaltInvocationError(
|
|
||||||
'The key ID \'{0}\' was not found in GnuPG keyring at \'{1}\''
|
|
||||||
@@ -527,6 +586,15 @@
|
|
||||||
|
|
||||||
if use_passphrase:
|
|
||||||
phrase = __salt__['pillar.get']('gpg_passphrase')
|
|
||||||
+ if use_gpg_agent:
|
|
||||||
+ _check_repo_gpg_phrase_utils()
|
|
||||||
+ cmd = '/usr/libexec/gpg-preset-passphrase --verbose --preset --passphrase "{0}" {1}'.format(phrase, local_keygrip_to_use)
|
|
||||||
+ retrc = __salt__['cmd.retcode'](cmd, runas=runas, env=env)
|
|
||||||
+ if retrc != 0:
|
|
||||||
+ raise SaltInvocationError(
|
|
||||||
+ 'Failed to preset passphrase, error {1}, '
|
|
||||||
+ 'check logs for further details'.format(retrc)
|
|
||||||
+ )
|
|
||||||
|
|
||||||
if local_uids:
|
|
||||||
define_gpg_name = '--define=\'%_signature gpg\' --define=\'%_gpg_name {0}\''.format(
|
|
||||||
@@ -553,43 +621,54 @@
|
|
||||||
number_retries = timeout / interval
|
|
||||||
times_looped = 0
|
|
||||||
error_msg = 'Failed to sign file {0}'.format(abs_file)
|
|
||||||
- cmd = 'rpm {0} --addsign {1}'.format(define_gpg_name, abs_file)
|
|
||||||
- preexec_fn = functools.partial(salt.utils.user.chugid_and_umask, runas, None)
|
|
||||||
- try:
|
|
||||||
- stdout, stderr = None, None
|
|
||||||
- proc = salt.utils.vt.Terminal(
|
|
||||||
- cmd,
|
|
||||||
- shell=True,
|
|
||||||
- preexec_fn=preexec_fn,
|
|
||||||
- stream_stdout=True,
|
|
||||||
- stream_stderr=True
|
|
||||||
- )
|
|
||||||
- while proc.has_unread_data:
|
|
||||||
- stdout, stderr = proc.recv()
|
|
||||||
- if stdout and SIGN_PROMPT_RE.search(stdout):
|
|
||||||
- # have the prompt for inputting the passphrase
|
|
||||||
- proc.sendline(phrase)
|
|
||||||
- else:
|
|
||||||
- times_looped += 1
|
|
||||||
+ if use_gpg_agent:
|
|
||||||
+ cmd = 'rpmsign --verbose --key-id={0} --addsign {1}'.format(local_keyid, abs_file)
|
|
||||||
+ retrc |= __salt__['cmd.retcode'](cmd, runas=runas, cwd=repodir, use_vt=True, env=env)
|
|
||||||
+ if retrc != 0:
|
|
||||||
+ raise SaltInvocationError(
|
|
||||||
+ 'Signing encountered errors for command \'{0}\', '
|
|
||||||
+ 'return error {1}, check logs for further details'.format(
|
|
||||||
+ cmd,
|
|
||||||
+ retrc)
|
|
||||||
+ )
|
|
||||||
+ else:
|
|
||||||
+ cmd = 'rpm {0} --addsign {1}'.format(define_gpg_name, abs_file)
|
|
||||||
+ preexec_fn = functools.partial(salt.utils.user.chugid_and_umask, runas, None)
|
|
||||||
+ try:
|
|
||||||
+ stdout, stderr = None, None
|
|
||||||
+ proc = salt.utils.vt.Terminal(
|
|
||||||
+ cmd,
|
|
||||||
+ shell=True,
|
|
||||||
+ preexec_fn=preexec_fn,
|
|
||||||
+ stream_stdout=True,
|
|
||||||
+ stream_stderr=True
|
|
||||||
+ )
|
|
||||||
+ while proc.has_unread_data:
|
|
||||||
+ stdout, stderr = proc.recv()
|
|
||||||
+ if stdout and SIGN_PROMPT_RE.search(stdout):
|
|
||||||
+ # have the prompt for inputting the passphrase
|
|
||||||
+ proc.sendline(phrase)
|
|
||||||
+ else:
|
|
||||||
+ times_looped += 1
|
|
||||||
+
|
|
||||||
+ if times_looped > number_retries:
|
|
||||||
+ raise SaltInvocationError(
|
|
||||||
+ 'Attemping to sign file {0} failed, timed out after {1} seconds'
|
|
||||||
+ .format(abs_file, int(times_looped * interval))
|
|
||||||
+ )
|
|
||||||
+ time.sleep(interval)
|
|
||||||
|
|
||||||
- if times_looped > number_retries:
|
|
||||||
+ proc_exitstatus = proc.exitstatus
|
|
||||||
+ if proc_exitstatus != 0:
|
|
||||||
raise SaltInvocationError(
|
|
||||||
- 'Attemping to sign file {0} failed, timed out after {1} seconds'
|
|
||||||
- .format(abs_file, int(times_looped * interval))
|
|
||||||
+ 'Signing file {0} failed with proc.status {1}'
|
|
||||||
+ .format(abs_file, proc_exitstatus)
|
|
||||||
)
|
|
||||||
- time.sleep(interval)
|
|
||||||
-
|
|
||||||
- proc_exitstatus = proc.exitstatus
|
|
||||||
- if proc_exitstatus != 0:
|
|
||||||
- raise SaltInvocationError(
|
|
||||||
- 'Signing file {0} failed with proc.status {1}'
|
|
||||||
- .format(abs_file, proc_exitstatus)
|
|
||||||
- )
|
|
||||||
- except salt.utils.vt.TerminalException as err:
|
|
||||||
- trace = traceback.format_exc()
|
|
||||||
- log.error(error_msg, err, trace)
|
|
||||||
- finally:
|
|
||||||
- proc.close(terminate=True, kill=True)
|
|
||||||
+ except salt.utils.vt.TerminalException as err:
|
|
||||||
+ trace = traceback.format_exc()
|
|
||||||
+ log.error(error_msg, err, trace)
|
|
||||||
+ finally:
|
|
||||||
+ proc.close(terminate=True, kill=True)
|
|
||||||
|
|
||||||
cmd = 'createrepo --update {0}'.format(repodir)
|
|
||||||
return __salt__['cmd.run_all'](cmd, runas=runas)
|
|
Loading…
Reference in new issue