Jira (PUP-9196) Host type raises error for use of whitespace in host_aliases attribute while array delimiter is a whitespace

5 views
Skip to first unread message

Kevin Reeuwijk (JIRA)

unread,
Oct 3, 2018, 9:35:05 AM10/3/18
to puppe...@googlegroups.com
Kevin Reeuwijk created an issue
 
Puppet / Bug PUP-9196
Host type raises error for use of whitespace in host_aliases attribute while array delimiter is a whitespace
Issue Type: Bug Bug
Affects Versions: PUP 6.0.0, PUP 5.5.6
Assignee: Unassigned
Components: Language
Created: 2018/10/03 6:34 AM
Priority: Normal Normal
Reporter: Kevin Reeuwijk

Puppet Version: verified on 5.5.x and 6.x
Puppet Server Version: 2018.1
OS Name/Version: CentOS 7.5.1804

It's impossible to provide a valid array of host_aliases to the Host resource from the 'puppet resource' command line, due to an erroneous validation error in the Host type definition. On lines 39-41 of /opt/puppetlabs/puppet/vendor_modules/host_core/lib/puppet/type/host.rb it defines the array delimiter as a space:

 

    def delimiter
      ' '
    end

while on line 49 it raises on error if the input contains a space:

 

 

      raise Puppet::Error, _('Host aliases cannot include whitespace') if value =~ %r{\s}

This naturally leads to an impossible situation, where the only working option is an array of 1 item.

 

Desired Behavior:

When specifying an array of host_aliases, the delimiter should be different from the validation for not using a whitespace.

Actual Behavior:

According to the type definition, this should be the correct command for puppet resource type:

 

puppet resource host puppet.classroom.puppet.com host_aliases="puppet master.puppet.vm"

However, this gives the following error, caused by line 49 in host.rb:

 

Error: Could not run: Parameter host_aliases failed on Host[puppet.classroom.puppet.com]: Host aliases cannot include whitespace

The user would then naturally think he should use the following command instead, using a different seperator:

puppet resource host puppet.classroom.puppet.com host_aliases="puppet,master.puppet.vm"

This command runs, but results in the following output:

 

host { 'puppet.classroom.puppet.com':
  ensure       => 'present',
  host_aliases => ['puppet,master.puppet.vm'],
  target       => '/etc/hosts',
}

Which is actually a single entry for a host alias called "puppet,master.puppet.vm", which is also wrong. See the resulting entry in /etc/hosts:

cat /etc/hosts
<removed non-relevant entries>
10.170.0.107 puppet.classroom.puppet.com puppet,master.puppet.vm

As a quick test, I commented out line 49 from the Host type and re-ran the original command, which now succeeds:

puppet resource host puppet.classroom.puppet.com host_aliases="puppet master.puppet.vm"
Notice: /Host[puppet.classroom.puppet.com]/host_aliases: host_aliases changed [puppet,master.puppet.vm] to 'puppet master.puppet.vm'
host { 'puppet.classroom.puppet.com':
  ensure       => 'present',
  host_aliases => ['puppet', 'master.puppet.vm'],
  target       => '/etc/hosts',
}
 
cat /etc/hosts
<removed non-relevant entries>
10.170.0.107 puppet.classroom.puppet.com puppet master.puppet.vm

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

Josh Cooper (Jira)

unread,
Mar 5, 2020, 2:07:02 AM3/5/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Component/s: Language
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Mar 5, 2020, 2:08:04 AM3/5/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9196
 
Re: Host type raises error for use of whitespace in host_aliases attribute while array delimiter is a whitespace

The host type was moved to a module in puppet 6. So any changes would need to be applied to the module and possibility backported to puppet 5.5.x (or not).

Josh Cooper (Jira)

unread,
Mar 5, 2020, 2:08:05 AM3/5/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages