From af0c9fa4803790ee41e998127827a91157fff597 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Fri, 30 May 2025 17:29:35 -0400 Subject: [PATCH] Enable IoP Signed-off-by: Eric D. Helms --- .fixtures.yml | 5 +++++ manifests/bundle.pp | 5 ++++- manifests/database.pp | 4 ++-- manifests/init.pp | 9 ++++++++ manifests/iop.pp | 39 +++++++++++++++++++++++++++++++++++ manifests/setup.pp | 6 +++++- spec/acceptance/iop_spec.rb | 16 ++++++++++++++ spec/setup_acceptance_node.pp | 9 ++++++++ 8 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 manifests/iop.pp create mode 100644 spec/acceptance/iop_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index f50e0b7..9a288ee 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -26,3 +26,8 @@ fixtures: puppet_version: '>= 6.0.0' systemd: "https://github.com/camptocamp/puppet-systemd" rhsm: "https://github.com/voxpupuli/puppet-rhsm" + podman: + repo: 'https://github.com/ehelms/puppet-podman' + branch: 'allow-disabled-quadlet' + iop: "https://github.com/ehelms/puppet-iop" + hashfile: "https://github.com/southalc/hashfile" diff --git a/manifests/bundle.pp b/manifests/bundle.pp index 4457cc2..d694d78 100644 --- a/manifests/bundle.pp +++ b/manifests/bundle.pp @@ -6,9 +6,12 @@ String $user = $katello_devel::user, Stdlib::Absolutepath $cwd = $katello_devel::foreman_dir, Integer[0] $timeout = 600, + Optional[String] $command = undef, ) { + $bundle_command = pick($command, $title) + exec { "bundle-${title}": - command => "bundle ${title}", + command => "bundle ${bundle_command}", environment => $environment + ["HOME=/home/${user}"], cwd => $cwd, user => $user, diff --git a/manifests/database.pp b/manifests/database.pp index a406b10..2da886d 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -38,7 +38,7 @@ database => 'all', user => 'all', address => '127.0.0.1/32', - order => 2, + order => 4, auth_method => 'trust', } @@ -47,7 +47,7 @@ database => 'all', user => 'all', address => '::1/128', - order => 3, + order => 5, auth_method => 'trust', } diff --git a/manifests/init.pp b/manifests/init.pp index c0127da..11706b7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,6 +73,10 @@ # # @param rails_cache_store # Manage the type of cache used for Rails, default is Redis. +# +# @param enable_iop +# Enable iop integration +# class katello_devel ( String $user = undef, Stdlib::Absolutepath $deployment_dir = '/home/vagrant', @@ -98,6 +102,7 @@ Boolean $katello_manage_repo = true, Boolean $rex_manage_repo = true, Hash[String, Any] $rails_cache_store = { 'type' => 'redis' }, + Boolean $enable_iop = false, ) inherits katello_devel::params { $group = $user @@ -175,4 +180,8 @@ group => $group, mode => '0755', } + + if $enable_iop { + include katello_devel::iop + } } diff --git a/manifests/iop.pp b/manifests/iop.pp new file mode 100644 index 0000000..5fb564b --- /dev/null +++ b/manifests/iop.pp @@ -0,0 +1,39 @@ +# @summary Insights on Premise (IoP) integration for Katello development +# @api private +class katello_devel::iop { + postgresql::server::pg_hba_rule { 'inventory_db IPV4': + type => 'host', + database => 'inventory_db', + user => 'all', + address => '127.0.0.1/32', + order => 2, + auth_method => 'md5', + } + + postgresql::server::pg_hba_rule { 'inventory_db IPV6': + type => 'host', + database => 'inventory_db', + user => 'all', + address => '::1/128', + order => 3, + auth_method => 'md5', + } + + # Create directory structure for Foreman assets + file { + [ + '/var/lib/foreman', + '/var/lib/foreman/public', + '/var/lib/foreman/public/assets', + '/var/lib/foreman/public/assets/apps', + ]: + ensure => directory, + owner => 'root', + group => 'root', + mode => '0755', + } -> + Katello_devel::Git_repo['foreman'] -> + katello_devel::plugin { 'theforeman/foreman_rh_cloud': } -> + Katello_devel::Bundle['exec rake db:migrate'] -> + class { 'iop': } +} diff --git a/manifests/setup.pp b/manifests/setup.pp index 65c6557..55811d1 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -8,7 +8,7 @@ String $admin_password = $katello_devel::admin_password, Integer[0] $npm_timeout = $katello_devel::npm_timeout, ) { - $pidfile = "${foreman_dir}/tmp/pids/server.pid" + $pidfile = "${foreman_dir}/tmp/pids/main-server.pid" $seed_env = [ "SEED_ORGANIZATION=${initial_organization}", @@ -29,6 +29,7 @@ if defined(Class['foreman_proxy::register']) { katello_devel::bundle { 'exec rails s -d': + command => "exec rails s -d -P ${pidfile}", unless => "/usr/bin/pgrep --pidfile ${pidfile}", subscribe => Katello_devel::Bundle['exec rake db:seed'], } -> @@ -37,6 +38,9 @@ command => "/usr/bin/pkill -9 --pidfile ${pidfile}", logoutput => 'on_failure', timeout => '600', + } -> + file { $pidfile: + ensure => absent, } } } diff --git a/spec/acceptance/iop_spec.rb b/spec/acceptance/iop_spec.rb new file mode 100644 index 0000000..c5b4527 --- /dev/null +++ b/spec/acceptance/iop_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper_acceptance' + +describe 'Scenario: install katello_devel' do + let(:manifest) do + <<-PUPPET + class { 'katello_devel': + user => 'vagrant', + enable_iop => true, + } + PUPPET + end + + it 'applies with no errors' do + apply_manifest(manifest, catch_failures: true) + end +end diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp index 0c29e96..2d3dd25 100644 --- a/spec/setup_acceptance_node.pp +++ b/spec/setup_acceptance_node.pp @@ -12,3 +12,12 @@ ensure => present, managehome => true, } + +package { ['rubygem-oauth', 'puppet-agent-oauth']: + ensure => installed, + require => Class['foreman::repo'], +} + +package { 'podman': + ensure => latest, +}