From 7c51624658f8e3307b5fe6f2c8e2449aea1dad25 Mon Sep 17 00:00:00 2001 From: nmburgan <13688219+nmburgan@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:23:14 -0800 Subject: [PATCH] Changes for OpenVox --- .gitmodules | 8 ++--- Dockerfile | 15 ++++++++ Gemfile | 6 ++-- Rakefile | 17 +++++++++ project.clj | 9 ++--- resources/ext/ezbake.conf | 6 ++-- ruby/facter | 1 - ruby/hiera | 1 - ruby/puppet | 1 - ruby/resource_api | 1 - tasks/build.rake | 76 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 Dockerfile delete mode 160000 ruby/facter delete mode 160000 ruby/hiera delete mode 160000 ruby/puppet delete mode 160000 ruby/resource_api create mode 100644 tasks/build.rake diff --git a/.gitmodules b/.gitmodules index c2c3c326f..8a8ca77a3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..6c5146165 --- /dev/null +++ b/Dockerfile @@ -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 "openvox@voxpupuli.org" +RUN git config --global user.name "Vox Pupuli" + +CMD ["tail -f /dev/null"] \ No newline at end of file diff --git a/Gemfile b/Gemfile index d88542885..e2a039f9e 100644 --- a/Gemfile +++ b/Gemfile @@ -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[:@][^#]*)#(.*)/ @@ -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' diff --git a/Rakefile b/Rakefile index ef927805c..409d347c9 100644 --- a/Rakefile +++ b/Rakefile @@ -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' diff --git a/project.clj b/project.clj index dacada43f..8a849d380 100644 --- a/project.clj +++ b/project.clj @@ -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"} @@ -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"} @@ -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]] diff --git a/resources/ext/ezbake.conf b/resources/ext/ezbake.conf index 52fa01d51..568e323f3 100644 --- a/resources/ext/ezbake.conf +++ b/resources/ext/ezbake.conf @@ -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: [ @@ -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" diff --git a/ruby/facter b/ruby/facter deleted file mode 160000 index 543b962a8..000000000 --- a/ruby/facter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 543b962a8173eddc41e3d7a54515e4562f86a0a1 diff --git a/ruby/hiera b/ruby/hiera deleted file mode 160000 index 6a2687cf9..000000000 --- a/ruby/hiera +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a2687cf93c2efe4969df328b151edee29d1bd7a diff --git a/ruby/puppet b/ruby/puppet deleted file mode 160000 index d2f3cd52e..000000000 --- a/ruby/puppet +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d2f3cd52eecdca2243190a7c1ecf8fd55a02d143 diff --git a/ruby/resource_api b/ruby/resource_api deleted file mode 160000 index 87b4bf5c7..000000000 --- a/ruby/resource_api +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 87b4bf5c7fdf70cd1b15e565c74634a7d7826004 diff --git a/tasks/build.rake b/tasks/build.rake new file mode 100644 index 000000000..ef9348872 --- /dev/null +++ b/tasks/build.rake @@ -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--i386.cow" +# and "---". +# 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 \ No newline at end of file