saltstack / saltstack/salt

[BUG] pyobjects renderer fails with Sls require

Open
#63,173 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage Renderers Requisite
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description

Using the pyobjects renderer, specifying a require requisite argument on Sls require=Sls("requirement") gives an error

[CRITICAL] Rendering SLS test failed, render error: name 'Sls' is not defined
...
NameError: name 'Sls is not defined

The equivalent to specify a requirement on a full sls in jinja|yaml which works is

include:
  - requirement

"/testfile":
   file.managed:
     - owner: "root"
     - group: "root"
     - require:
       - sls: "requirement"

Setup

  • ec2 instance running rhel 7.9

  • classic packaging (yum install salt-minion)

  • Create /srv/salt/test.sls:

    #!pyobjects
    include("requirement")
    File.managed("/testfile", owner="root", group="root", require=Sls("requirement"))
    
  • [] Create /srv/salt/requirement.sls:

    #!pyobjects
    File.managed("/requirement", owner="root", group="root")
    

Steps to Reproduce the behavior

salt-call --local state.apply test

Expected behavior
Expected to create a require requisite on the full sls requirement file.

Versions Report

salt-call --versions-report
Salt Version:
        Salt: 3004.1

System Versions:
      dist: rhel 7.9 Maipo
    locale: UTF-8
   release: 3.10.0-1160.15.2.el7.x86_64
   system: Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with salt-call --local state.apply test using /srv/salt/test.sls and /srv/salt/requirement.sls. Trace how the pyobjects renderer resolves the Sls requisite and compare it with the working jinja|yaml form. Done means the pyobjects example creates the requisite without a NameError and existing renderer tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.