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

Puppet中含特殊字符的密码配置失败问题求助

Puppet中含特殊字符的密码导致登录失败问题求助

问题描述

postgres用户密码为]htXXXXUyzJ5]yj!C时,无法被Puppet正常识别,执行Puppet命令后出现YAML解析错误,导致catalog无法获取。

执行pp命令报错信息

12:58
~# pp
Info: Using environment 'nre_restore_script'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Notice: Requesting catalog from xxx:8141 (xxx5)
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'lookup_options' failed: Unable to parse (/etc/puppetlabs/code/hieradata/hieradata-nodes-configuration/Linux/ops4ops/onezabbix/claranet/databases/rmp/preproduction/params.yaml): expected the node content, but found ']' while parsing a block node at line 74 column 23 (file: /etc/puppetlabs/code/environments/nre_restore_script/modules/stdlib/manifests/init.pp, line: 11, column: 3) on node XXXXX
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

相关文件说明

  • params.yaml文件第74行:配置项直接写入了含特殊字符的密码,格式为postgres_password: ]htXXXXUyzJ5]yj!C,未对字符串进行引号包裹,触发YAML解析报错。
  • 相关类定义:该类用于将密码写入.pgpass文件,逻辑为读取Hiera配置中的密码值,生成符合格式的.pgpass条目。

解决方法

  • 给YAML中的密码值添加引号:修改params.yaml中的密码配置,用单引号或双引号包裹密码,避免YAML解析器将特殊字符识别为语法符号,例如:
    postgres_password: ']htXXXXUyzJ5]yj!C'
    
  • 验证修复效果:修改后重新执行pp命令,确认catalog能正常获取;检查.pgpass文件中的密码是否正确写入,测试postgres用户登录是否正常。

内容的提问来源于stack exchange,提问作者JYOTI RAJAI

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 08:33:20