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

[BUG] Saltclass can't reuse variable which have type list or dict #66808

Open
nskkiselev opened this issue Aug 15, 2024 · 3 comments
Open

[BUG] Saltclass can't reuse variable which have type list or dict #66808

nskkiselev opened this issue Aug 15, 2024 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@nskkiselev
Copy link

nskkiselev commented Aug 15, 2024

Description
I used to use reclass (http://reclass.pantsfullofunix.net/) for pillar data.
Now I use its fork https://github.com/salt-formulas/reclass because it was rewritten on python3.

I want to replace reclass with saltclass because it has interesting features which I need.
But I encountered problems while testing saltclass.
Saltclass can't expand pillar value that is not of type 'str'. I tried to use yaml possibilities to reuse variables.

And I can see from these issues that they have existed since 2018.
#50262
#61934
#52407

Given this, I have following questions:

  1. Will you remove saltclass in the feature from the Core Modules / Supported Modules? Maybe you want to remove it completely and therefore do not solve this problem.
  2. Could you advise me how I can reuse pillar variables using saltclass? Maybe there is a way to do this using jinja.
  3. When you will solve problem with expanding pillar value that is not of type 'str'?

Setup

Example pillar data
cat nodes/server01.test.local.yml

environment: base
states:
pillars:
  test:
    S1: "Test S1"

    S2: ${test:S1}

    L1:
      - "item1"
      - "item2"
      - "item3"

    L2: ${test:L1}

    D1:
      D1_item1: item1
      D1_item2: item2

    D2: ${test:D1}

Steps to Reproduce the behavior
After this command
salt "server01.test.local" saltutil.refresh_pillar

I can see following errors in the /var/log/master file

[CRITICAL][2219096] Pillar render error: Failed to load ext_pillar saltclass: replace() argument 2 must be str, not list 
or 
[CRITICAL][2355663] Pillar render error: Failed to load ext_pillar saltclass: replace() argument 2 must be str, not dict

1 Call salt -v "server01.test.local" pillar.get test:S2
It works as expected.
Output:

server01.test.local:
    ----------
    test:S2:
        Test S1

2 Call salt -v "server01.test.local" pillar.get test:L2
Output:

server01.test.local:
    ----------
    test:L2:
        ${test:L1}

3 Call salt -v "server01.test.local" pillar.get test:D2
Output:

server01.test.local:
    ----------
    test:D2:
        ${test:D1}

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3007.1
 
Python Version:
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
      dateutil: 2.8.2
     docker-py: 7.1.0
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.16.0
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
Salt Extensions:
 saltext.vault: 1.0.0
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: ubuntu 20.04.6 focal
        locale: utf-8
       machine: x86_64
       release: 5.4.0-162-generic
        system: Linux
       version: Ubuntu 20.04.6 focal
@nskkiselev nskkiselev added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 15, 2024
Copy link

welcome bot commented Aug 15, 2024

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@nskkiselev
Copy link
Author

Up.
Can anyone answer me?

@whytewolf
Copy link
Collaborator

saltclass ext_pillar is going away in 3008. It looks liike the master_top is still there. but that could just be an oversite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants