From 9ff5caeacd1d7d50855bc482b243f89e6827e840 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Fri, 5 Aug 2022 09:31:26 +0200 Subject: [PATCH 01/14] installation via RVM --- .fixtures.yml | 2 ++ manifests/init.pp | 17 ++++++++++------- manifests/rvm.pp | 29 +++++++++++++++++++++++++++++ metadata.json | 12 ++++++++---- spec/classes/hdm_spec.rb | 8 ++++++++ 5 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 manifests/rvm.pp diff --git a/.fixtures.yml b/.fixtures.yml index 00aeaa8..cbc3711 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,3 +9,5 @@ fixtures: yumrepo: "puppetlabs/yumrepo_core" vcsrepo: "puppetlabs/vcsrepo" systemd: "puppet/systemd" + rvm: "puppet/rvm" + gnupg: "golja/gnupg" diff --git a/manifests/init.pp b/manifests/init.pp index ac9dcbb..b7b8322 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,10 +3,9 @@ # This class controls the installation of HDM # # @param method Select the installation method. -# Avalable methods: docker -# The puppet-ruby implenentation is not yet working. -# When using puppet-ruby we install bundler gem into -# the puppet-agent ruby installation. +# Avalable methods: docker, rvm +# When using rvm we install rvm into system and add the +# bundler gem. # # @param manage_docker Set to false if this module should NOT # also include the docker class (without any arguments) @@ -19,6 +18,9 @@ # Version is the image tag name when using docker and # the git tag when using puppet-ruby # +# @param ruby_version Select the ruby version when installing using rvm +# Please check [hdm ruby version requirement](https://github.com/betadots/hdm/blob/main/.ruby-version) +# # @param port The port where HDM should run on # # @param bind_ip The ip address to bind the process to @@ -110,9 +112,10 @@ # @example # include hdm class hdm ( - Enum['docker'] $method = 'docker', + Enum['docker', 'rvm'] $method = 'docker', Boolean $manage_docker = true, String[1] $version = 'main', + String[1] $ruby_version = '3.1.2', Stdlib::Port $port = 3000, Stdlib::IP::Address::Nosubnet $bind_ip = '0.0.0.0', String[1] $hostname = $facts['networking']['fqdn'], @@ -133,8 +136,8 @@ 'docker': { include hdm::docker } - 'puppet-ruby': { - include hdm::puppet_ruby + 'rvm': { + include hdm::rvm } default: { fail('Unknown HDM installation method.') diff --git a/manifests/rvm.pp b/manifests/rvm.pp new file mode 100644 index 0000000..59fca7b --- /dev/null +++ b/manifests/rvm.pp @@ -0,0 +1,29 @@ +# class hdm::rvm +class hdm::rvm { + group { $hdm::group: + ensure => present, + } + user { $hdm::user: + ensure => present, + shell => '/sbin/nologin', + home => $hdm::hdm_path, + gid => $hdm::group, + } + file { $hdm::hdm_path: + ensure => directory, + owner => $hdm::user, + group => $hdm::group, + } + include gnupg + include rvm + rvm::system_user { 'hdm': } + rvm_system_ruby { "ruby-${hdm::ruby_version}": + ensure => present, + default_use => false, + } + rvm_gem { 'bundler': + ensure => present, + ruby_version => "ruby-${hdm::ruby_version}", + require => Rvm_system_ruby["ruby-${hdm::ruby_version}"], + } +} diff --git a/metadata.json b/metadata.json index 0d24e4c..aacf783 100644 --- a/metadata.json +++ b/metadata.json @@ -14,14 +14,18 @@ "name": "puppetlabs/docker", "version_requirement": ">= 4.4.0 < 5.0.0" }, - { - "name": "puppetlabs/yumrepo_core", - "version_requirement": ">= 1.1.0 < 2.0.0" - }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 5.2.0 < 6.0.0" }, + { + "name": "golja/gnupg", + "version_requirement": ">= 1.2.3 < 2.0.0" + }, + { + "name": "puppet/rvm", + "version_requirement": ">= 2.0.0 < 3.0.0" + }, { "name": "puppetlabs/apt", "version_requirement": ">= 8.5.0 < 9.0.0" diff --git a/spec/classes/hdm_spec.rb b/spec/classes/hdm_spec.rb index c41842d..27916d8 100644 --- a/spec/classes/hdm_spec.rb +++ b/spec/classes/hdm_spec.rb @@ -7,6 +7,14 @@ context "on #{os} using docker" do let(:facts) { os_facts } + it { is_expected.to compile } + end + context "on #{os} using rvm" do + let(:facts) { os_facts } + let(:params) {{ + 'method' => 'rvm', + }} + it { is_expected.to compile } end end From 29e98fd68f051db36a2679e2269db80d82885609 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 10:16:06 +0200 Subject: [PATCH 02/14] use rvm for hdm installation hdm needs newer puppet version than offered by puppet. therefore we install ruby using rvm and then run the required bundle commands --- manifests/puppet_ruby.pp | 63 ------------------- manifests/rvm.pp | 49 ++++++++++++++- spec/classes/hdm_docker_spec.rb | 16 +++++ spec/classes/{hdm_spec.rb => hdm_rvm_spec.rb} | 5 -- spec/default_module_facts.yml | 2 + 5 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 manifests/puppet_ruby.pp create mode 100644 spec/classes/hdm_docker_spec.rb rename spec/classes/{hdm_spec.rb => hdm_rvm_spec.rb} (71%) create mode 100644 spec/default_module_facts.yml diff --git a/manifests/puppet_ruby.pp b/manifests/puppet_ruby.pp deleted file mode 100644 index 254ff67..0000000 --- a/manifests/puppet_ruby.pp +++ /dev/null @@ -1,63 +0,0 @@ -# @summary A short summary of the purpose of this class -# -# A description of what this class does -# -# @api private -# -# @example -# include hdm::puppet_ruby -class hdm::puppet_ruby { - package { 'bundler': - ensure => present, - provider => 'puppet_gem', - } - - group { $hdm::group: - ensure => present, - } - - user { $hdm::user: - ensure => present, - gid => $hdm::group, - shell => '/sbin/nologin', - } - - vcsrepo { $hdm::hdm_path: - ensure => present, - provider => 'git', - source => $hdm::git_url, - revision => $hdm::version, - } - - exec { 'bundle install': - command => 'bundle install --path vendor --jobs $(nproc) && touch .bundle_install_finished', - path => "${facts['path']}:/opt/puppetlabs/puppet/bin", - cwd => $hdm::hdm_path, - creates => "${hdm::hdm_path}/.bundle_install_finished", - } - - file { "${hdm::hdm_path}/config/hdm.yml": - ensure => file, - content => epp('hdm/hdm.yml.epp'), - } - - exec { 'bundle db setup': - command => 'bundle exec rails db:setup && touch .bundle_db_setup_finished', - path => "${facts['path']}:/opt/puppetlabs/puppet/bin", - cwd => $hdm::hdm_path, - creates => "${hdm::hdm_path}/.bundle_db_setup_finished", - } - - exec { 'bundle rails credentials': - command => 'echo "secret" | EDITOR="vim" bundle exec rails credentials:edit', - path => "${facts['path']}:/opt/puppetlabs/puppet/bin", - cwd => $hdm::hdm_path, - creates => "${hdm::hdm_path}/config/credentials.yml.enc", - } - - systemd::unit_file { 'hdm.service': - content => epp('hdm/hdm.service.epp'), - enable => true, - active => true, - } -} diff --git a/manifests/rvm.pp b/manifests/rvm.pp index 59fca7b..f0fc326 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -16,7 +16,9 @@ } include gnupg include rvm - rvm::system_user { 'hdm': } + rvm::system_user { 'hdm': + create => false, + } rvm_system_ruby { "ruby-${hdm::ruby_version}": ensure => present, default_use => false, @@ -26,4 +28,49 @@ ruby_version => "ruby-${hdm::ruby_version}", require => Rvm_system_ruby["ruby-${hdm::ruby_version}"], } + vcsrepo { $hdm::hdm_path: + ensure => present, + provider => 'git', + source => 'https://github.com/betadots/hdm.git', + revision => $hdm::version, + } + exec { 'bundle config path': + command => 'bundle config set --local path \'vendor/bundle\'', + cwd => $hdm::hdm_path, + path => $facts['path'], + unless => 'grep vendor/bundle .bundle/config' + } + exec { 'bundle config development': + command => 'bundle config set --local with \'development\'', + cwd => $hdm::hdm_path, + path => $facts['path'], + unless => 'grep development .bundle/config' + } + exec { 'bundle install': + command => 'bundle install --jobs $(nproc) && touch .bundle_install_finished', + cwd => $hdm::hdm_path, + path => $facts['path'], + creates => "${hdm::hdm_path}/.bundle_install_finished", + } + file { "${hdm::hdm_path}/config/hdm.yml": + ensure => file, + content => epp('hdm/hdm.yml.epp'), + } + exec { 'bundle db:setup': + command => 'bundle exec rails db:setup && touch .bundle_db_setup_finished', + cwd => $hdm::hdm_path, + path => $facts['path'], + creates => "${hdm::hdm_path}/.bundle_db_setup_finished", + } + exec { 'bundle rails credentials': + command => 'echo "secret" | EDITOR="vim" bundle exec rails credentials:edit', + cwd => $hdm::hdm_path, + path => $facts['path'], + creates => "${hdm::hdm_path}/config/credentials.yml.enc", + } + systemd::unit_file { 'hdm.service': + content => epp('hdm/hdm.service.epp'), + enable => true, + active => true, + } } diff --git a/spec/classes/hdm_docker_spec.rb b/spec/classes/hdm_docker_spec.rb new file mode 100644 index 0000000..faafa7f --- /dev/null +++ b/spec/classes/hdm_docker_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'hdm' do + on_supported_os.each do |os, os_facts| + context "on #{os} using docker" do + let(:facts) { os_facts } + let(:params) {{ + 'method' => 'docker', + }} + + it { is_expected.to compile } + end + end +end diff --git a/spec/classes/hdm_spec.rb b/spec/classes/hdm_rvm_spec.rb similarity index 71% rename from spec/classes/hdm_spec.rb rename to spec/classes/hdm_rvm_spec.rb index 27916d8..9697a2d 100644 --- a/spec/classes/hdm_spec.rb +++ b/spec/classes/hdm_rvm_spec.rb @@ -4,11 +4,6 @@ describe 'hdm' do on_supported_os.each do |os, os_facts| - context "on #{os} using docker" do - let(:facts) { os_facts } - - it { is_expected.to compile } - end context "on #{os} using rvm" do let(:facts) { os_facts } let(:params) {{ diff --git a/spec/default_module_facts.yml b/spec/default_module_facts.yml new file mode 100644 index 0000000..0a7db93 --- /dev/null +++ b/spec/default_module_facts.yml @@ -0,0 +1,2 @@ +--- +root_home: '/root' From 1a193d1e19032e1f2a2a58cad7b8ebc6edb62452 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 10:46:28 +0200 Subject: [PATCH 03/14] lint fixes --- manifests/rvm.pp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index f0fc326..8074403 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -3,71 +3,86 @@ group { $hdm::group: ensure => present, } + user { $hdm::user: ensure => present, shell => '/sbin/nologin', home => $hdm::hdm_path, gid => $hdm::group, } - file { $hdm::hdm_path: + + file { $hdm::hdm_path: ensure => directory, owner => $hdm::user, group => $hdm::group, } + include gnupg + include rvm + rvm::system_user { 'hdm': create => false, } + rvm_system_ruby { "ruby-${hdm::ruby_version}": ensure => present, default_use => false, } + rvm_gem { 'bundler': ensure => present, ruby_version => "ruby-${hdm::ruby_version}", require => Rvm_system_ruby["ruby-${hdm::ruby_version}"], } - vcsrepo { $hdm::hdm_path: + + vcsrepo { $hdm::hdm_path: ensure => present, provider => 'git', source => 'https://github.com/betadots/hdm.git', revision => $hdm::version, } + exec { 'bundle config path': command => 'bundle config set --local path \'vendor/bundle\'', cwd => $hdm::hdm_path, path => $facts['path'], - unless => 'grep vendor/bundle .bundle/config' + unless => 'grep vendor/bundle .bundle/config', } + exec { 'bundle config development': command => 'bundle config set --local with \'development\'', cwd => $hdm::hdm_path, path => $facts['path'], - unless => 'grep development .bundle/config' + unless => 'grep development .bundle/config', } + exec { 'bundle install': command => 'bundle install --jobs $(nproc) && touch .bundle_install_finished', cwd => $hdm::hdm_path, path => $facts['path'], creates => "${hdm::hdm_path}/.bundle_install_finished", } + file { "${hdm::hdm_path}/config/hdm.yml": ensure => file, content => epp('hdm/hdm.yml.epp'), } + exec { 'bundle db:setup': command => 'bundle exec rails db:setup && touch .bundle_db_setup_finished', cwd => $hdm::hdm_path, path => $facts['path'], creates => "${hdm::hdm_path}/.bundle_db_setup_finished", } + exec { 'bundle rails credentials': command => 'echo "secret" | EDITOR="vim" bundle exec rails credentials:edit', cwd => $hdm::hdm_path, path => $facts['path'], creates => "${hdm::hdm_path}/config/credentials.yml.enc", } + systemd::unit_file { 'hdm.service': content => epp('hdm/hdm.service.epp'), enable => true, From d2d2298dd96e3bb5be85ae4062cf0d0970e3e146 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 10:49:31 +0200 Subject: [PATCH 04/14] rubocop fixes --- spec/classes/hdm_docker_spec.rb | 8 +++++--- spec/classes/hdm_rvm_spec.rb | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/classes/hdm_docker_spec.rb b/spec/classes/hdm_docker_spec.rb index faafa7f..adff08d 100644 --- a/spec/classes/hdm_docker_spec.rb +++ b/spec/classes/hdm_docker_spec.rb @@ -6,9 +6,11 @@ on_supported_os.each do |os, os_facts| context "on #{os} using docker" do let(:facts) { os_facts } - let(:params) {{ - 'method' => 'docker', - }} + let(:params) do + { + 'method' => 'docker', + } + end it { is_expected.to compile } end diff --git a/spec/classes/hdm_rvm_spec.rb b/spec/classes/hdm_rvm_spec.rb index 9697a2d..77fb03a 100644 --- a/spec/classes/hdm_rvm_spec.rb +++ b/spec/classes/hdm_rvm_spec.rb @@ -6,9 +6,11 @@ on_supported_os.each do |os, os_facts| context "on #{os} using rvm" do let(:facts) { os_facts } - let(:params) {{ - 'method' => 'rvm', - }} + let(:params) do + { + 'method' => 'rvm', + } + end it { is_expected.to compile } end From f134bd41798c4670cb4fa013a5a5b8a85e77b1f1 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 11:56:25 +0200 Subject: [PATCH 05/14] use rvm prior runing bundler --- manifests/rvm.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index 8074403..7254284 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -44,21 +44,21 @@ } exec { 'bundle config path': - command => 'bundle config set --local path \'vendor/bundle\'', + command => "rvm use ${hdm::ruby_version} && bundle config set --local path 'vendor/bundle'", cwd => $hdm::hdm_path, path => $facts['path'], unless => 'grep vendor/bundle .bundle/config', } exec { 'bundle config development': - command => 'bundle config set --local with \'development\'', + command => "rvm use ${hdm::ruby_version} && bundle config set --local with 'development'", cwd => $hdm::hdm_path, path => $facts['path'], unless => 'grep development .bundle/config', } exec { 'bundle install': - command => 'bundle install --jobs $(nproc) && touch .bundle_install_finished', + command => "rvm use ${hdm::ruby_version} && bundle install --jobs $(nproc) && touch .bundle_install_finished", cwd => $hdm::hdm_path, path => $facts['path'], creates => "${hdm::hdm_path}/.bundle_install_finished", From 46eecaf3cfadfb39d04398add06c29c12222a359 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 12:03:39 +0200 Subject: [PATCH 06/14] use rvm path --- manifests/rvm.pp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index 7254284..b01f41c 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -46,21 +46,21 @@ exec { 'bundle config path': command => "rvm use ${hdm::ruby_version} && bundle config set --local path 'vendor/bundle'", cwd => $hdm::hdm_path, - path => $facts['path'], + path => "/usr/local/rvm/bin:${facts['path']}", unless => 'grep vendor/bundle .bundle/config', } exec { 'bundle config development': command => "rvm use ${hdm::ruby_version} && bundle config set --local with 'development'", cwd => $hdm::hdm_path, - path => $facts['path'], + path => "/usr/local/rvm/bin:${facts['path']}", unless => 'grep development .bundle/config', } exec { 'bundle install': command => "rvm use ${hdm::ruby_version} && bundle install --jobs $(nproc) && touch .bundle_install_finished", cwd => $hdm::hdm_path, - path => $facts['path'], + path => "/usr/local/rvm/bin:${facts['path']}", creates => "${hdm::hdm_path}/.bundle_install_finished", } @@ -70,16 +70,16 @@ } exec { 'bundle db:setup': - command => 'bundle exec rails db:setup && touch .bundle_db_setup_finished', + command => "rvm use ${hdm::ruby_version} && bundle exec rails db:setup && touch .bundle_db_setup_finished", cwd => $hdm::hdm_path, - path => $facts['path'], + path => "/usr/local/rvm/bin:${facts['path']}", creates => "${hdm::hdm_path}/.bundle_db_setup_finished", } exec { 'bundle rails credentials': - command => 'echo "secret" | EDITOR="vim" bundle exec rails credentials:edit', + command => "rvm use ${hdm::ruby_version} && echo 'secret' | EDITOR='vim' bundle exec rails credentials:edit", cwd => $hdm::hdm_path, - path => $facts['path'], + path => "/usr/local/rvm/bin:${facts['path']}", creates => "${hdm::hdm_path}/config/credentials.yml.enc", } From baf3dca6c14373ed42dbc91e6f636beab3f5d717 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:01:15 +0200 Subject: [PATCH 07/14] centos 7 needs g++ from scl --- manifests/rvm.pp | 66 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index b01f41c..0748008 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -36,6 +36,27 @@ require => Rvm_system_ruby["ruby-${hdm::ruby_version}"], } + # Fix for old g++ + case $facts['os']['family'] { + 'RedHat': { + if versioncmp($facts['os']['release']['major'], '8') < 0 { + package { 'centos-release-scl': + ensure => present, + } + + package { 'devtoolset-7': + ensure => present, + } + $exec_prefix = 'scl enable devtoolset-7 ' + } else { + $exec_prefix = '' + } + } + default: { + $exec_prefix = '' + } + } + vcsrepo { $hdm::hdm_path: ensure => present, provider => 'git', @@ -44,24 +65,27 @@ } exec { 'bundle config path': - command => "rvm use ${hdm::ruby_version} && bundle config set --local path 'vendor/bundle'", - cwd => $hdm::hdm_path, - path => "/usr/local/rvm/bin:${facts['path']}", - unless => 'grep vendor/bundle .bundle/config', + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do bundle config set --local path 'vendor/bundle'", + cwd => $hdm::hdm_path, + path => "/usr/local/rvm/bin:${facts['path']}", + unless => 'grep vendor/bundle .bundle/config', + provider => 'shell', } exec { 'bundle config development': - command => "rvm use ${hdm::ruby_version} && bundle config set --local with 'development'", - cwd => $hdm::hdm_path, - path => "/usr/local/rvm/bin:${facts['path']}", - unless => 'grep development .bundle/config', + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do bundle config set --local with 'development'", + cwd => $hdm::hdm_path, + path => "/usr/local/rvm/bin:${facts['path']}", + unless => 'grep development .bundle/config', + provider => 'shell', } exec { 'bundle install': - command => "rvm use ${hdm::ruby_version} && bundle install --jobs $(nproc) && touch .bundle_install_finished", - cwd => $hdm::hdm_path, - path => "/usr/local/rvm/bin:${facts['path']}", - creates => "${hdm::hdm_path}/.bundle_install_finished", + command => "${exec_prefix} 'source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do bundle install --jobs $(nproc) && touch .bundle_install_finished'", + cwd => $hdm::hdm_path, + path => "/usr/local/rvm/bin:${facts['path']}", + creates => "${hdm::hdm_path}/.bundle_install_finished", + provider => 'shell', } file { "${hdm::hdm_path}/config/hdm.yml": @@ -70,17 +94,19 @@ } exec { 'bundle db:setup': - command => "rvm use ${hdm::ruby_version} && bundle exec rails db:setup && touch .bundle_db_setup_finished", - cwd => $hdm::hdm_path, - path => "/usr/local/rvm/bin:${facts['path']}", - creates => "${hdm::hdm_path}/.bundle_db_setup_finished", + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do 'bundle exec rails db:setup' && touch .bundle_db_setup_finished", + cwd => $hdm::hdm_path, + path => "/usr/local/rvm/bin:${facts['path']}", + creates => "${hdm::hdm_path}/.bundle_db_setup_finished", + provider => 'shell', } exec { 'bundle rails credentials': - command => "rvm use ${hdm::ruby_version} && echo 'secret' | EDITOR='vim' bundle exec rails credentials:edit", - cwd => $hdm::hdm_path, - path => "/usr/local/rvm/bin:${facts['path']}", - creates => "${hdm::hdm_path}/config/credentials.yml.enc", + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do \"echo 'secret' | EDITOR='vim' bundle exec rails credentials:edit\"", + cwd => $hdm::hdm_path, + path => "/usr/local/rvm/bin:${facts['path']}", + creates => "${hdm::hdm_path}/config/credentials.yml.enc", + provider => 'shell', } systemd::unit_file { 'hdm.service': From b44710bbaab65f2d36e86f3c07315d7bda18dfbd Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:22:37 +0200 Subject: [PATCH 08/14] centos 7 needs newer sqlite --- manifests/rvm.pp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index 0748008..732dc5a 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -36,7 +36,7 @@ require => Rvm_system_ruby["ruby-${hdm::ruby_version}"], } - # Fix for old g++ + # Fix for old g++ and sqlite3 case $facts['os']['family'] { 'RedHat': { if versioncmp($facts['os']['release']['major'], '8') < 0 { @@ -48,6 +48,16 @@ ensure => present, } $exec_prefix = 'scl enable devtoolset-7 ' + package { 'sqlite-devel': + ensure => '3.8.11', + source => 'https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm', + provider => 'rpm', + } + package { 'sqlite': + ensure => '3.8.11', + source => 'https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm', + provider => 'rpm', + } } else { $exec_prefix = '' } @@ -94,7 +104,7 @@ } exec { 'bundle db:setup': - command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do 'bundle exec rails db:setup' && touch .bundle_db_setup_finished", + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do bundle exec rails db:setup && touch .bundle_db_setup_finished", cwd => $hdm::hdm_path, path => "/usr/local/rvm/bin:${facts['path']}", creates => "${hdm::hdm_path}/.bundle_db_setup_finished", From a87e66cb424c88fe1cab12e5042011520496b41b Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:30:25 +0200 Subject: [PATCH 09/14] sqlite updating needs exec --- manifests/rvm.pp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index 732dc5a..eb8c1ff 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -48,15 +48,10 @@ ensure => present, } $exec_prefix = 'scl enable devtoolset-7 ' - package { 'sqlite-devel': - ensure => '3.8.11', - source => 'https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm', - provider => 'rpm', - } - package { 'sqlite': - ensure => '3.8.11', - source => 'https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm', - provider => 'rpm', + exec { 'update sqlite': + command => 'yum install -y https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm', + path => $facts['path'], + unless => 'rpm -q sqlite | grep 3.8', } } else { $exec_prefix = '' From 7c5ffbac5822d6c9d8efb9d80a96c83a3a410a50 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:32:43 +0200 Subject: [PATCH 10/14] fix rvm do call --- manifests/rvm.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/rvm.pp b/manifests/rvm.pp index eb8c1ff..5505e52 100644 --- a/manifests/rvm.pp +++ b/manifests/rvm.pp @@ -107,7 +107,7 @@ } exec { 'bundle rails credentials': - command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do \"echo 'secret' | EDITOR='vim' bundle exec rails credentials:edit\"", + command => "source $(rvm ${hdm::ruby_version} do rvm env --path) && rvm ${hdm::ruby_version} do echo 'secret' | EDITOR='vim' bundle exec rails credentials:edit", cwd => $hdm::hdm_path, path => "/usr/local/rvm/bin:${facts['path']}", creates => "${hdm::hdm_path}/config/credentials.yml.enc", From 185f6164d3ccf0fb1069d7d9829a0ace3b81dc3a Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:41:17 +0200 Subject: [PATCH 11/14] add rvm to systemd unit file --- templates/hdm.service.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/hdm.service.epp b/templates/hdm.service.epp index 5275bbf..63c61d4 100644 --- a/templates/hdm.service.epp +++ b/templates/hdm.service.epp @@ -7,8 +7,8 @@ Type=simple User=<%= $hdm::user %> Group=<%= $hdm::group %> WorkingDirectory=<%= $hdm::hdm_path %> -# ExecStart=/bin/bash -lc 'bundle exec rails server -e production --bind 0.0.0.0 --port 80' -ExecStart=/bin/bash -lc 'bundle exec rails server -b <%= $hdm::bind_ip %> -p <%= $hdm::port %>' +Environment="PATH=/usr/local/rvm/bin:<%= $facts['path'] %>" +ExecStart=/bin/bash -lc 'source $(rvm <%= $hdm::ruby_version %> do rvm env --path) && bundle exec rails server -b <%= $hdm::bind_ip %> -p <%= $hdm::port %>' TimeoutSec=30 RestartSec=15s Restart=always From 041aa266ea285e077791a9de80648b28ba248104 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:47:31 +0200 Subject: [PATCH 12/14] set systemd env --- templates/hdm.service.epp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/hdm.service.epp b/templates/hdm.service.epp index 63c61d4..6d10066 100644 --- a/templates/hdm.service.epp +++ b/templates/hdm.service.epp @@ -4,10 +4,12 @@ Requires=network.target [Service] Type=simple -User=<%= $hdm::user %> -Group=<%= $hdm::group %> +#User=<%= $hdm::user %> +#Group=<%= $hdm::group %> +User=root +Group=root WorkingDirectory=<%= $hdm::hdm_path %> -Environment="PATH=/usr/local/rvm/bin:<%= $facts['path'] %>" +Environment="PATH=/usr/local/rvm/bin:<%= $facts['path'] %>,RAILS_DEVELOPMENT_HOSTS=<%= ${hdm::hostname} %>" ExecStart=/bin/bash -lc 'source $(rvm <%= $hdm::ruby_version %> do rvm env --path) && bundle exec rails server -b <%= $hdm::bind_ip %> -p <%= $hdm::port %>' TimeoutSec=30 RestartSec=15s From 8193b0ac4979677ac55bb8859e46d05d541be636 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:50:59 +0200 Subject: [PATCH 13/14] set systemd env --- templates/hdm.service.epp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/hdm.service.epp b/templates/hdm.service.epp index 6d10066..dcb8e15 100644 --- a/templates/hdm.service.epp +++ b/templates/hdm.service.epp @@ -9,7 +9,8 @@ Type=simple User=root Group=root WorkingDirectory=<%= $hdm::hdm_path %> -Environment="PATH=/usr/local/rvm/bin:<%= $facts['path'] %>,RAILS_DEVELOPMENT_HOSTS=<%= ${hdm::hostname} %>" +Environment="PATH=/usr/local/rvm/bin:<%= $facts['path'] %>" +Environment="RAILS_DEVELOPMENT_HOSTS=<%= $hdm::hostname %>" ExecStart=/bin/bash -lc 'source $(rvm <%= $hdm::ruby_version %> do rvm env --path) && bundle exec rails server -b <%= $hdm::bind_ip %> -p <%= $hdm::port %>' TimeoutSec=30 RestartSec=15s From 69268e757e7d9e7bae12442a7c51ad7b5f7d2586 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 8 Aug 2022 13:56:51 +0200 Subject: [PATCH 14/14] add .with_all_deps to spec tests --- spec/classes/hdm_docker_spec.rb | 2 +- spec/classes/hdm_rvm_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/hdm_docker_spec.rb b/spec/classes/hdm_docker_spec.rb index adff08d..df45797 100644 --- a/spec/classes/hdm_docker_spec.rb +++ b/spec/classes/hdm_docker_spec.rb @@ -12,7 +12,7 @@ } end - it { is_expected.to compile } + it { is_expected.to compile.with_all_deps } end end end diff --git a/spec/classes/hdm_rvm_spec.rb b/spec/classes/hdm_rvm_spec.rb index 77fb03a..fa3acc6 100644 --- a/spec/classes/hdm_rvm_spec.rb +++ b/spec/classes/hdm_rvm_spec.rb @@ -12,7 +12,7 @@ } end - it { is_expected.to compile } + it { is_expected.to compile.with_all_deps } end end end