0
votes

I have a Scale Set I provisioned in Azure through Terraform.
(A scale set is an implicit availability set with 5 fault domains and 5 update domains.[ [1]])

I need to find out which Fault Domain each instance is in, so that I can configure my application cluster based on this, for improved redundancy.

So far, I have found only a single post remotely addressing thisenter link description here.

More context:

  • I can switch to regular VMs rather than a scale set if there is absolutely no other way.
  • I use ansible's dynamic inventory (azure_rm.py) which I have already customised to work with Scale Sets. If the solution can leverage this, extra kudos :)
  • My application allows me to define topology (datacentre, rack, etc.) and I am deploying it in a single Azure datacentre. Maybe I have missed a different solution?

Many many thanks, –Jeff

1
so with which tool do you want to find that out?4c74356b41
It would be perfect if I could find it out with the ansible dynamic-inventory. I am currently looking into the Python Azure SDK, which I think the former leverages.Jeff Hemmen
Something like this?Jeroen Heier
@JeroenHeier indeed, but I have to run it from a Linux machine.Jeff Hemmen
@JeroenHeier I'll see on Monday if I can use the same 'field names' in the Python API.Jeff Hemmen

1 Answers

0
votes

I have solved this by using the 169.254.169.254 'virtual IP' that allows a VM in the could to read its own metadata.

Specifically, I am running:

curl -H Metadata:true --silent "http://169.254.169.254/metadata/instance/compute/platformFaultDomain?api-version=2017-03-01&format=text"

in an Ansible task, and then using Ansible's local facts to make this available as an Ansible variable on the host.