-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat: read Salt-Cloud Maps from the Pillar #47742
feat: read Salt-Cloud Maps from the Pillar #47742
Conversation
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.
This looks great!
Just a couple docs issue that need to be cleaned up.
salt/modules/cloud.py
Outdated
@@ -210,6 +210,8 @@ def map_run(path=None, **kwargs): | |||
|
|||
salt minionname cloud.map_run /path/to/cloud.map | |||
salt minionname cloud.map_run map_data='<actual map data>' | |||
# to use map data in pillar under salt:cloud:maps:<map_pillar>' |
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.
I believe this should be cloud:maps
not salt:cloud:maps
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.
Heya @gtmanfred, you're absolutely right! I was referencing it's location in the salt-formula pillar by accident. I have the correction for this on my laptop already - will push ASAP.
salt/modules/cloud.py
Outdated
@@ -210,6 +210,8 @@ def map_run(path=None, **kwargs): | |||
|
|||
salt minionname cloud.map_run /path/to/cloud.map | |||
salt minionname cloud.map_run map_data='<actual map data>' | |||
# to use map data in pillar under salt:cloud:maps:<map_pillar>' | |||
salt minionname cloud.map_run map_pillar='<map_pillar>' |
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.
Can you add a section above this for map_pillar and really describe what it is and how to use it?
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.
Once we get docs pushed that will be reflected here, I think this looks good:
https://docs.saltstack.com/en/latest/topics/cloud/config.html#pillar-configuration
I've added docs and am just watching for tests. Does this change need to include tests? Any other feedback to consider? |
Tests would be great. You can put them in unit tests, or if you want to write an integration test, we put them in salt/integration/cloud, and add the @expensiveTest decorator to them. Thanks! |
- The function signature `def map_run(path=None, **kwargs):`, so doesn't need to change. - Adding support for Cloud Maps in Pillar builds on the strength of the dynamic pillar-centric data organizing scheme. - in `Map.__init__`, a file path is read in as the class's `self.rendered_map` by the `Map.read` function, (which locates the file using the file path that the CloudClient is where most of the functionality is collected and it gets a copy of pillar values here (https://github.com/saltstack/salt/blob/develop/salt/cloud/init.py#L194-L206). (doc) - added usage and precedence info to `map_run()` at modules/cloud.py - added example pillar to topics/cloud/config.rst - corrected YAML indentation of example 7 in topics/cloud/map.rst
…maps-from-the-pillar
After looking into the cloud tests I'd prefer to come back to adding tests in a separate PR. |
What does this PR do?
Enable use of cloud map data sourced from the Pillar.
Uses the map data found in the pillar at
cloud:maps:
+ the key-name provided withmap_pillar
argument.Example
Where
To preserve backwards compatibility the
map_pillar
option is ignored in the presence of eithermap_data
orpath
arguments.The implementation is in two parts: (1) add maps data from the pillar at
CloudClient.__init__()
(alongside the existing similarly loadedprofiles
andproviders
info), and (2) allow for selecting and reading from this data inMap.read()
, which is the function that map data is sourced from.What issues does this PR fix or reference?
#40975
Previous Behavior
Allow loading map data from a file or from a JSON data structure via CLI.
New Behavior
Add a pillar-based option to the existing map data.
Tests written?
No so far, but what sort of tests should this have?
Commits signed with GPG?
No