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(map): update to v4 and add config.get lookup from multiple roots #186

Merged
merged 3 commits into from
Aug 1, 2020

Conversation

baby-gnu
Copy link
Contributor

@baby-gnu baby-gnu commented Jul 21, 2020

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

saltstack-formulas/libvirt-formula#79

Describe the changes you're proposing

Use the new v4 map.jinja and maintain the compatibility with user pillars by configuring a new map_jinja:config_get_roots parameter.

The map.jinja use the generic exported name mapdata as in the latest libvirt-formula.

Pillar / config required to test the proposed changes

It's already provided by test/salt/pillar/default.sls.

Debug log showing how the proposed changes work

       [INFO    ] Fetching file from saltenv 'base', ** done ** 'openssh/map.jinja'
       [DEBUG   ] In saltenv 'base', looking at rel_path 'openssh/libsaltcli.jinja' to resolve 'salt://openssh/libsaltcli.jinja'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/openssh/libsaltcli.jinja' to resolve 'salt://openssh/libsaltcli.jinja'
       [DEBUG   ] LazyLoaded log.debug
       [DEBUG   ] [libsaltcli] the salt command type has been identified to be: local
       [DEBUG   ] map.jinja: initialise parameters from openssh/parameters/defaults.yaml
       [DEBUG   ] In saltenv 'base', looking at rel_path 'openssh/parameters/defaults.yaml' to resolve 'salt://openssh/parameters/defaults.yaml'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/openssh/parameters/defaults.yaml' to resolve 'salt://openssh/parameters/defaults.yaml'
       [DEBUG   ] map.jinja: lookup 'map_jinja' configuration sources
       [DEBUG   ] LazyLoaded config.get
       [DEBUG   ] key: map_jinja:sources, ret: _|-
       [DEBUG   ] key: openssh:map_jinja:sources, ret: _|-
       [DEBUG   ] map.jinja: load parameters with sources from ['osarch', 'os_family', 'os', 'osfinger', 'config_get_lookup', 'config_get', 'id']
       [DEBUG   ] map.jinja: initialise 'config.get' roots with 'tplroot' openssh
       [DEBUG   ] key: map_jinja:config_get_roots, ret: _|-
       [DEBUG   ] key: openssh:map_jinja:config_get_roots, ret: _|-
       [DEBUG   ] map.jinja: load parameters with 'config.get' from roots [u'openssh', u'sshd_config', u'ssh_config']
       [DEBUG   ] key: openssh:strategy, ret: _|-
       [DEBUG   ] key: openssh:merge_lists, ret: _|-
       [DEBUG   ] map.jinja: load parameters from file openssh/parameters/osarch/x86_64.yaml
       [DEBUG   ] Could not find file 'salt://openssh/parameters/osarch/x86_64.yaml' in saltenv 'base'
       [DEBUG   ] map.jinja: load parameters from file openssh/parameters/os_family/Arch.yaml
       [DEBUG   ] In saltenv 'base', looking at rel_path 'openssh/parameters/os_family/Arch.yaml' to resolve 'salt://openssh/parameters/os_family/Arch.yaml'
       [DEBUG   ] In saltenv 'base', ** considering ** path '/tmp/kitchen/var/cache/salt/minion/files/base/openssh/parameters/os_family/Arch.yaml' to resolve 'salt://openssh/parameters/os_family/Arch.yaml'
       [DEBUG   ] map.jinja: merge parameters from openssh/parameters/os_family/Arch.yaml
       [DEBUG   ] LazyLoaded slsutil.merge
       [DEBUG   ] map.jinja: load parameters from file openssh/parameters/os/Arch.yaml
       [DEBUG   ] Could not find file 'salt://openssh/parameters/os/Arch.yaml' in saltenv 'base'
       [DEBUG   ] key: osfinger, ret: _|-
       [DEBUG   ] map.jinja: load parameters from file openssh/parameters/osfinger.yaml
       [DEBUG   ] Could not find file 'salt://openssh/parameters/osfinger.yaml' in saltenv 'base'
       [DEBUG   ] map.jinja: retrieve 'openssh:lookup' with 'config.get', merge: strategy='None'
       [DEBUG   ] key: openssh:lookup, ret: _|-
       [DEBUG   ] map.jinja: merge 'openssh:lookup' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: retrieve 'sshd_config:lookup' with 'config.get', merge: strategy='None'
       [DEBUG   ] key: sshd_config:lookup, ret: _|-
       [DEBUG   ] map.jinja: merge 'sshd_config:lookup' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: retrieve 'ssh_config:lookup' with 'config.get', merge: strategy='None'
       [DEBUG   ] key: ssh_config:lookup, ret: _|-
       [DEBUG   ] map.jinja: merge 'ssh_config:lookup' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: retrieve 'openssh' with 'config.get', merge: strategy='None'
       [DEBUG   ] map.jinja: merge 'openssh' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: retrieve 'sshd_config' with 'config.get', merge: strategy='None'
       [DEBUG   ] map.jinja: merge 'sshd_config' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: retrieve 'ssh_config' with 'config.get', merge: strategy='None'
       [DEBUG   ] map.jinja: merge 'ssh_config' retrieved with 'config.get', merge: strategy='smart', lists='False'
       [DEBUG   ] map.jinja: load parameters from file openssh/parameters/id/7c13b93cdef4.yaml
       [DEBUG   ] Could not find file 'salt://openssh/parameters/id/7c13b93cdef4.yaml' in saltenv 'base'
       [DEBUG   ] map.jinja: save parameters in variable 'mapdata'

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

