Jira (PUP-4078) puppet resource tool output contains incorrect quoting

1 view
Skip to first unread message

Geoff Williams (JIRA)

unread,
Mar 3, 2015, 9:26:19 PM3/3/15
to puppe...@googlegroups.com
Geoff Williams created an issue
 
Puppet / Bug PUP-4078
puppet resource tool output contains incorrect quoting
Issue Type: Bug Bug
Affects Versions: PUP 3.7.4
Assignee: Unassigned
Components: Platform
Created: 2015/03/03 6:25 PM
Environment:

3.7.4 (Puppet Enterprise 3.7.2)

Priority: Normal Normal
Reporter: Geoff Williams

Overview

puppet resource currently outputs quotes around values such as 'false' which should logically equate to true unless there are additional measures in place to parse out known values before continuing.

Problems this causes

As part of the preparation for PE 4.x which includes optional typing, we need to help educate users not to write code which is ambiguous or needs additional processing to work correctly.

It's important that the RAL tool generates good puppet code because:

  • Its often the first puppet code a user will see (output by installer)
  • Its output be used for reverse engineering systems and can end up becoming deeply embedded into a codebase

Worked example

Inspecting the pe-puppet service - note quoting around boolean (and reserved word?):

[root@xagent1 ~]# puppet resource service pe-puppet
service { 'pe-puppet':
  ensure => 'running',
  enable => 'true',
}

Change the pe-puppet daemon to be stopped with puppet resource -e service pe-puppet

Check output of puppet resource command again, note quoting as above

[root@xagent1 ~]# puppet resource service pe-puppet
service { 'pe-puppet':
  ensure => 'stopped',
  enable => 'false',
}

Corrective action

  • booleans should not be quoted
  • reserved words should not be quoted
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.3.10#6340-sha1:7ea293a)
Atlassian logo

Geoff Williams (JIRA)

unread,
Mar 3, 2015, 9:29:21 PM3/3/15
to puppe...@googlegroups.com
Geoff Williams updated an issue
Change By: Geoff Williams
h2. Overview

{{puppet resource}} currently outputs quotes around values such as {{'false'}} which should logically equate to true unless there are additional measures in place to parse out known values before continuing.

h2. Problems this causes

As part of the preparation for PE 4.x which includes optional typing, we need to help educate users not to write code which is ambiguous or needs additional processing to work correctly.

It's important that the RAL tool generates _good_ puppet code because:
* Its often the first puppet code a user will see (output by installer)
 so we need to make sure we don't teach bad habits
* Its output be used for reverse engineering systems and can end up becoming deeply embedded into a codebase

h2. Worked example

Inspecting the {{pe-puppet}} service - note quoting around boolean (and reserved word?):
{noformat}

[root@xagent1 ~]# puppet resource service pe-puppet
service { 'pe-puppet':
  ensure => 'running',
  enable => 'true',
}
{noformat}

_Change the {{pe-puppet}} daemon to be stopped with {{puppet resource -e service pe-puppet}}_


Check output of puppet resource command again, note quoting as above
{noformat}

[root@xagent1 ~]# puppet resource service pe-puppet
service { 'pe-puppet':
  ensure => 'stopped',
  enable => 'false',
}
{noformat}

h2. Corrective action
* booleans should not be quoted
* reserved words should not be quoted

Henrik Lindberg (JIRA)

unread,
Mar 4, 2015, 7:02:26 AM3/4/15
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-4078
 
Re: puppet resource tool output contains incorrect quoting

I think it should:

  • Output numbers as numbers
  • Booleans as booleans
  • Resource references as resource type instances (it probably does already i.e. File['foo'], and not 'File[foo]')

Keywords in general must be quoted, the fact that true and false are keywords does not mean that values such as 'if' should be output as a keyword.

The RAL is unchanged between 3.x and 4.x. It will contain values as produced by the 3.x types. I suspect the cleanup will have to be done as part of puppet resource printout of the values. (The catalog is still predominantly based on everything being strings).

Geoff Williams (JIRA)

unread,
Mar 10, 2015, 9:32:27 PM3/10/15
to puppe...@googlegroups.com

Henrik Lindberg What would you say octal file permissions should be set to? At the moment we advise to write code like this:

file { "/bla":
  ...,
  mode => "0755",
}

Is this still correct? Maybe 0755 with no quotes would now be 'better'?

Henrik Lindberg (JIRA)

unread,
Mar 11, 2015, 9:28:23 AM3/11/15
to puppe...@googlegroups.com

File mode now requires a string, so it will fail if the value is written without quotes on Puppet 4.0. That change was to protect users from writing something like mode => 755 which is very different from mode => '755'.

John Duarte (JIRA)

unread,
May 17, 2017, 12:54:06 PM5/17/17
to puppe...@googlegroups.com
John Duarte updated an issue
 
Change By: John Duarte
Labels: triaged
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 17, 2017, 12:56:18 PM5/17/17
to puppe...@googlegroups.com

Nicholas Fagerlund (JIRA)

unread,
May 17, 2017, 12:57:03 PM5/17/17
to puppe...@googlegroups.com
Nicholas Fagerlund updated an issue
Change By: Nicholas Fagerlund
*  -  reserved words should not be quoted - (Words like "running" are just strings, so it doesn't really matter if they're bare-words or quoted.)
* Numbers should not be quoted (except in file modes, where they're strings)

Nicholas Fagerlund (JIRA)

unread,
May 17, 2017, 12:58:48 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

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

Henrik Lindberg (JIRA)

unread,
May 19, 2017, 9:58:04 AM5/19/17
to puppe...@googlegroups.com
 
Re: puppet resource tool output contains incorrect quoting

Ping Thomas Hallgren wonder if your recent work using string converter may have effect on this ticket as well ??

Thomas Hallgren (JIRA)

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

Yes, PUP-7155 will fix some of this but there's more to it than just representation. A puppet resource service httpd on my machine creates a resource with the two parameters ensure => 'running' and enable => 'true'. A debugger reveals that hey are both ruby symbols. I believe 'enable' should be a Boolean.

Thomas Hallgren (JIRA)

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

Setting this as blocked by PUP-7155 since that needs to be resolved before further work is done in this area.

Josh Cooper (JIRA)

unread,
Jun 7, 2017, 12:36:02 AM6/7/17
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4078

I believe 'enable' should be a Boolean

It should not be a boolean, because there are 4 possible states: true, false, manual, mask.

Thomas Hallgren (JIRA)

unread,
Jun 7, 2017, 3:46:02 AM6/7/17
to puppe...@googlegroups.com

Josh Cooper (Jira)

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

This looks to be not an issue anymore, closing:

[root@gloomy-fuchsia ~]# puppet resource file /tmp
file { '/tmp':
  ensure   => 'directory',
  ctime    => '2020-03-13 21:51:16 +0000',
  group    => 0,
  mode     => '1777',
  mtime    => '2020-03-13 21:51:16 +0000',
  owner    => 0,
  provider => 'posix',
  type     => 'directory',
}
[root@gloomy-fuchsia ~]# puppet resource service puppet
service { 'puppet':
  ensure   => 'stopped',
  enable   => 'false',
  provider => 'systemd',
}

The quoted false value is expected, see comments above.

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages