Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Several Ways to do this:


Environment Variables

If you create an environment variable that starts with a capital FACTER_ it will be available to the child shell processes

$ export FACTER_HERP='derp'

Then inside the puppet manifest, you could call the fact

${::herp}

Here is an example

$ export FACTER_HERP='derp'
$ puppet apply  -e "class foo { fail(\"herp is \'${::herp}\'\") } include foo" --debug
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/hostname_aliases.rb
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/operatingsystem_lowercase.rb
Error: herp is 'derp' at line 1 on node gitlab.example.com
Error: herp is 'derp' at line 1 on node gitlab.example.com

Or the same example again, but more human friendly

    class foo { 
       fail( "herp is ${::herp}") 
    } 
    include foo

Custom Facts

You can write your own fact in ruby then put it in the lib directory

Here is an example:

https://github.com/spuder/puppet-gitlab/blob/master/lib/facter/operatingsystem_lowercase.rb

Several Ways to do this:


Environment Variables

If you create an environment variable that starts with a capital FACTER_ it will be available to the child shell processes

$ export FACTER_HERP='derp'

Then inside the puppet manifest, you could call the fact

${::herp}

Here is an example

$ export FACTER_HERP='derp'
$ puppet apply  -e "class foo { fail(\"herp is \'${::herp}\'\") } include foo" --debug
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/hostname_aliases.rb
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/operatingsystem_lowercase.rb
Error: herp is 'derp' at line 1 on node gitlab.example.com
Error: herp is 'derp' at line 1 on node gitlab.example.com

Or the same example again, but more human friendly

    class foo { 
       fail( "herp is ${::herp}") 
    } 
    include foo

Custom Facts

You can write your own fact in ruby then put it in the lib directory

Here is an example:

https://github.com/spuder/puppet-gitlab/blob/master/lib/facter/operatingsystem_lowercase.rb

Several Ways to do this:

Environment Variables

If you create an environment variable that starts with a capital FACTER_ it will be available to the child shell processes

$ export FACTER_HERP='derp'

Then inside the puppet manifest, you could call the fact

${::herp}

Here is an example

$ export FACTER_HERP='derp'
$ puppet apply  -e "class foo { fail(\"herp is \'${::herp}\'\") } include foo" --debug
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/hostname_aliases.rb
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/operatingsystem_lowercase.rb
Error: herp is 'derp' at line 1 on node gitlab.example.com
Error: herp is 'derp' at line 1 on node gitlab.example.com

Or the same example again, but more human friendly

    class foo { 
       fail( "herp is ${::herp}") 
    } 
    include foo

Custom Facts

You can write your own fact in ruby then put it in the lib directory

Here is an example:

https://github.com/spuder/puppet-gitlab/blob/master/lib/facter/operatingsystem_lowercase.rb

Several Ways to do this:

Environment Variables

If you create an environment variable that starts with a capital FACTER_ it will be available to the child shell processes

$ export FACTER_HERP='derp'

Then inside the puppet manifest, you could call the fact

${::herp}

Here is an example

$ export FACTER_HERP='derp'
$ puppet apply  -e "class foo { fail(\"herp is \'${::herp}\'\") } include foo" --debug
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/hostname_aliases.rb
Info: Loading facts in /etc/puppet/modules/gitlab/lib/facter/operatingsystem_lowercase.rb
Error: herp is 'derp' at line 1 on node gitlab.example.com
Error: herp is 'derp' at line 1 on node gitlab.example.com

Or the same example again, but more human friendly

    class foo { 
       fail( "herp is ${::herp}") 
    } 
    include foo

Custom Facts

You can write your own fact in ruby then put it in the lib directory

Here is an example:

https://github.com/spuder/puppet-gitlab/blob/master/lib/facter/operatingsystem_lowercase.rb