unable to execute shell script through non root user

33 views
Skip to first unread message

Supriya Uppalapati

unread,
Jun 4, 2014, 11:33:55 AM6/4/14
to puppet...@googlegroups.com
Hi,
 
I am trying to run shell script through non root user in puppet facts.
 
Here is my code.
 
 $cat cis_rhel6_check.rb
require 'facter'

Facter.add("cis_rhel6_check") do
  setcode do
 %x[ sh /tmp/cis_rhel6_check.sh ]
  end
end

the shell script is in
 
drwxrwxrwt. 178 root   root     tmp
ls -ls /tmp/cis_rhel6_check.sh
44 -rwxrwxrwx 1 root pe-puppet 43916 May 19 15:28 /tmp/cis_rhel6_check.sh
 
 
The issue was:
sh: /tmp/cis_rhel6_check.sh: No such file or directory
 
 
help me

jcbollinger

unread,
Jun 5, 2014, 9:47:07 AM6/5/14
to puppet...@googlegroups.com


On Wednesday, June 4, 2014 10:33:55 AM UTC-5, Supriya Uppalapati wrote:
Hi,
 
I am trying to run shell script through non root user in puppet facts.
 
Here is my code.
 
 $cat cis_rhel6_check.rb
require 'facter'

Facter.add("cis_rhel6_check") do
  setcode do
 %x[ sh /tmp/cis_rhel6_check.sh ]
  end
end

the shell script is in
 
drwxrwxrwt. 178 root   root     tmp
ls -ls /tmp/cis_rhel6_check.sh
44 -rwxrwxrwx 1 root pe-puppet 43916 May 19 15:28 /tmp/cis_rhel6_check.sh
 

This -----^^^^ seems to be contradicted by
 
 
The issue was:
sh: /tmp/cis_rhel6_check.sh: No such file or directory
 

this ----^^^^.

Can you, as that same non-root user, successfully execute the script both immediately before and immediately after eliciting that message from Facter (all on the same machine)?  Note in particular that the Puppet agent syncs custom facts and evaluates them (along with all the other facts) before requesting a catalog, so you cannot rely on the agent to put the script in place for you where the fact expects it to be before the fact is evaluated.

If it's a simple, 1st-party script then it might be a good approach to just rewrite it in Ruby in the fact body.

Alternatively, you could also consider turning it into an external fact.


John

Spencer Krum

unread,
Jun 5, 2014, 6:50:06 PM6/5/14
to puppet...@googlegroups.com
It's not perfect but is an interesting project and it would be great to get more help with it.

Thanks,
Spencer



--
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/b18bf7db-ccae-4687-9244-7d695ad5501e%40googlegroups.com.

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



--
Spencer Krum
(619)-980-7820
Reply all
Reply to author
Forward
0 new messages