Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter to enable iop-advisor-engine to rh_cloud plugin #1204

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ fixtures:
apache: 'https://github.com/puppetlabs/puppetlabs-apache'
apt: 'https://github.com/puppetlabs/puppetlabs-apt'
augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core'
certs: 'https://github.com/theforeman/puppet-certs'
concat: 'https://github.com/puppetlabs/puppetlabs-concat'
cron_core: 'https://github.com/puppetlabs/puppetlabs-cron_core'
extlib: 'https://github.com/voxpupuli/puppet-extlib'
hashfile: 'https://github.com/southalc/hashfile'
iop_advisor_engine: 'https://github.com/theforeman/puppet-iop_advisor_engine'
evgeni marked this conversation as resolved.
Show resolved Hide resolved
podman: 'https://github.com/southalc/podman'
postgresql: 'https://github.com/puppetlabs/puppetlabs-postgresql'
puppet: 'https://github.com/theforeman/puppet-puppet'
redis: 'https://github.com/voxpupuli/puppet-redis'
Expand Down
15 changes: 13 additions & 2 deletions manifests/plugin/rh_cloud.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Installs rh_cloud plugin
class foreman::plugin::rh_cloud {
# @summary Installs rh_cloud plugin
#
# @param enable_iop_advisor_engine
# Enable iop-advisor-engine integration
#
class foreman::plugin::rh_cloud (
Boolean $enable_iop_advisor_engine = false,
) {
foreman::plugin { 'rh_cloud':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theforeman/foreman_rh_cloud#932 introduces settings. IMHO this should create a /etc/foreman/settings.plugins.d/${plugin}.yaml file with that which can be done easily with the existing config parameter. The following keeps it simple and avoids a template by using stdlib::to_yaml:

Suggested change
foreman::plugin { 'rh_cloud':
$config = {
':foreman_rh_cloud' => {
':use_local_advisor_engine' => $enable_iop_advisor_engine,
},
}
foreman::plugin { 'rh_cloud':
config => stdlib::to_yaml($config),

I'm not 100% sure on the use of symbols vs strings though. That could break.

Copy link
Member

@evgeni evgeni Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# cat /etc/foreman/plugins/foreman_rh_cloud.yaml 
---
":foreman_rh_cloud":
  ":use_local_advisor_engine": true

# foreman-rake console
Loading production environment (Rails 7.0.8.7)
irb(main):001:0> SETTINGS.dig(:foreman_rh_cloud, :use_local_advisor_engine)
=> nil

😡

Why are we using symbols again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it makes life interesting? I wonder if we should enhance https://github.com/theforeman/foreman/blob/9e5da95e3194f37b71f013794835fd1d0f9a4a30/config/settings.rb#L40 to symbolize keys.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe… but I am not shooting at that can of worms today.

config => epp('foreman/rh_cloud.yaml.epp', { 'enable_iop_advisor_engine' => $enable_iop_advisor_engine }),
}

class { 'iop_advisor_engine':
ensure => bool2str($enable_iop_advisor_engine, 'present', 'absent'),
}
}
10 changes: 10 additions & 0 deletions spec/acceptance/foreman_rh_cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
# iop_advisor_engine requires foreman-proxy certs to talk back to Foreman
# TODO: redesign the deployment in a way that it better aligns with our architecture
file { '/etc/foreman-proxy':
ensure => directory,
}

group { 'foreman-proxy':
ensure => present,
}
Comment on lines +11 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a foreman-proxy in puppet-foreman? That feels like a horrible violation of principles where Foreman should never read files from foreman-proxy. Is this because of certs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, advisor-engine uses the proxy cert to auth against Foreman, and that lives in /etc/foreman-proxy (and gets read from there into a podman secret).
We probably can make puppet-certs deploy a second copy into /etc/iop-advisor-engine to avoid that, but today it's not happening.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already mentioned before that I feel advisor engine belongs closer to a Smart Proxy because that's where all our external integration lives. We really need to figure out external services in a consistent way, especially if we expect more services to be added. Perhaps our Smart Proxy model isn't scalable, but I've made a mental note we need to discuss this. For now a note above it in the acceptance test is a "good enough" to allow us to proceed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're abusing a bit of the SP architecture, even tho I still think it's not actually a SP thing (e.g. you can't have multiple of it, which breaks the SP paradigm).

I'll add a note to the test, yes.


include foreman
include foreman::plugin::rh_cloud
PUPPET
Expand Down
6 changes: 6 additions & 0 deletions templates/rh_cloud.yaml.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<%- |
Boolean $enable_iop_advisor_engine,
| -%>
---
:foreman_rh_cloud:
:use_local_advisor_engine: <%= $enable_iop_advisor_engine %>