@baby-gnu baby-gnu requested a review from a team as a code owner July 21, 2020 15:41
@pull-assistant
Copy link

pull-assistant bot commented Jul 21, 2020

Score: 0.93

Best reviewed: commit by commit


Optimal code review plan

     feat(map): update to v4 “map.jinja”

     feat(map): config.get lookups from configurable roots

     chore: add breaking change message for new map.jinja

Powered by Pull Assistant. Last update df477b2 ... a0af21a. Read the comment docs.

The `map.jinja` now exports a single variable called `mapdata`.

We extract the `openssh`, `sshd_config` and `ssh_config` from it to
minimize the changes to `.sls` files.
@baby-gnu baby-gnu force-pushed the feature/v4-map.jinja branch 2 times, most recently from 986518d to 2adbb2d Compare July 31, 2020 09:20
We avoid compatibility break with user pillars by looking up
configuration values using `config.get` in configurable roots.

We provide a new parameter `map_jinja:config_get_roots` in the formula
`parameters/defaults.yaml`to retrives values not only from
`tplroot=openssh` but from `sshd_config` and `ssh_config` too.

We need to update the `_mapdata` reference files to include the new
`map_jinja:config_get_roots`.
BREAKING CHANGE: `map.jinja` has been upgraded from using `pillar.get`
to `config.get`.
@myii myii merged commit db67ce6 into saltstack-formulas:master Aug 1, 2020
@myii
Copy link
Member

myii commented Aug 1, 2020

Merged, excellent work @baby-gnu!

@myii
Copy link
Member

myii commented Aug 1, 2020

@baby-gnu Something worth thinking about (for v6 of map.jinja?!): how about using Salt targetting grammar instead? See this from the discussion with @OrangeDog in the Slack channel.

https://freenode.logbot.info/saltstack-formulas/20200730#c4572975-c4573065

- - -
16:13 OrangeDog[m] Is it possible to make it less ambiguous? There's nothing stopping there being a grain called config_get_lookup , or a function os.family
16:13 myii nebuchadnezzar: Ready to be merged from your end?
16:13 OrangeDog[m] For example, see the targeting grammar
16:14 nebuchadnezzar myii: yes
16:15 myii OK, I'll do that once it's green -- thanks for all of your efforts!
16:15 nebuchadnezzar see you tomorrow ;-)
16:16 myii[m] OrangeDog: Any suggestions? We did have some other ideas but they're lost somewhere in GitHub Discussions (not searchable yet).
16:18 OrangeDog[m] grain:os_family , G!os_family , grains[os_family], salt:config.get , module:config.get, F!config.get , config.get() , salt[config.get]
16:19 OrangeDog[m] (edited) ... , G!os_family , grains[os_family], salt:config.get , module:config.get, F!config.get , ... => ... , G@os_family , grains[os_family], salt:config.get , module:config.get, F⊙cg , ...

@saltstack-formulas-travis

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@myii
Copy link
Member

myii commented Aug 1, 2020

Note: Checked this across all platforms in Travis and only failing on CentOS-6, as expected from our discussions in Slack/IRC:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants