custom script execution and sending output back to master

41 views
Skip to first unread message

kaustubh chaudhari

unread,
Aug 21, 2014, 10:25:02 AM8/21/14
to puppet...@googlegroups.com
Hi All,

I am looking to run a shell script on the agent, i know there are many ways to to do that through manifests, customfacts etc.

What i want is, how to send output of this shell script or a file that is created by shell script back to master.

eg: i am running below script

==
#!bin/bash
cat /etc/issue > /tmp/test.txt
==

I want puppet agent to send this file or the output of the command # cat /etc/issue to the master?

Is this possible, if yes can some one suggest or redirect me to some docs that i can refer too.

Thanks in advance!

Cheers
Kaustubh

Felix Frank

unread,
Aug 25, 2014, 5:46:30 PM8/25/14
to puppet...@googlegroups.com
On 08/21/2014 04:25 PM, kaustubh chaudhari wrote:
>
> I want puppet agent to send this file or the output of the command #
> cat /etc/issue to the master?
>
> Is this possible, if yes can some one suggest or redirect me to some
> docs that i can refer too.

That requirement is practically the verbatim definition of External Facts.

https://docs.puppetlabs.com/facter/2.1/custom_facts.html#external-facts

kaustubh chaudhari

unread,
Aug 27, 2014, 8:07:04 AM8/27/14
to puppet...@googlegroups.com
Thanks for the reply Felix,

I was wondering if we can get the output of a executable custom fact to a specific-seperate file instead of standard servername.yml file ?



With Warm Regards
Kaustubh.A.Chaudhari
(M)-09373102619



--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/pJRuahaMpmM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/53FBAEAE.7090600%40Alumni.TU-Berlin.de.
For more options, visit https://groups.google.com/d/optout.

Felix Frank

unread,
Aug 27, 2014, 8:41:52 AM8/27/14
to puppet...@googlegroups.com
On 08/27/2014 02:06 PM, kaustubh chaudhari wrote:
> Thanks for the reply Felix,
>
> I was wondering if we can get the output of a executable custom fact to
> a specific-seperate file instead of standard servername.yml file ?
>
>
>
> With Warm Regards
> Kaustubh.A.Chaudhari

Hi,

I'm at a loss to what you are referring here, specifically. What is that
servername.yml you speak of?

If you want a custom fact to cache its value in some file, then modify
it to store the value there.

HTH,
Felix

kaustubh chaudhari

unread,
Sep 2, 2014, 8:46:00 AM9/2/14
to puppet...@googlegroups.com
Hey,

Thanks for the reply. I tried what you suggested.

Sorry i am not a programmer, trying to find my way through.

I am looking for a best way to achieve this.

run a script on nodes user.sh which will create a file user.out, all i am looking for getting this user.out file back to the puppet master.

can you suggest any ideas thoughts on this ?
(i am running user.sh through my manifest)


With Warm Regards
Kaustubh.A.Chaudhari
(M)-09373102619


--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/pJRuahaMpmM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.

Felix Frank

unread,
Sep 2, 2014, 5:05:34 PM9/2/14
to puppet...@googlegroups.com
On 09/02/2014 02:45 PM, kaustubh chaudhari wrote:
> Hey,
>
> Thanks for the reply. I tried what you suggested.
>
> Sorry i am not a programmer, trying to find my way through.
>
> I am looking for a best way to achieve this.
>
> run a script on nodes user.sh which will create a file user.out, all i
> am looking for getting this user.out file back to the puppet master.
>
> can you suggest any ideas thoughts on this ?
> (i am running user.sh through my manifest)

It should be as simple as this custom fact:

Facter.add('user_sh_output') do
setcode do
File.read('/path/to/user.out')
end
end

https://docs.puppetlabs.com/facter/2.1/custom_facts.html#loading-custom-facts

This documentation explains what is what and where to put the code.

HTH,
Felix

kaustubh chaudhari

unread,
Sep 5, 2014, 8:12:06 AM9/5/14
to puppet...@googlegroups.com
Cool!!! Thanks for that Felix. It did what i was looking for.

The only catch was formatting of the file is messed, but i did some scripting on the master server and fixed it.

Thanks for your help .....

more i work with puppet.. more i fell in love with it!!!


With Warm Regards
Kaustubh.A.Chaudhari
(M)-09373102619



HTH,
Felix

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/pJRuahaMpmM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages