diff --git a/README.md b/README.md index 3f177212..5f020298 100644 --- a/README.md +++ b/README.md @@ -443,6 +443,22 @@ To do this, pass a lambda as the value for the custom fact. The lambda is passed add_custom_fact :root_home, lambda { |os,facts| "/tmp/#{facts['hostname']}" } ``` +#### Overwrite existing facts + +You can also supply an optional input `:overwrite_fact` to the `add_custom_fact` method. + +This allows you to completely overwrite a fact already present in the facts hash as oppose to deep merging the fact values. + +```ruby +add_custom_fact :networking, { "ip" => "127.0.0.1", "ip6" => "FE80:0000:0000:0000:AAAA:AAAA:AAAA", "mac" => "AA:AA:AA:AA:AA:AA"}, :overwrite_fact => true +``` + +will return the following hash when queried for networking facts + +```ruby +:networking => { "ip" => "127.0.0.1", "ip6" => "FE80:0000:0000:0000:AAAA:AAAA:AAAA", "mac" => "AA:AA:AA:AA:AA:AA"} +``` + ### Supplying Custom External Facts through FacterDB Rspec-puppet-facts uses a gem called facterdb that contains many fact sets of various combinations that are pre generated. Rspec-puppet-facts queries facterdb to pull out a specific fact set to use when testing.