0

I need to insert multiple facts on many machines(100+) based on its hostname. All the machines get a single app deployed but the app configuration differs and also machines form part of different clusters. I am trying to find the right approach to implement this. One approach I found in How can I create a custom :host_role fact from the hostname? wherein there is a condition in facter add code block to check for hostname.

I was also thinking if there is a way to add multiple facts in one facter add call instead of having 1 per facter as that way I can logically organize my code on cluster/machines instead of facts.

Example:

Machine1 and its facts: clustername: C1 Java version: 1.8.60 ProcessRuns: 3

Machine2 and its facts: clustername: C1 Java version: 1.8.60 ProcessRuns: 1

Machine3 and its facts: clustername: C2 Java version: 1.9.00 ProcessRuns: 1

Machine4 and its facts: clustername: C2 Java version: 1.9.00 ProcessRuns: 2

Machine5 and its facts: clustername: C3 Java version: 1.9.60 ProcessRuns: 1

Aseem
  • 33
  • 1
  • 7

1 Answers1

0

I did not find any way to have multiple facts in 1 facter.add call so went with 1 call per fact I wanted to add.

The fact file finally looks something like this:

when "Machine1"
    Facter.add(:processcount) do
        setcode do
            3
        end
    end

when "Machine2", "Machine3", "Machine5"
    Facter.add(:processcount) do
        setcode do
            1
        end
    end
Aseem
  • 33
  • 1
  • 7