-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(FACT-1383) Add Azure instance metadata fact #2298
Conversation
dfbb88f
to
1888c22
Compare
This commit adds the `az_metadata` fact that contains all available metadata information of the Microsoft Azure instance on which facter is being run. Support added for Linux and Windows.
1888c22
to
37113d3
Compare
Due to the previous nature of the test (expecting to not see any `caching` in stderr output), the `az_metadata` fact was causing `no_cache_should_not_refresh_cached_facts.rb` and `no_cache_should_not_cache_facts.rb` to fail because of its output. Seen example: `"osDisk" => { "caching" => "ReadOnly"` This commit makes the tests more specific: from not expecting any `caching` to not expecting any `caching values for`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍, just a minor comment about a leftover EC2
. Tested both this and the Ruby version and these are my findings:
- the fact correctly resolves if on hyperv and the endpoint is available ✔️
- the fact silently fails to resolve if on hyperv and the endpoint is not available ✔️
- the fact does not resolve at all if not on hyperv ✔️
The only difference I was able to spot was how empty arrays are rendered, but this is something that appears to be different in the Facter 4 code that pretty-prints the json, which is unrelated to this work:
$ diff -u <(bundle exec facter az_metadata) <(../3.x_facter/bin/facter az_metadata)
--- /dev/fd/63 2021-03-02 17:22:36.085844995 +0000
+++ /dev/fd/62 2021-03-02 17:22:36.085844995 +0000
@@ -21,9 +21,7 @@
platformFaultDomain => "0",
platformUpdateDomain => "0",
provider => "Microsoft.Compute",
- publicKeys => [
-
- ],
+ publicKeys => [],
publisher => "canonical",
resourceGroupName => "test-facter-azure_group",
resourceId => "/subscriptions/de8aa4b1-87d7-41be-ada7-5e2e4b4768e5/resourceGroups/test-facter-azure_group/providers/Microsoft.Compute/virtualMachines/test-facter-azure",
@@ -87,9 +85,7 @@
},
subscriptionId => "de8aa4b1-87d7-41be-ada7-5e2e4b4768e5",
tags => "",
- tagsList => [
-
- ],
+ tagsList => [],
version => "20.04.202102020",
vmId => "9e5e7e81-8db0-4ff1-adc3-2dcfcd7f2727",
vmScaleSetName => "",
@@ -114,9 +110,7 @@
]
},
ipv6 => {
- ipAddress => [
-
- ]
+ ipAddress => []
},
macAddress => "000D3A38BFF9"
}
} | ||
} catch (lth_curl::http_request_exception& ex) { | ||
LOG_DEBUG("Azure instance metadata fact is unavailable: not running under an Azure instance or Azure is not responding in a timely manner."); | ||
LOG_TRACE("EC2 metadata request failed: {1}", ex.what()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be AZ/Azure
This commit adds the
az_metadata
fact that contains all available metadata information of the Microsoft Azure instance on which facter is being run. Support added for Linux and Windows.