Skip to content

Commit 8166507

Browse files
committed
adjust opensuse distribution based on sles version
1 parent feb371a commit 8166507

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

manifests/mod/php.pp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,21 @@
106106
}
107107

108108
if $facts['os']['name'] == 'SLES' {
109-
# Enable legacy repo to install apache2-mod_php7 package
110-
# if SUSE OS major version is >= 15 and minor version is > 3
111-
if ($_package_name == 'apache2-mod_php7' and versioncmp($facts['os']['release']['major'], '15') >= 0 and versioncmp($facts['os']['release']['minor'], '3') == 1) {
112-
exec { 'enable legacy repos':
113-
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
114-
command => "SUSEConnect --product sle-module-legacy/${facts['os']['release']['major']}.${facts['os']['release']['minor']}/x86_64",
115-
unless => "SUSEConnect --status-text | grep sle-module-legacy/${facts['os']['release']['major']}.${facts['os']['release']['minor']}/x86_64",
116-
}
109+
# TEMPORARY FIX: Configure fallback repo for unregistered SLES systems
110+
# GCP BYOS images have zero repos configured, SUSEConnect doesn't work
111+
# Use version-appropriate repos: Leap 42.3 for SLES 12 (PHP 5), Leap 15.6 for SLES 15 (PHP 7)
112+
if versioncmp($facts['os']['release']['major'], '15') >= 0 {
113+
$repo_url = 'http://download.opensuse.org/distribution/leap/15.6/repo/oss/'
114+
} else {
115+
# SLES 12 needs older repo with PHP 5 support
116+
$repo_url = 'http://download.opensuse.org/distribution/leap/42.3/repo/oss/'
117+
}
118+
119+
exec { 'Configure zypper repo for SLES mod_php':
120+
path => '/bin:/usr/bin:/sbin:/usr/sbin',
121+
command => "zypper --non-interactive --gpg-auto-import-keys ar ${repo_url} opensuse-leap-fallback && zypper --non-interactive --gpg-auto-import-keys refresh",
122+
unless => "zypper lr 2>/dev/null | grep -q 'opensuse-leap-fallback\\|http'",
123+
logoutput => true,
117124
}
118125

119126
::apache::mod { $mod:
@@ -122,6 +129,7 @@
122129
lib => "mod_${mod}.so",
123130
id => $_module_id,
124131
path => "${apache::lib_path}/mod_${mod}.so",
132+
require => Exec['Configure zypper repo for SLES mod_php'],
125133
}
126134
} else {
127135
::apache::mod { $mod:

spec/setup_acceptance_node.pp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
'SLES', 'SUSE': {
88
# TEMPORARY FIX: Add fallback repo for unregistered SLES systems
99
# GCP BYOS images have zero repos configured, SUSEConnect doesn't work
10+
# Use version-appropriate repos: Leap 42.3 for SLES 12, Leap 15.6 for SLES 15
11+
if versioncmp($facts['os']['release']['major'], '15') >= 0 {
12+
$repo_url = 'http://download.opensuse.org/distribution/leap/15.6/repo/oss/'
13+
} else {
14+
# SLES 12 needs older repo with PHP 5 support
15+
$repo_url = 'http://download.opensuse.org/distribution/leap/42.3/repo/oss/'
16+
}
17+
1018
exec { 'Configure zypper repo for SLES':
1119
path => '/bin:/usr/bin:/sbin:/usr/sbin',
12-
command => 'zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/distribution/leap/15.6/repo/oss/ opensuse-leap-fallback && zypper --non-interactive --gpg-auto-import-keys refresh',
20+
command => "zypper --non-interactive --gpg-auto-import-keys ar ${repo_url} opensuse-leap-fallback && zypper --non-interactive --gpg-auto-import-keys refresh",
1321
unless => "zypper lr 2>/dev/null | grep -q 'opensuse-leap-fallback\\|http'",
1422
logoutput => true,
1523
}

0 commit comments

Comments
 (0)