Raj Parpani
07/13/2023, 1:53 AMRaj Parpani
07/13/2023, 1:54 AMn3snah
07/13/2023, 10:34 AMn3snah
07/13/2023, 10:38 AMSlackbot
07/13/2023, 11:21 AMDr Bunsen Honeydew
07/13/2023, 11:45 AMSlackbot
07/13/2023, 3:55 PMSlackbot
07/13/2023, 4:53 PMSlackbot
07/13/2023, 7:06 PMSlackbot
07/13/2023, 7:53 PMSlackbot
07/13/2023, 8:02 PMDr Bunsen Honeydew
07/13/2023, 8:45 PMSlackbot
07/13/2023, 10:27 PMSlackbot
07/14/2023, 1:13 AMDavid Sandilands
07/14/2023, 9:47 AMemerson_prado
07/16/2023, 4:14 PMinsync?
and, consequently, the setter functions are not called for properties set to false
by the user. I reproduced in all Puppet versions I could install - 5 to 8 - and several distro/version combinations.
Have anyone else seen this? Could it be an intended behaviour?
Test type:
Puppet::Type.newtype(:setter_call) do
newparam(:title, namevar: true) do
desc 'Resource title'
end
newparam(:previous_state) do
desc 'Test property previous state'
end
newproperty(:desired_state) do
desc 'Test property desired state'
def insync?(is)
Puppet.warning("[Type 'insync?' function] - previous: \"#{is}\" - desired: \"#{should}\"")
is == should
end
end
end
Test provider:
Puppet::Type.type(:setter_call).provide(:setter_call) do
def send_log(function, previous, desired)
Puppet.warning("[#{function}] previous: \"#{previous}\" - desired: \"#{desired}\"")
end
def desired_state
send_log('Getter', resource[:previous_state], resource[:desired_state])
resource[:previous_state]
end
def desired_state=(_)
send_log('Setter', resource[:previous_state], resource[:desired_state])
end
end
emerson_prado
07/16/2023, 6:51 PMclass Puppet::Property < Puppet::Parameter
...
# @note If the wanted value _(should)_ is not defined or is set to a non-true value then this is
# a state that can not be fixed and the property is reported to be in sync.
def safe_insync?(is)
# If there is no @should value, consider the property to be in sync.
return true unless @should
...
insync?(is)
end
...
end
So, if @should
is undefined, nil
or false
, the method returns true
, no matter the sync status (except that, in my tests, nil
did not trigger this).
I wonder if we could use return true unless defined? @should
instead. Dunno if @should
gets defined even if the user doesn't set the property. Thoughts?
As far as my code is concerned, I'll switch to the more "Puppety" :absent
instead of false
. With some regret of not doing it earlier...emerson_prado
07/16/2023, 9:14 PMnil
instead of undef
in Puppet, so I got "nil" string. Fixing the Puppet part got the normal behaviour: no insync?
call for false
nor for nil
.
Plus, class Puppet::Transaction::ResourceHarness method sync_if_needed
doesn't call Puppet::Property.safe_insync?
if the property's user specified value is nil
. Is that intended?
In the case user specified false
, is it intended too that Puppet doesn't process the property any further?Slackbot
07/17/2023, 8:10 AMSlackbot
07/17/2023, 9:02 AMSlackbot
07/17/2023, 10:10 AMedwin
07/17/2023, 10:33 AMPourya
07/17/2023, 12:39 PM--debug
run of the very first puppet apply for the node itself
Global Data Provider (hiera configuration version 5)
Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
Hierarchy entry "Host data"
Path "/etc/puppetlabs/code/hieradata/.yaml"
Original path: "%{::facts.hostname}.yaml"
Path not found
Pourya
07/17/2023, 12:39 PMhiera.yaml
looks like this
defaults:
datadir: /etc/puppetlabs/code/hieradata
data_hash: yaml_data
hierarchy:
- name: Host data
path: "%{::facts.hostname}.yaml"
- name: Host secure data
lookup_key: eyaml_lookup_key
path: "%{::facts.hostname}.eyaml"
options:
pkcs7_private_key: /etc/puppetlabs/puppet/eyaml/private_key.pkcs7.pem
pkcs7_public_key: /etc/puppetlabs/puppet/eyaml/public_key.pkcs7.pem
Pourya
07/17/2023, 12:39 PM# puppet facts hostname
{
"hostname": "us1svcs-uupuppetserver001"
}
However this doesn’t work
# puppet lookup --environment prod --explain --node us1svcs-uupuppetserver001 hostname
Error: Cached facts for us1svcs-uupuppetserver001 failed: Could not find terminus puppetdb for indirection facts
Error: Could not run: No facts available for target node: us1svcs-uupuppetserver001
Pourya
07/17/2023, 12:45 PM%{facts.networking.hostname}
Slackbot
07/17/2023, 2:35 PMSlackbot
07/17/2023, 2:58 PMSlackbot
07/17/2023, 3:24 PMSlackbot
07/17/2023, 3:56 PM