puppet exec is not working

67 views
Skip to first unread message

moons...@gmail.com

unread,
Feb 29, 2016, 2:20:25 PM2/29/16
to Puppet Users
Hi All,

I following code is not working. Not sure why. 

exec { "file_system_cleanup":
                command => "touch /root/file_system_cleanup.log",
                path    => '/bin/:/sbin/:/usr/bin/:/usr/sbin',
                onlyif  => "test `df -h / | tail -1 | awk '{print $5}' | sed 's/%//g'` -gt 20",
         }



Thanks,

moons...@gmail.com

unread,
Feb 29, 2016, 2:27:23 PM2/29/16
to Puppet Users
When I run with debug option i see "$" is not working inside puppet. I tried to escape but it is not working. 

Debug: Exec[file_system_cleanup](provider=posix): Executing check 'test `df -h / | tail -1 | awk '{print }' | sed 's/%//g'` -gt 20'
Debug: Executing: 'test `df -h / | tail -1 | awk '{print }' | sed 's/%//g'` -gt 20'

Thanks,

Thomas Müller

unread,
Feb 29, 2016, 3:39:51 PM2/29/16
to Puppet Users
you need to escape $ signs or puppet will replace $5 with probably an empty string.


- Thomas 

warron.french

unread,
Feb 29, 2016, 7:57:23 PM2/29/16
to puppet...@googlegroups.com

How does one escape something like she'll values inside awk inside ruby code?

--
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/020c7283-a183-4d37-9460-209318875dc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vladislav Rusanov

unread,
Mar 1, 2016, 4:08:05 AM3/1/16
to puppet...@googlegroups.com
Hi!

Just add backslash before $:
Reply all
Reply to author
Forward
0 new messages