-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
fixtures: | ||
repositories: | ||
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib' | ||
systemd: 'https://github.com/voxpupuli/puppet-systemd' |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||||
# @param manage_fact_watcher_dependencies | ||||||||||||
# Install the missing dependencies for fact_watchter | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
class puppetserver_foreman ( | ||||||||||||
Stdlib::HTTPUrl $foreman_url = $puppetserver_foreman::params::foreman_url, | ||||||||||||
Boolean $enc = true, | ||||||||||||
|
@@ -58,6 +62,8 @@ | |||||||||||
Variant[Enum[''], Stdlib::Absolutepath] $ssl_cert = $puppetserver_foreman::params::client_ssl_cert, | ||||||||||||
Variant[Enum[''], Stdlib::Absolutepath] $ssl_key = $puppetserver_foreman::params::client_ssl_key, | ||||||||||||
Boolean $use_client_tls_certs = true, | ||||||||||||
Boolean $fact_watcher_service = $puppetserver_foreman::params::fact_watcher_service, | ||||||||||||
Boolean $manage_fact_watcher_dependencies = true, | ||||||||||||
) inherits puppetserver_foreman::params { | ||||||||||||
case $facts['os']['family'] { | ||||||||||||
'Debian': { $json_package = 'ruby-json' } | ||||||||||||
|
@@ -126,5 +132,33 @@ | |||||||||||
group => $puppet_group, | ||||||||||||
mode => '0750', | ||||||||||||
} | ||||||||||||
if $manage_fact_watcher_dependencies { | ||||||||||||
$ensure = if $fact_watcher_service { | ||||||||||||
'installed' | ||||||||||||
} else { | ||||||||||||
'absent' | ||||||||||||
} | ||||||||||||
package { 'ruby-inotify': | ||||||||||||
ensure => 'installed', | ||||||||||||
provider => 'puppet_gem', | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dislike using the |
||||||||||||
before => Systemd::Unit_file['fact_watcher.service'], | ||||||||||||
} | ||||||||||||
} | ||||||||||||
systemd::manage_unit { 'fact_watcher.service': | ||||||||||||
enable => $fact_watcher_service, | ||||||||||||
active => $fact_watcher_service, | ||||||||||||
unit_entry => { | ||||||||||||
'Description' => 'Publish facts to Foreman', | ||||||||||||
}, | ||||||||||||
service_entry => { | ||||||||||||
'Type' => 'simple', | ||||||||||||
'Environment' => "PATH=/opt/puppetlabs/puppet/bin:${facts['path']}", | ||||||||||||
'User' => $puppet_user, | ||||||||||||
'ExecStart' => "${puppet_etcdir}/node.rb --watch-facts --push-facts-parallel", | ||||||||||||
Comment on lines
+155
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||
}, | ||||||||||||
install_entry => { | ||||||||||||
'WantedBy' => 'multi-user.target', | ||||||||||||
}, | ||||||||||||
} | ||||||||||||
} | ||||||||||||
} |
There was a problem hiding this comment.
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. Perhapsfail()
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.