(FACT-1383) Add Azure instance metadata fact#2298
Merged
mihaibuzgau merged 2 commits intopuppetlabs:3.xfrom Mar 2, 2021
Merged
(FACT-1383) Add Azure instance metadata fact#2298mihaibuzgau merged 2 commits intopuppetlabs:3.xfrom
mihaibuzgau merged 2 commits intopuppetlabs:3.xfrom
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`.
GabrielNagy
approved these changes
Mar 2, 2021
Contributor
GabrielNagy
left a comment
There was a problem hiding this comment.
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()); |
Contributor
There was a problem hiding this comment.
nit: should be AZ/Azure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds the
az_metadatafact that contains all available metadata information of the Microsoft Azure instance on which facter is being run. Support added for Linux and Windows.