Jira (PUP-4024) Puppet should allow setting null property value

4 views
Skip to first unread message

Geoffrey Gardella (JIRA)

unread,
Feb 17, 2015, 2:31:53 PM2/17/15
to puppe...@googlegroups.com
Geoffrey Gardella created an issue
 
Puppet / Bug PUP-4024
Puppet should allow setting null property value
Issue Type: Bug Bug
Affects Versions: PUP 3.7.4, PUP 3.6.2
Assignee: Unassigned
Created: 2015/02/17 11:31 AM
Environment:

Solaris 11.2+

Priority: Normal Normal
Reporter: Geoffrey Gardella
Original Estimate: 2 days
Remaining Estimate: 2 days

On evsadm (and many other commands), it takes null value to reset a specific parameter.
i.e.)

  1. evsadm set-evsprop -p maxbw= HR

This command will reset the value of maxbw of the evs instance, HR.
(Please note that maxbw is blank, not HR. HR is the evs name )

This makes total sense since there is no default value for maxbw and null(blank) means that a user wants to reset it to none.

This method works fine with Puppet when you do 'apply'.

  1. puppet apply -e "evs {'sys-global/HR': maxbw=>''}

    "
    Notice: Compiled catalog for bamd-sfb-01.us.oracle.com in environment production in 0.07 seconds
    Notice: /Stage[main]/Main/Evs[sys-global/HR]/maxbw: maxbw changed '1G' to ''
    Notice: Finished catalog run in 6.28 seconds

However Puppet resource doesn't seem happy with null value for a parameter.

  1. puppet resource evs sys-global/HR maxbw='' --debug
    Error: Could not run: Invalid parameter setting maxbw=

Puppet should allow setting an empty parameter by the puppet command.

The values:

maxbw=
maxbw=''

From the puppet command's perspective, are exactly the same thing, and should really be valid.

Taking a look at the code, it would seem to be that...

In the file:

/usr/ruby/1.9/lib/amd64/ruby/vendor_ruby/1.9.1/puppet/application/resource.rb

The first problem that I see in the code is:

args.each do |setting|
if setting =~ /^(\w+)=(.+)$/
params[$1] = $2
else
raise "Invalid parameter setting #

{setting}

"
end
end

What I get from reading this is that the value after the '=' must contain at least one character, which of course something like 'maxbw=' doesn't...

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.3.10#6340-sha1:7ea293a)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 17, 2017, 12:34:03 PM5/17/17
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
On evsadm (and many other commands), it takes null value to reset a specific parameter.
i.e.)

{noformat}
# evsadm set-evsprop -p maxbw= HR
{noformat}

This command will reset the value of maxbw of the evs instance, HR.
(Please note that maxbw is blank, not HR. HR is the evs name )

This makes total sense since there is no default value for maxbw and null(blank) means that a user wants to reset it to none.

This method works fine with Puppet when you do 'apply'.

{noformat}
# puppet apply -e "evs{'sys-global/HR': maxbw=>''}"

Notice: Compiled catalog for bamd-sfb-01.us.oracle.com in environment production in 0.07 seconds
Notice: /Stage[main]/Main/Evs[sys-global/HR]/maxbw: maxbw changed '1G' to ''
Notice: Finished catalog run in 6.28 seconds
{noformat}

However Puppet resource doesn't seem happy with null value for a parameter.

{noformat}
# puppet resource evs sys-global/HR maxbw='' --debug

Error: Could not run: Invalid parameter setting maxbw=
{noformat}

Puppet should allow setting an empty parameter by the puppet command.

The values:

{noformat}
   maxbw=
   maxbw=''
{noformat}

From the puppet command's perspective, are exactly the same thing, and should really be valid.

Taking a look at the code, it would seem to be that...

In the file:

{noformat}
   /usr/ruby/1.9/lib/amd64/ruby/vendor_ruby/1.9.1/puppet/application/resource.rb
{noformat}

The first problem that I see in the code is:

{code:ruby}
    args.each do |setting|
      if setting =~ /^(\w+)=(.+)$/
        params[$1] = $2
      else
        raise "Invalid parameter setting #{setting}"
      end
    end
{code}

What I get from reading this is that the value after the '=' *must* contain at least one character, which of course something like 'maxbw=' doesn't... 
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Ethan Brown (JIRA)

unread,
May 17, 2017, 12:34:04 PM5/17/17
to puppe...@googlegroups.com

John Duarte (JIRA)

unread,
May 17, 2017, 12:35:04 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

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

Henrik Lindberg (JIRA)

unread,
May 20, 2017, 10:00:02 AM5/20/17
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-4024
 
Re: Puppet should allow setting null property value

It looks like we would need a CLI representation of undef since '' is an empty string, and is different from undef - while both prints as "nothing", the distinction may be important.

Henrik Lindberg (JIRA)

unread,
May 22, 2017, 4:34:02 AM5/22/17
to puppe...@googlegroups.com

This also relates to the issue that the puppet language does not have a way to set undef explicitly as an attribute value. If you do something like:

myresource { 'title':
  x => undef
}

that means that x should be given its default value - it does not set x to undef. In another ticket, it has been proposed that a specific syntax should be used to allow that - for example using x ==> undef - that has however been rejected.

In this particular case, it seems like an empty string would be a better choice to mean that there is a "blank" value as opposed to being "undefined".

Josh Cooper (Jira)

unread,
Mar 13, 2020, 6:56:02 PM3/13/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4024

When using puppet resource if you want a property to be undefined, then you'd omit it from the CLI, e.g. puppet resource myresource title ensure=present. However, if you wanted the property to be defined, but have an empty value, then you should be able to do puppet resource myresource title ensure=present x=. For example, you can't touch a file using puppet resource:

$ bx puppet resource file /tmp/bar ensure=file content=
Error: Could not run: Invalid parameter setting content=

Using .* does work as expected though:

$ bx puppet resource file /tmp/empty ensure=file content=
Notice: /File[/tmp/empty]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
file { '/tmp/empty':
  ensure   => 'file',
  content  => '{md5}d41d8cd98f00b204e9800998ecf8427e',
  provider => 'posix',
}
$ file /tmp/empty
/tmp/empty: empty

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

Josh Cooper (Jira)

unread,
Feb 9, 2022, 12:47:01 AM2/9/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Epic Link: PUP-7560
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages