temp dir fact

280 views
Skip to first unread message

Cristian Falcas

unread,
May 3, 2014, 1:50:11 PM5/3/14
to puppet...@googlegroups.com
Hello,

Does puppet have a variable for temporary directories for each os, or
I need to write a custom fact with this?

Best regards,
Cristian Falcas

liu.cy

unread,
May 4, 2014, 9:43:38 AM5/4/14
to puppet...@googlegroups.com
http://docs.puppetlabs.com/guides/custom_facts.html

facter have two type custom_facts: custom_facts and external facts

Facter offers a few methods of loading facts:

  • $LOAD_PATH, or the ruby library load path
  • The environment variable ‘FACTERLIB’
  • Facts distributed using pluginsync
you can just use the environment style, puts custom facts in ~/lib/ruby/<os>/facter/ and export FACTERLIB=~/lib/ruby/facter/`uname`
custom facts wrote by ruby code, this is a sample.
# hardware_platform.rb Facter.add("hardware_platform") do setcode do Facter::Util::Resolution.exec('/bin/uname --hardware-platform') end end

the other style facts is external facts.
External facts provide a way to use arbitrary executables or scripts as facts, or set facts statically with structured data. If you’ve ever wanted to write a custom fact in Perl, C, or a one-line text file, this is how.
external facts should default put in /etc/facter/facts.d, and you can use --external-dir option to specify.

Cristian Falcas

unread,
May 4, 2014, 10:24:34 AM5/4/14
to puppet...@googlegroups.com
Thank you for your answer
> --
> 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/379fbab6-5826-424b-9309-99b75e3cefda%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

liu.cy

unread,
May 4, 2014, 11:30:10 AM5/4/14
to puppet...@googlegroups.com
it looks like I misunderstood what you asked for.
facter doesn't built-in temp directory fact, but i think the temp dir of all unix-like os is /tmp, it only helps when you both mange unix-like and windows hosts.

On Sunday, May 4, 2014 1:50:11 AM UTC+8, Cristian Falcas wrote:

Cristian Falcas

unread,
May 5, 2014, 2:22:49 AM5/5/14
to puppet...@googlegroups.com
I need it for a windows module: some predetermined path where to
download a file. I have no idea if in windows there is such a place,
like unix tmp (meaning is not relativ to user name)
> --
> 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/bb02dd17-ddcd-49bb-86a5-de72d2bac5e5%40googlegroups.com.

liu.cy

unread,
May 5, 2014, 12:12:42 PM5/5/14
to puppet...@googlegroups.com
it can be %SystemRoot%\TEMP, aka c:\windows\temp

jcbollinger

unread,
May 5, 2014, 1:21:06 PM5/5/14
to puppet...@googlegroups.com


On Saturday, May 3, 2014 12:50:11 PM UTC-5, Cristian Falcas wrote:
Hello,

Does puppet have a variable for temporary directories for each os, or
I need to write a custom fact with this?



You can get the complete list of facts that any node will provide to Puppet by running "facter -p" on that node.  I don't see a standard fact naming a designated temporary directory when I try it on CentOS 5 or 6.


John

Cristian Falcas

unread,
May 6, 2014, 4:17:30 AM5/6/14
to puppet...@googlegroups.com
I have now something like this in one of my modules:

require 'facter'
Facter.add("temp_dir") { setcode { Dir::tmpdir } }


Why I was asking about a standard fact: I wanted to contribute to some
external module and I needed to download a file on Windows.machines.
And I realized there is now standard location where any user can
download files.

Thank you all for your answers.

Best regards,
Cristian Falcas
> --
> 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/4a312035-105f-4d2f-9788-d9841f9900a0%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages