Jira (PUP-2368) using booleans result in unmanaged property

4 views
Skip to first unread message

Arney (JIRA)

unread,
Mar 17, 2016, 3:58:08 PM3/17/16
to puppe...@googlegroups.com
Arney commented on Bug PUP-2368
 
Re: using booleans result in unmanaged property

This problem is still present in Puppet 4.3.2 and here is a minimal example:

puppet/type/foo.rb

require 'puppet/property/boolean'
 
Puppet::Type.newtype(:foo) do
  newparam(:name)
  newproperty(:boolprop, parent: Puppet::Property::Boolean)
end

puppet/provider/foo/bar.rb

Puppet::Type.type(:foo).provide(:bar) do
 
  def boolprop
    # Force change, always return the opposite
    !resource.should(:boolprop)
  end
 
  def boolprop=(value)
    p "Setting value: #{value}"
  end
 
end

$ puppet resource foo works boolprop=true
"Setting value: true"
Notice: /Foo[works]/boolprop: boolprop changed 'false' to 'true'
foo { 'works':
  boolprop => 'false',
}
$ puppet resource foo broken boolprop=false
foo { 'broken':
  boolprop => 'true',
}

Setting a boolean property to false will never trigger its setter.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Atlassian logo

Maggie Dreyer (JIRA)

unread,
May 16, 2017, 1:46:03 PM5/16/17
to puppe...@googlegroups.com
Maggie Dreyer updated an issue
 
Puppet / Bug PUP-2368
Change By: Maggie Dreyer
Labels: triaged
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Maggie Dreyer (JIRA)

unread,
May 16, 2017, 1:46:03 PM5/16/17
to puppe...@googlegroups.com

Maggie Dreyer (JIRA)

unread,
May 16, 2017, 1:47:03 PM5/16/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 18, 2017, 1:49:08 PM5/18/17
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Feb 15, 2018, 12:34:03 PM2/15/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sub-team: Coremunity
This message was sent by Atlassian JIRA (v7.5.1#75006-sha1:7df2574)
Atlassian logo

Josh Cooper (JIRA)

unread,
Feb 15, 2018, 12:34:03 PM2/15/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core Grooming

Josh Cooper (JIRA)

unread,
Feb 15, 2018, 12:37:03 PM2/15/18
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-2368
 
Re: using booleans result in unmanaged property

PUP-8442 should resolve the issue for parameter defaults. This issue is related, but different because properties are managed and we want to be able to set the current value to false.

David Schmitt (JIRA)

unread,
Feb 20, 2018, 6:31:03 AM2/20/18
to puppe...@googlegroups.com
David Schmitt commented on Bug PUP-2368

This is far enough up the stack that it also affects the Resource API.

David Schmitt (JIRA)

unread,
Apr 12, 2018, 10:38:05 AM4/12/18
to puppe...@googlegroups.com
David Schmitt commented on Bug PUP-2368

The Resource API now carries a workaround for that: https://github.com/puppetlabs/puppet-resource_api/pull/62 , basically using :true and :false when talking to puppet. This does not affect the provider, which still can work with regular booleans.

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Sep 26, 2018, 8:54:14 PM9/26/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core Grooming

Mykhailo Danylenko (JIRA)

unread,
Oct 4, 2018, 12:33:05 AM10/4/18
to puppe...@googlegroups.com
Mykhailo Danylenko commented on Bug PUP-2368
 
Re: using booleans result in unmanaged property

Hey, could this be finally fixed in some way? I've spent this week digging through puppet internals to understand, why my resource isn't being managed (as it turned out, only boolean properties were not managed, but they comprise the majority of my resource). Or at least documented in the source, so that developers don't waste their time debugging their code, when the problem lies in puppet's.

P.S. I am using puppet 5.5.6 from the official debian repo.

David Schmitt (JIRA)

unread,
Oct 5, 2018, 5:01:06 AM10/5/18
to puppe...@googlegroups.com
David Schmitt commented on Bug PUP-2368

Mykhailo Danylenko to avoid this (and many other issues) please use the Resource API: https://puppet.com/docs/puppet/6.0/custom_resources.html

The Resource API is available to install on puppet 4 and 5 as a gem (there is also a module for that), and it is shipped fully supported with puppet 6.

Mykhailo Danylenko (JIRA)

unread,
Oct 5, 2018, 8:15:05 AM10/5/18
to puppe...@googlegroups.com

David Schmitt thanks for the suggestion. Well, if it's the future, I guess I'll switch to that. Still, I think a note in the Puppet::Property::Boolean class would be helpful.

Trevor Vaughan (Jira)

unread,
Mar 19, 2020, 1:25:08 PM3/19/20
to puppe...@googlegroups.com

The Resource API hasn't reached parity with the underlying API so this will still need to be addressed at some point.

Documentation outside of this ticket would be great.

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Trevor Vaughan (Jira)

unread,
Mar 20, 2020, 8:14:02 PM3/20/20
to puppe...@googlegroups.com

Removing the inheritance on Puppet::Property::Boolean and adding the following appears to do the trick:

def should
  return nil unless defined?(@should)
  (@should - [true,:true]).empty?
end

It's possible that the underlying puppet code could detect whether or not the thing is a boolean in the native should code and "do the right thing".

Michael Hashizume (Jira)

unread,
Mar 7, 2023, 4:45:03 PM3/7/23
to puppe...@googlegroups.com
Michael Hashizume updated an issue
 
Change By: Michael Hashizume
Team: Coremunity Phoenix
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages