diff --git a/lib/puppet/provider/foreman_host/rest_v3.rb b/lib/puppet/provider/foreman_host/rest_v3.rb index 98a6a6fb4..66464b7bb 100644 --- a/lib/puppet/provider/foreman_host/rest_v3.rb +++ b/lib/puppet/provider/foreman_host/rest_v3.rb @@ -2,7 +2,7 @@ confine :feature => [:json, :oauth] def exists? - !id.nil? + !resource[:force_fact_upload] && !id.nil? end def create diff --git a/lib/puppet/type/foreman_host.rb b/lib/puppet/type/foreman_host.rb index 64dcc8f50..3afb6b0ea 100644 --- a/lib/puppet/type/foreman_host.rb +++ b/lib/puppet/type/foreman_host.rb @@ -11,4 +11,8 @@ defaultto { $facts } end + + newparam(:force_fact_upload) do + desc 'Force fact upload when host already exists' + end end diff --git a/manifests/register.pp b/manifests/register.pp index 9f2ffd74f..dda76299b 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -2,16 +2,18 @@ # @api private class foreman::register ( Stdlib::Fqdn $foreman_host_name = $facts['networking']['fqdn'], + Boolean $force_fact_upload = false, ) { foreman_host { "foreman-${$foreman_host_name}": - ensure => present, - hostname => $foreman_host_name, - base_url => $foreman::foreman_url, - consumer_key => $foreman::oauth_consumer_key, - consumer_secret => $foreman::oauth_consumer_secret, - effective_user => $foreman::oauth_effective_user, - ssl_ca => $foreman::server_ssl_chain, - facts => $facts, + ensure => present, + hostname => $foreman_host_name, + base_url => $foreman::foreman_url, + consumer_key => $foreman::oauth_consumer_key, + consumer_secret => $foreman::oauth_consumer_secret, + effective_user => $foreman::oauth_effective_user, + ssl_ca => $foreman::server_ssl_chain, + facts => $facts, + force_fact_upload => $force_fact_upload, } foreman_instance_host { "foreman-${$foreman_host_name}":