Skip to content
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

Merged
merged 2 commits into from May 29, 2018

Conversation

Projects
None yet
3 participants
@nickgarber
Copy link
Contributor

commented May 20, 2018

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 with map_pillar argument.

Example

salt-call cloud.map_run map_pillar=my-prd-map

Where

cloud:
  maps:
    my-prd-map:
      named-profile-01:
        - named-instance-01
        - named-instance-02

To preserve backwards compatibility the map_pillar option is ignored in the presence of either map_data or path arguments.

The implementation is in two parts: (1) add maps data from the pillar at CloudClient.__init__() (alongside the existing similarly loaded profiles and providers info), and (2) allow for selecting and reading from this data in Map.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

@salt-jenkins salt-jenkins requested a review from saltstack/team-cloud May 20, 2018

@gtmanfred
Copy link
Contributor

left a comment

This looks great!

Just a couple docs issue that need to be cleaned up.

@@ -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>'

This comment has been minimized.

Copy link
@gtmanfred

gtmanfred May 21, 2018

Contributor

I believe this should be cloud:maps not salt:cloud:maps

This comment has been minimized.

Copy link
@nickgarber

nickgarber May 21, 2018

Author Contributor

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.

@@ -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>'

This comment has been minimized.

Copy link
@gtmanfred

gtmanfred May 21, 2018

Contributor

Can you add a section above this for map_pillar and really describe what it is and how to use it?

@cachedout
Copy link
Collaborator

left a comment

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

@nickgarber

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2018

I've added docs and am just watching for tests. Does this change need to include tests? Any other feedback to consider?

@gtmanfred

This comment has been minimized.

Copy link
Contributor

commented May 22, 2018

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!
Daniel

@nickgarber nickgarber changed the title [WIP] #40975 Feat: read Salt-Cloud Maps from the Pillar #40975 Feat: read Salt-Cloud Maps from the Pillar May 22, 2018

@nickgarber nickgarber changed the title #40975 Feat: read Salt-Cloud Maps from the Pillar feat: read Salt-Cloud Maps from the Pillar May 22, 2018

nickgarber added some commits May 21, 2018

Issue #40975
 - 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

@nickgarber nickgarber changed the title feat: read Salt-Cloud Maps from the Pillar [WIP] feat: read Salt-Cloud Maps from the Pillar May 25, 2018

@nickgarber

This comment has been minimized.

Copy link
Contributor Author

commented May 26, 2018

After looking into the cloud tests I'd prefer to come back to adding tests in a separate PR.

@gtmanfred gtmanfred merged commit cf1e5d4 into saltstack:develop May 29, 2018

3 of 10 checks passed

jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #5286 — ABORTED
Details
jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #10257 — ABORTED
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #19342 — ABORTED
Details
default Build finished.
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #23220 — FAILURE
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #22192 — FAILURE
Details
WIP work in progress – do not merge!
Details
codeclimate All good!
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #25476 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #17562 — SUCCESS
Details

@nickgarber nickgarber deleted the nickgarber:develop__wip-issue-40975-read-salt-cloud-maps-from-the-pillar branch May 29, 2018

@nickgarber nickgarber changed the title [WIP] feat: read Salt-Cloud Maps from the Pillar feat: read Salt-Cloud Maps from the Pillar May 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.