Skip to content

Commit 835ff77

Browse files
treydockjohrstrom
andauthored
Support Ubuntu 20.04 packages with OnDemand 2.0 (#2141)
* Support Ubuntu 20.04 packages * Use 2.0 release package to bootstrap E2E tests * Backport Ubuntu support into ood-portal-generator * Backport htcacheclean restart removal * Ensure /opt/ood/ondemand/enable is loaded by Ubuntu packaged OnDemand * Also handle doc labels for release branches * Bump ood_packaging dependency * Run update_ood_portal during postinst to avoid changing config files during postinst that are also part of package * Update beaker-docker dependency * Do not install package or test gems * Fix logic to avoid issues when re-running tests * Support Ubuntu with nginx_stage * rnode location edits account for relative paths (#1934) Enable rnode location edits account for relative paths because they broke in apache 2.4. This has the explicit group for them now. Co-authored-by: Jeff Ohrstrom <johrstrom@osc.edu>
1 parent 5c11c00 commit 835ff77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+717
-126
lines changed

.github/workflows/document-merge.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- master
88
- 'feature/**'
9+
- 'release_**'
910
types: [closed]
1011

1112
jobs:

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
strategy:
7979
fail-fast: false
8080
matrix:
81-
dist: ["el7", "el8"]
81+
dist: ["el7", "el8", "ubuntu-20.04"]
8282
version: ["2.0"]
8383
runs-on: "ubuntu-latest"
8484
name: E2E test ${{ matrix.dist }} (ondemand-${{ matrix.version }})

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ build:
2020
- bundle exec rake package:build[$OOD_PACKAGING_DIST]
2121
parallel:
2222
matrix:
23-
- OOD_PACKAGING_DIST: [el7, el8]
23+
- OOD_PACKAGING_DIST: [el7, el8, ubuntu-20.04]
2424
artifacts:
2525
paths:
2626
- dist

Gemfile

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
66

77
gem "rake"
88
gem "bcrypt"
9+
gem 'dotenv', '~> 2.1'
910

1011
group :package do
11-
gem 'ood_packaging', '0.0.1.r2.0'
12+
gem 'ood_packaging', '0.0.2.r2.0'
1213
end
1314

1415
group :test do
@@ -18,8 +19,5 @@ group :test do
1819

1920
gem "beaker"
2021
gem "beaker-rspec"
21-
# Use fork until merged and released
22-
# https://github.com/voxpupuli/beaker-docker/pull/53
23-
# https://github.com/voxpupuli/beaker-docker/pull/54
24-
gem "beaker-docker", git: 'https://github.com/treydock/beaker-docker.git', branch: 'osc'
22+
gem "beaker-docker", '~> 1.1.1'
2523
end

Gemfile.lock

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
GIT
2-
remote: https://github.com/treydock/beaker-docker.git
3-
revision: a4c8f255db29903ada6e780872fd873bbf93303c
4-
branch: osc
5-
specs:
6-
beaker-docker (1.0.0)
7-
docker-api (~> 2.1)
8-
stringify-hash (~> 0.0.0)
9-
101
GEM
112
remote: https://rubygems.org/
123
specs:
134
ansi (1.5.0)
145
ast (2.4.2)
156
bcrypt (3.1.16)
16-
beaker (4.30.0)
7+
beaker (4.37.0)
178
beaker-hostgenerator
9+
ed25519 (~> 1.0)
1810
hocon (~> 1.0)
1911
in-parallel (~> 0.1)
2012
inifile (~> 3.0)
@@ -36,9 +28,12 @@ GEM
3628
hocon (~> 1.0)
3729
require_all (>= 1.3.2, < 3.1.0)
3830
stringify-hash (~> 0.0.0)
39-
beaker-hostgenerator (1.5.0)
40-
deep_merge (~> 1.0)
31+
beaker-docker (1.1.1)
32+
beaker (>= 4.34)
33+
docker-api (~> 2.1)
4134
stringify-hash (~> 0.0.0)
35+
beaker-hostgenerator (1.16.0)
36+
deep_merge (~> 1.0)
4237
beaker-pe (2.11.13)
4338
beaker (~> 4.0)
4439
beaker-abs
@@ -65,12 +60,14 @@ GEM
6560
colorize (0.8.1)
6661
commander (4.6.0)
6762
highline (~> 2.0.0)
68-
deep_merge (1.2.1)
63+
deep_merge (1.2.2)
6964
diff-lcs (1.4.4)
7065
docker-api (2.2.0)
7166
excon (>= 0.47.0)
7267
multi_json
73-
excon (0.85.0)
68+
dotenv (2.7.6)
69+
ed25519 (1.3.0)
70+
excon (0.92.3)
7471
faraday (1.7.0)
7572
faraday-em_http (~> 1.0)
7673
faraday-em_synchrony (~> 1.0)
@@ -96,17 +93,17 @@ GEM
9693
inifile (3.0.0)
9794
method_source (1.0.0)
9895
minitar (0.9)
99-
minitest (5.14.4)
96+
minitest (5.16.2)
10097
multi_json (1.15.0)
10198
multipart-post (2.1.1)
102-
net-scp (3.0.0)
103-
net-ssh (>= 2.6.5, < 7.0.0)
104-
net-ssh (6.1.0)
99+
net-scp (1.2.1)
100+
net-ssh (>= 2.6.5)
101+
net-ssh (7.0.1)
105102
net-telnet (0.1.1)
106103
oga (3.3)
107104
ast
108105
ruby-ll (~> 2.1)
109-
ood_packaging (0.0.1.r2.0)
106+
ood_packaging (0.0.2.r2.0)
110107
rake (~> 13.0.1)
111108
open_uri_redirections (0.2.1)
112109
parallel (1.20.1)
@@ -173,7 +170,7 @@ GEM
173170
net-telnet (= 0.1.1)
174171
sfl
175172
stringify-hash (0.0.2)
176-
thor (1.1.0)
173+
thor (1.2.1)
177174
unicode-display_width (2.0.0)
178175
vmfloaty (1.4.0)
179176
colorize (~> 0.8.1)
@@ -189,9 +186,10 @@ PLATFORMS
189186
DEPENDENCIES
190187
bcrypt
191188
beaker
192-
beaker-docker!
189+
beaker-docker (~> 1.1.1)
193190
beaker-rspec
194-
ood_packaging (= 0.0.1.r2.0)
191+
dotenv (~> 2.1)
192+
ood_packaging (= 0.0.2.r2.0)
195193
rake
196194
rspec
197195
rubocop

Rakefile

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ PROJ_DIR = Pathname.new(__dir__)
55
TASK_DIR = "#{PROJ_DIR}/lib/tasks"
66
APPS_DIR = PROJ_DIR.join('apps')
77
GEMFILE = PROJ_DIR.join('Gemfile')
8-
INSTALL_ROOT = Pathname.new(ENV["PREFIX"] || "/opt/ood")
8+
DESTDIR = Pathname.new(ENV['DESTDIR'].to_s)
9+
INSTALL_ROOT = Pathname.new(ENV["PREFIX"] || "#{DESTDIR}/opt/ood")
910
VENDOR_BUNDLE = (ENV['VENDOR_BUNDLE'] == "yes" || ENV['VENDOR_BUNDLE'] == "true")
1011
PASSENGER_APP_ENV = ENV["PASSENGER_APP_ENV"] || "production"
1112

1213
require "#{TASK_DIR}/rake_helper"
14+
require "#{TASK_DIR}/build_utils"
1315
require "#{TASK_DIR}/packaging"
1416
require "#{TASK_DIR}/test"
1517
require "#{TASK_DIR}/lint"
1618
require "#{TASK_DIR}/docker"
1719
require "#{TASK_DIR}/development"
1820

1921
include RakeHelper
22+
include BuildUtils
2023

2124
namespace :build do
2225
desc "Build gems"
@@ -77,8 +80,20 @@ namespace :install do
7780
sh "cp -r #{APPS_DIR} #{INSTALL_ROOT}/"
7881
end
7982

83+
namespace :infrastructure do
84+
desc 'Install infrastructure files'
85+
task :files do
86+
infrastructure_files.each do |file|
87+
src = render_package_file(file[:src])
88+
FileUtils.mkdir_p(File.dirname(file[:dest]), verbose: true) unless Dir.exist?(File.dirname(file[:dest]))
89+
FileUtils.cp(src, file[:dest], verbose: true)
90+
FileUtils.chmod(file[:mode], file[:dest], verbose: true)
91+
end
92+
end
93+
end
94+
8095
desc "Install OnDemand infrastructure and apps"
81-
task :all => [:infrastructure, :apps]
96+
task :all => [:infrastructure, :apps, 'infrastructure:files']
8297
end
8398

8499
desc "Install OnDemand"

lib/tasks/build_utils.rb

+108
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# frozen_string_literal: true
2+
require 'erb'
3+
require 'dotenv'
4+
require 'tempfile'
25

36
module BuildUtils
47
def proj_root
@@ -69,4 +72,109 @@ def image_name
6972
def user
7073
@user ||= Etc.getpwnam(Etc.getlogin)
7174
end
75+
76+
def os_release
77+
@os_release ||= begin
78+
if File.exist?('/etc/os-release')
79+
Dotenv.parse('/etc/os-release')
80+
else
81+
{}
82+
end
83+
end
84+
end
85+
86+
def scl_apache?
87+
return true if (el? && os_release['VERSION_ID'] =~ /^7/)
88+
false
89+
end
90+
91+
def el?
92+
return true if "#{os_release['ID']} #{os_release['ID_LIKE']}" =~ /(rhel|fedora)/
93+
false
94+
end
95+
96+
def debian?
97+
return true if (os_release['ID'] =~ /(ubuntu|debian)/ or os_release['ID_LIKE'] == 'debian')
98+
false
99+
end
100+
101+
def apache_daemon
102+
return '/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper' if scl_apache?
103+
"/usr/sbin/#{apache_service}"
104+
end
105+
106+
def apache_reload
107+
return '/usr/sbin/apachectl graceful' if debian?
108+
"#{apache_daemon} $OPTIONS -k graceful"
109+
end
110+
111+
def apache_user
112+
return 'www-data' if debian?
113+
'apache'
114+
end
115+
116+
def apache_service
117+
return 'apache2' if debian?
118+
return 'httpd24-httpd' if scl_apache?
119+
'httpd'
120+
end
121+
122+
def infrastructure_files
123+
@infrastructure_files ||= [
124+
{
125+
src: 'apache-systemd.ood-portal.conf.erb',
126+
dest: File.join(DESTDIR, "etc/systemd/system/#{apache_service}.service.d/ood-portal.conf"),
127+
mode: 0444,
128+
},
129+
{
130+
src: 'apache-systemd.ood.conf',
131+
dest: File.join(DESTDIR, "etc/systemd/system/#{apache_service}.service.d/ood.conf"),
132+
mode: 0444,
133+
},
134+
{
135+
src: 'crontab',
136+
dest: File.join(DESTDIR, 'etc/cron.d/ood'),
137+
mode: 0644,
138+
},
139+
{
140+
src: 'favicon.ico',
141+
dest: File.join(DESTDIR, 'var/www/ood/public/favicon.ico'),
142+
mode: 0644,
143+
},
144+
{
145+
src: 'logo.png',
146+
dest: File.join(DESTDIR, 'var/www/ood/public/logo.png'),
147+
mode: 0644,
148+
},
149+
{
150+
src: 'logrotate',
151+
dest: File.join(DESTDIR, 'etc/logrotate.d/ood'),
152+
mode: 0644,
153+
},
154+
{
155+
src: 'ondemand-nginx-tmpfiles',
156+
dest: File.join(DESTDIR, 'usr/lib/tmpfiles.d/ondemand-nginx.conf'),
157+
mode: 0644,
158+
},
159+
{
160+
src: 'sudo.erb',
161+
dest: File.join(DESTDIR, 'etc/sudoers.d/ood'),
162+
mode: 0440,
163+
},
164+
]
165+
end
166+
167+
def render_package_file(name)
168+
src = File.join(proj_root, 'packaging/files', name)
169+
return src unless File.extname(name) == '.erb'
170+
171+
content = ERB.new(File.read(src), nil, '-').result(binding)
172+
begin
173+
t = Tempfile.new(name)
174+
t.write(content)
175+
t.path
176+
ensure
177+
t.close
178+
end
179+
end
72180
end

lib/tasks/packaging.rb

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
require_relative 'build_utils'
55
include BuildUtils
66

7+
task :version do
8+
puts ood_package_version
9+
end
10+
711
def image_exists?(image_name)
812
`#{container_runtime} inspect --type image --format exists #{image_name} || true`.chomp.eql?('exists')
913
end

nginx_stage/etc/profile

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
#
99
SCL_PKGS=${SCL_PKGS:-"ondemand"}
1010
SCL_SOURCE="$(command -v scl_source)"
11-
[[ "${SCL_SOURCE}" ]] && source "${SCL_SOURCE}" enable ${SCL_PKGS}
11+
DEB_SOURCE="/opt/ood/ondemand/enable"
12+
if [[ "${SCL_SOURCE}" ]]; then
13+
source "${SCL_SOURCE}" enable ${SCL_PKGS}
14+
else
15+
[[ -e "${DEB_SOURCE}" ]] && source "${DEB_SOURCE}" || :
16+
fi

nginx_stage/lib/nginx_stage/configuration.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'yaml'
22
require 'etc'
33
require 'pathname'
4+
require 'dotenv'
45

56
module NginxStage
67
# An object that stores the configuration options to control NginxStage's
@@ -419,7 +420,11 @@ def set_default_configuration
419420
self.ondemand_title = nil
420421
self.template_root = "#{root}/templates"
421422

422-
self.proxy_user = 'apache'
423+
if debian?
424+
self.proxy_user = 'www-data'
425+
else
426+
self.proxy_user = 'apache'
427+
end
423428
self.nginx_bin = '/opt/ood/ondemand/root/usr/sbin/nginx'
424429
self.nginx_signals = %i(stop quit reopen reload)
425430
self.mime_types_path = '/opt/ood/ondemand/root/etc/nginx/mime.types'
@@ -508,6 +513,12 @@ def read_configuration(file)
508513
end
509514
end
510515

516+
def debian?
517+
env = Dotenv.parse('/etc/os-release')
518+
return true if (env['ID'] =~ /(ubuntu|debian)/ or env['ID_LIKE'] == 'debian')
519+
false
520+
end
521+
511522
private
512523
# Recursively symbolize keys in hash
513524
def symbolize(obj)

nginx_stage/nginx_stage.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
1818
spec.require_paths = ["lib"]
1919

2020
spec.add_dependency "syslog", "~> 0.1.0"
21+
spec.add_dependency 'dotenv', '~> 2.1'
2122

2223
spec.add_development_dependency "bundler", "~> 2.1.0"
2324
spec.add_development_dependency "rake", "~> 13.0.1"

0 commit comments

Comments
 (0)