2

In hiera examples, I have seen people putting a fact called dc or datacenter in their hierarchies. However, its not clear anywhere as to how the fact is implemented to determine the data center. Is there something that already exists for the same? Or does everyone write their own custom fact? Would appreciate some help on understanding this.

  • 1
    I imagine how you would implement a datacenter fact depends on the source of the datacenter value for your environment. If you don't currently have a source for this information, you need to start with that. – Aaron Copley Feb 27 '15 at 18:53
  • Precisely. I just don't understand how to start with that. How do others do this? How I usually work with any kind of machine is that I log into the management interface of the infra provider, and provision a new machine which I get in some time depending on if it is a virtual machine or bare metal. There is nothing in the machine that I have which I can use for determining the data center or location of the machine. The only way I can think of achieving this is a have a process for bootstrapping a machine which is location aware and that puts a meta data file which may have this info. – vaidik Feb 28 '15 at 8:30
  • Does the above process sound good enough? Is that what everyone does or is there something else that people do to achieve this? – vaidik Feb 28 '15 at 8:31
  • Maybe you can tell what datacenter it is based on the subnet? Read the default gateway value and set the datacenter value based on a conditional test. – Aaron Copley Mar 2 '15 at 15:59
2

What are you describing is generally done by extending the core set of facts on the server. There are two ways of adding additional facts:

Custom facts - facts created through ruby code

External facts - facts generated by either output from an external script or even a static text-based data source

Either way, those facts can be generated programmable based on one more combination of attributes and/or deliberate identification of the server's role and location. In the case of the data center fact, if the datacenters are distinguished by IP address, you can specify the data center off of that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.