Skip to content

Commit

Permalink
Changes for OpenVox
Browse files Browse the repository at this point in the history
  • Loading branch information
nmburgan committed Jan 16, 2025
1 parent eaeade4 commit 7c51624
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "ruby/puppet"]
path = ruby/puppet
url = https://github.com/puppetlabs/puppet.git
url = https://github.com/openvoxproject/puppet.git
[submodule "ruby/hiera"]
path = ruby/hiera
url = https://github.com/puppetlabs/hiera.git
url = https://github.com/openvoxproject/hiera.git
[submodule "ruby/resource_api"]
path = ruby/resource_api
url = https://github.com/puppetlabs/puppet-resource_api.git
url = https://github.com/openvoxproject/puppet-resource_api.git
[submodule "ruby/facter"]
path = ruby/facter
url = https://github.com/puppetlabs/facter.git
url = https://github.com/openvoxproject/facter.git
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM almalinux:9

WORKDIR /

RUN dnf install -y --enablerepo=crb vim wget git rpm-build java-11-openjdk java-11-openjdk-devel libyaml-devel zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel
RUN wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
RUN chmod a+x lein
RUN mv lein /usr/local/bin
RUN wget -q https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer -O- | bash
RUN /bin/bash --login -c 'rbenv install 3.2.6'
RUN /bin/bash --login -c 'rbenv global 3.2.6'
RUN git config --global user.email "[email protected]"
RUN git config --global user.name "Vox Pupuli"

CMD ["tail -f /dev/null"]
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source ENV['GEM_SOURCE'] || 'https://artifactory.delivery.puppetlabs.net/artifactory/api/gems/rubygems/'
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

def location_for(place, fake_version = nil)
if place.is_a?(String) && place =~ /^(git[:@][^#]*)#(.*)/
Expand All @@ -22,7 +22,9 @@ group :test do
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 2.4")
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 1.0")
gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1.3")
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4.0")
# This needs to be updated so it doesn't require Ruby < 3.2. Just to get things building,
# I'm disabling it for now. - Nick
#gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4.0")
gem 'uuidtools'
gem 'httparty'
gem 'master_manipulator'
Expand Down
17 changes: 17 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
require 'open3'

def run_command(cmd)
output = ''
Open3.popen2e(cmd) do |_stdin, stdout_stderr, thread|
stdout_stderr.each do |line|
puts line
output += line
end
exitcode = thread.value.exitstatus
abort "Command failed!" unless exitcode.zero?
end
output.chomp
end

Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file }

### puppetlabs stuff ###
require 'open-uri'
require 'json'
require 'pp'
Expand Down
9 changes: 5 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
default-heap-size))

(defproject puppetlabs/puppetserver ps-version
:description "Puppet Server"
:description "OpenVox Server"

:license {:name "Apache License, Version 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
Expand Down Expand Up @@ -96,13 +96,14 @@
:group "puppet"
:numeric-uid-gid 52
:build-type "foss"
:package-name "openvox-server"
:puppet-platform-version 8
:java-args ~(str "-Xms2g -Xmx2g "
"-Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger")
:create-dirs ["/opt/puppetlabs/server/data/puppetserver/jars"
"/opt/puppetlabs/server/data/puppetserver/yaml"]
:repo-target "puppet8"
:nonfinal-repo-target "puppet8-nightly"
:repo-target "openvox8"
:nonfinal-repo-target "openvox8-nightly"
:bootstrap-source :services-d
:logrotate-enabled false}
:resources {:dir "tmp/ezbake-resources"}
Expand Down Expand Up @@ -176,7 +177,7 @@
[puppetlabs/puppetserver ~ps-version]
[com.puppetlabs/trapperkeeper-webserver-jetty10]
[puppetlabs/trapperkeeper-metrics]]
:plugins [[puppetlabs/lein-ezbake "2.6.2"]]
:plugins [[puppetlabs/lein-ezbake "2.6.3-SNAPSHOT-openvox"]]
:name "puppetserver"}
:uberjar {:dependencies [[org.bouncycastle/bcpkix-jdk18on]
[com.puppetlabs/trapperkeeper-webserver-jetty10]]
Expand Down
6 changes: 3 additions & 3 deletions resources/ext/ezbake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ezbake: {
pe: {}
foss: {
redhat: { dependencies: ["puppet-agent >= 6.16.0"],
redhat: { dependencies: ["openvox-agent >= 8.11.0"],
build-dependencies: ["%{open_jdk}"],
# Install some gems
install: [
Expand Down Expand Up @@ -35,8 +35,8 @@ ezbake: {
]
}

debian: { dependencies: ["puppet-agent (>= 6.16.0)"],
build-dependencies: ["openjdk-8-jre-headless"],
debian: { dependencies: ["openvox-agent (>= 8.11.0)"],
build-dependencies: ["openjdk-11-jre-headless"],
# Install some gems
install: [
"bash ./ext/build-scripts/install-vendored-gems.sh"
Expand Down
1 change: 0 additions & 1 deletion ruby/facter
Submodule facter deleted from 543b96
1 change: 0 additions & 1 deletion ruby/hiera
Submodule hiera deleted from 6a2687
1 change: 0 additions & 1 deletion ruby/puppet
Submodule puppet deleted from d2f3cd
1 change: 0 additions & 1 deletion ruby/resource_api
Submodule resource_api deleted from 87b4bf
76 changes: 76 additions & 0 deletions tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require 'fileutils'

@image = 'ezbake-builder'
@container = 'openvox-server-builder'
@timestamp = Time.now.strftime('%Y%m%d_%H%M%S')
# It seems like these are special files/names that, when you want to add a new one, require
# changes in some other component. But no, it seems to only really look at the parts of
# the text in the string, as long as it looks like "base-<whatever you want to call the platform>-i386.cow"
# and "<doesn't matter>-<os>-<osver>-<arch which doesn't matter because it's actually noarch>".
# I think it just treats all debs like Debian these days. And all rpms are similar.
# So do whatever you want I guess. We really don't need separate packages for each platform.
# To be fixed one of these days. Relevant stuff:
# https://github.com/puppetlabs/ezbake/blob/aeb7735a16d2eecd389a6bd9e5c0cfc7c62e61a5/resources/puppetlabs/lein-ezbake/template/global/tasks/build.rake
# https://github.com/puppetlabs/ezbake/blob/aeb7735a16d2eecd389a6bd9e5c0cfc7c62e61a5/resources/puppetlabs/lein-ezbake/template/global/ext/fpm.rb
@debs = "base-ubuntu18.04-i386.cow base-ubuntu20.04-i386.cow base-ubuntu22.04-i386.cow base-ubuntu24.04-i386.cow base-debian10-i386.cow base-debian11-i386.cow base-debian12-i386.cow"
@rpms = "pl-el-7-x86_64 pl-el-8-x86_64 pl-el-9-x86_64 pl-el-10-x86_64 pl-sles-15-x86_64"

def image_exists
!`docker images -q #{@image}`.strip.empty?
end

def container_exists
!`docker container ls --all --filter 'name=#{@container}' --format json`.strip.empty?
end

def teardown
if container_exists
puts "Stopping #{@container}"
run_command("docker stop #{@container}")
run_command("docker rm #{@container}")
end
end

def start_container(ezbake_dir)
run_command("docker run -d --name #{@container} -v .:/code -v #{ezbake_dir}:/ezbake #{@image} /bin/sh -c 'tail -f /dev/null'")
end

def run(cmd)
puts "\033[32mRunning #{cmd}\033[0m"
run_command("docker exec #{@container} /bin/bash --login -c '#{cmd}'")
end

namespace :vox do
desc 'Build openvox-server packages with Docker'
task :build do |_, _args|
begin
# If the Dockerfile has changed since this was last built,
# delete all containers and do `docker rmi ezbake-builder`
unless image_exists
puts "Building ezbake-builder image"
run_command("docker build -t ezbake-builder .")
end

puts "Checking out ezbake"
tmp = Dir.mktmpdir("ezbake")
ezbake_dir = "#{tmp}/ezbake"
run_command("git clone https://github.com/openvoxproject/ezbake #{ezbake_dir}")
Dir.chdir(ezbake_dir) { |_| run_command('git checkout main') }
#FileUtils.cp_r("../ezbake", ezbake_dir)

puts "Starting container"
teardown if container_exists
start_container(ezbake_dir)

puts "Installing ezbake from source"
run("cd /ezbake && lein install")

puts "Building openvox-server"
run("cd /code && rm -rf ruby && rm -rf output && bundle install --without test && lein install")
run("cd /code && COW=\"#{@debs}\" MOCK=\"#{@rpms}\" GEM_SOURCE='https://rubygems.org' EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile user,ezbake,provided,internal ezbake local-build")
run("find /code/output -type d -name \"*i386*\" -exec rm -rf {} +")
ensure
teardown
end
end
end

0 comments on commit 7c51624

Please sign in to comment.