Skip to content

Add support to use current node parameters as references in class name#89

Merged
epcim merged 2 commits intosalt-formulas:developfrom
bbinet:param-references-class
Oct 2, 2020
Merged

Add support to use current node parameters as references in class name#89
epcim merged 2 commits intosalt-formulas:developfrom
bbinet:param-references-class

Conversation

@bbinet
Copy link
Copy Markdown

@bbinet bbinet commented Apr 2, 2020

so that with the following reclass config:

=> /etc/reclass/nodes/mynode.yml
classes:
  - common
parameters:
  project: myproject

=> /etc/reclass/classes/common.yml
class:
  - ${project}

=> /etc/reclass/classes/myproject.yml
parameters:
  some:
    project: parameters

The mynode parameters would be merged successfully by reclass and we will
get the following result for the parameters:

parameters:
  project: myproject
  some:
    project: parameters

Without this patch, this would result in the following error:

Failed to load ext_pillar reclass: ext_pillar.reclass: -> mynode
        In yaml_fs:///etc/reclass/classes/common.yml
        Class name ${project} not resolvable

@bbinet bbinet force-pushed the param-references-class branch from e2d8987 to 17b582b Compare April 2, 2020 16:04
bbinet added a commit to bbinet/docker-salt-master that referenced this pull request Apr 3, 2020
@epcim
Copy link
Copy Markdown
Member

epcim commented Sep 26, 2020

LGTM, tentative to merge, will you rebase (anything to add/comment?) ie: update docs?

bbinet added 2 commits October 1, 2020 15:04
so that with the following reclass config:

```
=> /etc/reclass/nodes/mynode.yml
classes:
  - common
parameters:
  project: myproject

=> /etc/reclass/classes/common.yml
class:
  - ${project}

=> /etc/reclass/classes/myproject.yml
parameters:
  some:
    project: parameters
```

The mynode parameters would be merged successfully by reclass and we will
get the following result for the parameters:

```
parameters:
  project: myproject
  some:
    project: parameters
```

Without this patch, this would result in the following error:

```
Failed to load ext_pillar reclass: ext_pillar.reclass: -> mynode
	In yaml_fs:///etc/reclass/classes/common.yml
	Class name ${project} not resolvable
```
so that we avoid side effect of list elements being merged twice in the
same list.

This commit adds a new "scalar_parameters" reclass config option
(defaults to False) used to indicate where to find scalar parameters in
node parameters dict.
@bbinet bbinet force-pushed the param-references-class branch from 62ed214 to 5656186 Compare October 1, 2020 13:05
@bbinet
Copy link
Copy Markdown
Author

bbinet commented Oct 1, 2020

@epcim I've just rebased on the latest develop branch.

@epcim epcim merged commit 6b345f1 into salt-formulas:develop Oct 2, 2020
@bbinet bbinet deleted the param-references-class branch February 4, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants