- 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
When the name of the resource is 1 letter long, it keeps repeating that entry every time puppet agent runs.
Expected Behavior
Not to keep creating new entries and detect that entry already exists.
Steps to Reproduce
Steps to reproduce the behavior:
- Create host resource with name that is only 1 character
 
host { 'x':
  ensure       => 'present',
  host_aliases => ['x.my.tld'],
  ip           => '127.0.0.1',
  target       => '/etc/test_hosts',
}
- Deploy to machine
 - Rerun agent
 - Check resulting file
 
# HEADER: This file was autogenerated at 2024-04-01 16:28:31 +0300
# HEADER: by puppet.  While it can still be managed manually, it
# HEADER: is definitely not recommended.
127.0.0.1   x   x.my.tld
127.0.0.1   x   x.my.tld
127.0.0.1   x   x.my.tld
Environment
- Version [Puppet 7.28.0, host_core v1.2.0]
 - Platform [AlmaLinux 8]
 
Additional Context
No problem with more than 1 character host name.
It seems the regular expression in here expects 1 character that is not #, + nor whitespace and it has to follow with at least 1 character of non whitespace, making it require at least 2 char long host name.
| hosts_pattern = '^([0-9a-f:]\S+)\s+([^#\s+]\S+)\s*(.*?)?(?:\s*#\s*(.*))?$' | 
Potentially fix could be
  hosts_pattern = '^([0-9a-f:]\S+)\s+([^#\s+]+)\s*(.*?)?(?:\s*#\s*(.*))?$'
But should be tested.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working