On 9/7/14 11:41 AM, omfg9899 wrote:
>   I know I must be missing something stupid, but I have tried for 2 days
> now without success.
>  
>  I am using puppet stand alone, no master.
> 
>  I need a simple custom fact to be created to assist in deploying the
> correct configuration at build time.
>   I made this super simple fact.. 
> 
> <fact>
> # envir.rb
> 
> Facter.add('environment_class') do
>     setcode '/bin/cat /etc/default/environment.info'
>     end
> </fact>
> 
> I have placed this file in MANY different places as suggested and it
> never works.  However, if i run facter envir.rb  it will stick the fact
> into the fact list.  This fact basically determines if the system is
> dev/cert or prod and assigns certain configs for various services based
> on that value.  The only thing in the environment.info file is going to
> be prod or cer or prod.
>   Out of desperation I ran strace to see if it was even looking at the
> file and to my surprise it was.  I  was surprised to see that it was
> infact touching the file but can't understand the output.
> 
> <output>
> tat("/etc/facter/facts.d/envir.rb", {st_mode=S_IFREG|0755, st_size=104,
> ...}) = 0
> geteuid()                               = 0
> getegid()                               = 0
> getuid()                                = 0
> getgid()                                = 0
> access("/etc/facter/facts.d/envir.rb", X_OK) = 0
> .......
> open("/etc/facter/facts.d/envir.rb.ttl", O_RDONLY) = -1 ENOENT (No such
> file or directory)
> stat("/etc/facter/facts.d/envir.rb", {st_mode=S_IFREG|0755, st_size=104,
> ...}) = 0
> rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
> pipe([5, 6])                            = 0
> futex(0x7f5fe8480a84, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7f5fe8480a80,
> {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
> futex(0x7f5fe8480ab0, FUTEX_WAKE_PRIVATE, 1) = 1
> clone(child_stack=0,
> flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
> child_tidptr=0x7f5fe86b19d0) = 4959
> rt_sigaction(SIGVTALRM, {0x7f5fe81c74e0, [], SA_RESTORER,
> 0x7f5fe7f8c4a0}, {0x7f5fe81c74e0, [], SA_RESTORER, 0x7f5fe7f8c4a0}, 8) = 0
> clone(child_stack=0x7f5fe2523ff0,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
> parent_tidptr=0x7f5fe25249d0, tls=0x7f5fe2524700,
> child_tidptr=0x7f5fe25249d0) = 4960
> futex(0x7f5fe8480ae4, FUTEX_WAIT_PRIVATE, 7, NULL) = 0
> futex(0x7f5fe8480ab0, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
> futex(0x7f5fe8480ab0, FUTEX_WAKE_PRIVATE, 1) = 0
> close(6)                                = 0
> fcntl(5, F_GETFL)                       = 0 (flags O_RDONLY)
> ./facter_dot_d.rb:148: command not found: /etc/facter/facts.d/envir.rb
> </output>
> 
>  Any thoughts?
> 
>  Thanks in advance.
> 
>  J
> 

Hi,

Take a look at external facts[1]. Since your fact is spawning a shell to
cat a file, you could get the same functionality without the effort of
maintaining that code.

Given a text file, /etc/facter/facts.d/environment_class.txt with the
contents

  environment_class=some_text

you would have the custom fact 'environment_class' with the value
'some_text'.

[1] -
https://docs.puppetlabs.com/facter/latest/custom_facts.html#external-facts

Best regards,
-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/540DEE24.8080109%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to