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 service to publish facts to foreman #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bastelfreak
Copy link
Member

No description provided.

@bastelfreak bastelfreak added the Enhancement New feature or request label Oct 25, 2024
@bastelfreak bastelfreak self-assigned this Oct 25, 2024
@bastelfreak bastelfreak force-pushed the service branch 3 times, most recently from a81c7aa to b09dae2 Compare October 25, 2024 17:25
manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
@bastelfreak bastelfreak force-pushed the service branch 8 times, most recently from bb208a1 to 8860920 Compare October 25, 2024 21:47
@bastelfreak bastelfreak force-pushed the service branch 2 times, most recently from 3bcf370 to d2c4065 Compare December 16, 2024 12:36
@ekohl
Copy link
Member

ekohl commented Dec 18, 2024

Puppet also has the Fact indirector concept and here's an example: https://github.com/puppetlabs/puppetlabs-satellite_pe_tools/blob/main/lib/puppet/indirector/facts/satellite.rb

@bastelfreak
Copy link
Member Author

I would prefer to avoid the indirector. As far as I know puppet does not really support multiple of them, and Mos people already use the functionality to store data in Puppetdb.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

As far as I know puppet does not really support multiple of them

It really does not. There is just 1 fact indirector.

I'm sure this change will play really nice with https://github.com/puppetlabs/puppetlabs-satellite_pe_tools, but I don't care too much about that.

Overall I'd prefer to use the system Ruby because dependencies are easier to manage. Not that we have many, but still.

manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved

[Service]
Type=simple
Environment=PATH=/opt/puppetlabs/puppet/bin:<%= $facts['path'] %>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this path needed? I think you end up using the AIO Puppet's Ruby so then why do you need rb-notify?

Copy link
Member Author

Choose a reason for hiding this comment

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

rb-notify is installed into the puppet ruby. And that's the only ruby interpreter we know is present on the system. Managing system ruby is a whole different can of worms.

manifests/init.pp Outdated Show resolved Hide resolved
spec/classes/init_spec.rb Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
templates/fact_watcher.service.epp Outdated Show resolved Hide resolved
@bastelfreak bastelfreak force-pushed the service branch 4 times, most recently from 989c875 to d17f301 Compare December 18, 2024 15:08
@bastelfreak
Copy link
Member Author

Overall I'd prefer to use the system Ruby because dependencies are easier to manage. Not that we have many, but still.

I think that's more complicated because we don't know if a system ruby exists. And the whole service is an edge case for PE users to make the migration easier. So I would argue this is fine.

@ekohl
Copy link
Member

ekohl commented Dec 18, 2024

I think that's more complicated because we don't know if a system ruby exists.

We pull in rubygem-json (on EL) or ruby-json (on Debian). Doesn't that already guarantee a system Ruby?

}
package { 'ruby-inotify':
ensure => 'installed',
provider => 'puppet_gem',
Copy link
Member

Choose a reason for hiding this comment

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

I dislike using the puppet_gem provider (or really, gem on production servers). If you upgrade your Puppet AIO it may break the native extensions and you don't know what you're pulling in.

Comment on lines +155 to +157
'Environment' => "PATH=/opt/puppetlabs/puppet/bin:${facts['path']}",
'User' => $puppet_user,
'ExecStart' => "${puppet_etcdir}/node.rb --watch-facts --push-facts-parallel",
Copy link
Member

Choose a reason for hiding this comment

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

If you want to enforce the AIO Ruby (and I really dislike it), perhaps this is better?

Suggested change
'Environment' => "PATH=/opt/puppetlabs/puppet/bin:${facts['path']}",
'User' => $puppet_user,
'ExecStart' => "${puppet_etcdir}/node.rb --watch-facts --push-facts-parallel",
'User' => $puppet_user,
'ExecStart' => "/opt/puppetlabs/puppet/bin/ruby ${puppet_etcdir}/node.rb --watch-facts --push-facts-parallel",

@@ -40,6 +40,10 @@
# The directory used to install the report processor to
# @param use_client_tls_certs
# Enable client TLS authentication to foreman
# @param fact_watcher_service
# Sets up a simple systemd unit that watches for new fact files and publishes them to foreman. Not required when foreman is the ENC
Copy link
Member

Choose a reason for hiding this comment

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

There is a $enc parameter which you can use. Perhaps fail() if both are true?

Technically you could look at $enc_upload_facts but then you don't have a guarantee that the facts are uploaded before the ENC is calculated. Uploading facts will create a host entry when it doesn't exist, so I wouldn't do that.

# @param fact_watcher_service
# Sets up a simple systemd unit that watches for new fact files and publishes them to foreman. Not required when foreman is the ENC
# @param manage_fact_watcher_dependencies
# Install the missing dependencies for fact_watchter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Install the missing dependencies for fact_watchter
# Install the missing dependencies for fact_watcher

@bastelfreak
Copy link
Member Author

We pull in rubygem-json (on EL) or ruby-json (on Debian). Doesn't that already guarantee a system Ruby?

If foreman-proxy is installed, yes. I doubt that someone wants to submit facts but not run foreman-proxy, but who knows. If you want, I can update it to the gem provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants