You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Salt State结合Pillar数据运行失败,报错状态未按列表定义求助

Fixing the Salt State Compilation Error

Let's break down the issue and fix your Salt State file step by step.

The Root Cause

The error message mentions the radiusgroup state isn't formed as a list, but the actual culprit is a syntax mistake in your first state (freeradius). In Salt, when defining a state with no arguments, you need to explicitly indicate it's a state function (not just a string) by adding a colon and an empty list. Your original freeradius line was missing this, which confused the YAML parser and led to a misleading error about the radiusgroup state.

Corrected Salt State

Here's the fixed version of your SLS file:

freeradius:
  pkg.installed: []  # Added colon and empty list for valid state syntax
radiusgroup:
  group.present:
    - name: radiusadm
    - gid: 666
{% for user, args in pillar['users'].items() %}
{% if ( user not in pillar['absents'] ) and ( 'radiuspassword' in args ) %}
shadow_hash_{{ user }}:
  user.present:
    - name: {{ user }}
    - password: {{ args['radiuspassword'] }}
{% endif %}
{% endfor %}

Key Changes Explained

  1. Fixed freeradius state: Changed pkg.installed to pkg.installed: []. This tells Salt that pkg.installed is a state function with no arguments, which aligns with Salt's required YAML structure.
  2. Preserved valid radiusgroup state: Your original group.present configuration was already correct (using a list of arguments), so no changes were needed here.
  3. Jinja templating remains intact: The loop for user accounts is correctly structured and will work as expected once the YAML syntax is fixed.

Additional Checks

  • Ensure all indentation uses spaces (not tabs) — YAML is strict about this, and tabs can cause hidden parsing errors.
  • Your Pillar data is correctly formatted, so no changes are needed there.

Content of the question来源于stack exchange,提问作者sapios

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 13:22:57