How to read the files of puppet agent.

927 views
Skip to first unread message

shashank sinha

unread,
Jul 9, 2014, 3:30:31 AM7/9/14
to puppet...@googlegroups.com
Hi,

I have written a code on template to open & read file i.e passwd but it reads the file from the puppet server (Master-node) rather I want to read the file of each agent-nodes.

Is it possible to read files from the agent node or to copy the files from agent to master?

Thanks
Shashank

Martijn

unread,
Jul 9, 2014, 4:19:38 AM7/9/14
to puppet...@googlegroups.com
Shashank,

The templates are compiled on the master but can incorporate data sent to it from several sources, such as built-in facts, custom facts and exported resources. Copying files from node to master isn't possible in the manner that you want.

I suppose in this case setting a custom fact is the easiest solution. You can create a custom fact in various ways. They can be simple hardcoded files on the node, or run a simple or complex program on the node to determine the desired value. In your case a simple script that reads a file on the agent node and outputs a fact would be easy. Check out the following docs for info and examples:
You could also look at Exported Resources (http://docs.puppetlabs.com/guides/exported_resources.html) which will 'share' actual Puppet resources between nodes. Kind of hard to explain, so check the Nagios example in the doc.

Hope this helps,
Martijn

Op woensdag 9 juli 2014 09:30:31 UTC+2 schreef shashank sinha:

shashank

unread,
Jul 10, 2014, 5:55:08 AM7/10/14
to puppet...@googlegroups.com
Hi Martijn,

Thanks for the suggestion.

Just now I have implemented the custom facts as you have suggested and its exactly meets the requirement.

Thanks
Shashank
Reply all
Reply to author
Forward
0 new messages