puppet does not like ~ in file name

30 views
Skip to first unread message

Fabrice Bacchella

unread,
Nov 10, 2016, 9:17:05 AM11/10/16
to Puppet Users
I need a file called /etc/cron.hourly/~cronalive. I don't like the ~ but don't have real choice here.

So I defined the following resource:

file{'/etc/cron.hourly/~cronalive':
....
}

But if fails with:

Error: Could not set 'file' on ensure: user cronalive20161110-32243-1wx31rr doesn't exist at .../manifests/node.pp:35

I think it resolve ~cronalive using shell resolution and looks for the homedir of this user. Is there any work around for that ? Adding a \ create a file whose name starts with a \, using path => '/etc/cron.hourly/~cronalive' gives the same result.

Rob Nelson

unread,
Nov 10, 2016, 10:13:42 AM11/10/16
to puppet...@googlegroups.com
I don't have an answer, but did you verify that when you remove the tilde, the resource applies properly? If so, this does sound like a bug of some sort.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/45C5718D-14EA-4C2F-BBE0-04AB750075AE%40orange.fr.
For more options, visit https://groups.google.com/d/optout.

Fabrice Bacchella

unread,
Nov 10, 2016, 11:03:28 AM11/10/16
to puppet...@googlegroups.com
yes it works once removed.

Christopher Wood

unread,
Nov 10, 2016, 11:44:47 AM11/10/16
to puppet...@googlegroups.com
I can reproduce this using puppet 4.4.2 from puppet-agent 1.4.2, definitely seems like a bug. You can "cd ~user" in a bash shell so I wonder if somebody somewhere made something which works similarly. I'd be interested in watching the bug you file because I'm nosy.

$ cat /tmp/x.pp
file { '/tmp/x~x':
content => "x\n",
}

file { '/tmp/~x':
content => "x\n",
}

file { '/tmp/x~':
content => "x\n",
}
$ puppet apply /tmp/x.pp
Notice: Compiled catalog for cwl.hostopia.com in environment production in 0.04 seconds
Notice: /Stage[main]/Main/File[/tmp/x~x]/ensure: defined content as '{md5}401b30e3b8b5d629635a5c613cdb7919'
Error: Could not set 'file' on ensure: user x20161110-7118-fwfpjo doesn't exist at 5:/tmp/x.pp
Error: Could not set 'file' on ensure: user x20161110-7118-fwfpjo doesn't exist at 5:/tmp/x.pp
Wrapped exception:
user x20161110-7118-fwfpjo doesn't exist
Error: /Stage[main]/Main/File[/tmp/~x]/ensure: change from absent to file failed: Could not set 'file' on ensure: user x20161110-7118-fwfpjo doesn't exist at 5:/tmp/x.pp
Notice: /Stage[main]/Main/File[/tmp/x~]/ensure: defined content as '{md5}401b30e3b8b5d629635a5c613cdb7919'
Notice: Applied catalog in 0.15 seconds


On Thu, Nov 10, 2016 at 05:03:17PM +0100, Fabrice Bacchella wrote:
> yes it works once removed.
>
> Le 10 nov. 2016 à 16:13, Rob Nelson <[1]rnel...@gmail.com> a écrit :
> I don't have an answer, but did you verify that when you remove the
> tilde, the resource applies properly? If so, this does sound like a bug
> of some sort.
> Rob Nelson
> [2]rnel...@gmail.com
> On Thu, Nov 10, 2016 at 9:16 AM, Fabrice Bacchella
> <[3]fabrice....@orange.fr> wrote:
>
> I need a file called /etc/cron.hourly/~cronalive. I don't like the ~
> but don't have real choice here.
>
> So I defined the following resource:
>
>     file{'/etc/cron.hourly/~cronalive':
>        ....
>     }
>
> But if fails with:
>
> Error: Could not set 'file' on ensure: user
> cronalive20161110-32243-1wx31rr doesn't exist at
> .../manifests/node.pp:35
>
> I think it resolve ~cronalive using shell resolution and looks for the
> homedir of this user. Is there any work around for that ? Adding a \
> create a file whose name starts with a \, using path   =>
> '/etc/cron.hourly/~cronalive' gives the same result.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [4]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [5]https://groups.google.com/d/msgid/puppet-users/A326124B-ACEA-43FB-A3A9-37107DD749F0%40orange.fr.
> For more options, visit [6]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:rnel...@gmail.com
> 2. mailto:rnel...@gmail.com
> 3. mailto:fabrice....@orange.fr
> 4. mailto:puppet-users...@googlegroups.com
> 5. https://groups.google.com/d/msgid/puppet-users/A326124B-ACEA-43FB-A3A9-37107DD749F0%40orange.fr?utm_medium=email&utm_source=footer
> 6. https://groups.google.com/d/optout

Rob Nelson

unread,
Nov 10, 2016, 12:22:23 PM11/10/16
to puppet...@googlegroups.com
Agreed, please sure the ticket link!

That said, who decided a tilde to start a file name was good for anything but a temp file??? I understand you have no choice as a user, but someone somewhere, somewhen, chose it :(
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20161110164439.GA24818%40iniquitous.heresiarch.ca.

For more options, visit https://groups.google.com/d/optout.


--

Fabrice Bacchella

unread,
Nov 10, 2016, 12:55:21 PM11/10/16
to puppet...@googlegroups.com

> Le 10 nov. 2016 à 18:22, Rob Nelson <rnel...@gmail.com> a écrit :
>
> That said, who decided a tilde to start a file name was good for anything but a temp file??? I understand you have no choice as a user, but someone somewhere, somewhen, chose it :(

because in the sort algorithm from glob, ~ is one of the only the very few characters that goes after z and it's printable, look at LC_COLLATE in http://pubs.opengroup.org/onlinepubs/007908775/xbd/locale.html#tag_005_003_002.

John Gelnaw

unread,
Nov 10, 2016, 2:14:25 PM11/10/16
to Puppet Users
First, a tilde in a filename is a special character in most shells-- you're setting yourself up for pain, and unexpected behavior.

Secondly, on many linux systems, run-parts (the engine behind cron.hourly) will not run a script with a tilde in the name, since it will only match the regex /[A-Za-z0-9_]+/

If you're concerned about order, number them all. 

Francois Lafont

unread,
Nov 10, 2016, 4:28:33 PM11/10/16
to puppet...@googlegroups.com
Hi,

I confirm the problem with the lastest version of Puppet (4.8.0)
on my Ubuntu Trusty (ie puppet-agent 1.8.0) :


--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--
root@puppet ~ # puppet --version
4.8.0

root@puppet ~ # puppet apply -e "file {'/tmp/f': ensure => present, content => 'Hello' }"
Notice: Compiled catalog for puppet.athome.priv in environment production in 0.10 seconds
Notice: /Stage[main]/Main/File[/tmp/f]/ensure: defined content as '{md5}8b1a9953c4611296a827abf8c47804d7'
Notice: Applied catalog in 0.21 seconds

root@puppet ~ # puppet apply -e "file {'/tmp/f~': ensure => present, content => 'Hello' }"
Notice: Compiled catalog for puppet.athome.priv in environment production in 0.10 seconds
Notice: /Stage[main]/Main/File[/tmp/f~]/ensure: defined content as '{md5}8b1a9953c4611296a827abf8c47804d7'
Notice: Applied catalog in 0.19 seconds

root@puppet ~ # puppet apply -e "file {'/tmp/~f': ensure => present, content => 'Hello' }"
Notice: Compiled catalog for puppet.athome.priv in environment production in 0.10 seconds
Error: Could not set 'present' on ensure: user f20161110-3350-13n4ulf doesn't exist at line 1
Error: Could not set 'present' on ensure: user f20161110-3350-13n4ulf doesn't exist at line 1
Wrapped exception:
user f20161110-3350-13n4ulf doesn't exist
Error: /Stage[main]/Main/File[/tmp/~f]/ensure: change from absent to present failed: Could not set 'present' on ensure: user f20161110-3350-13n4ulf doesn't exist at line 1
Notice: Applied catalog in 0.19 seconds
--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--


So, it's seems to be tricky because:

- no problem with '/tmp/f' (normal)
- no problem with '/tmp/f~'
- but error with '/tmp/~f'

I haven't seen a ticket on https://tickets.puppetlabs.com yet.
It would deserve one in my humble opinion. I can create it is you want. ;)

Regards.

Christopher Wood

unread,
Nov 10, 2016, 5:47:19 PM11/10/16
to puppet...@googlegroups.com
I reproduced this with 4.8.0 and filed a ticket.

https://tickets.puppetlabs.com/browse/PUP-6914

Seems like it's a ruby thing?

https://ruby-doc.org/core-2.1.8/File.html#method-c-expand_path

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/file.rb

Usual disclaimer, not a programmer, somebody with a spare clue feel free to pass it along. Or just add said clue to the ticket.
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/864517c9-e8cb-093e-994f-805e6a628c59%40gmail.com.

Fabrice Bacchella

unread,
Nov 10, 2016, 6:43:50 PM11/10/16
to puppet...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages