Ansible 2.9.9版本wait_for模块报错:缺失括号问题求助
解决Ansible 2.9.9 wait_for模块缺失括号报错问题
问题场景
使用Ansible 2.9.9执行以下wait_for模块Playbook时:
- name: wait for port 1433 to open wait_for: host: 10.20.30.20 port: 1433 state: started timeout: 30 delay: 0
出现报错:
module_stderr: Exception calling Create with 1 arguments at line.. def _ansiballz_main() An expression was expected after '('. Missing argument in parameter list if scriptdir is not Missing ( after if in if statement
解决方案
1. 更换为Windows专属模块(若目标节点是Windows)
通用wait_for模块在Windows节点上兼容性较差,改用Windows专属的win_wait_for模块即可解决语法解析问题,修改后的Playbook:
- name: wait for port 1433 to open win_wait_for: host: 10.20.30.20 port: 1433 state: started timeout: 30 delay: 0
2. 升级目标Windows节点的PowerShell版本
若坚持使用wait_for模块,需将目标Windows节点的PowerShell升级至3.0及以上(推荐5.1版本)。旧版本PowerShell的语法规则与Ansible生成的模块脚本不匹配,会触发此类括号缺失的语法报错。
3. 校验Playbook格式
确认YAML文件的缩进统一(建议用2个空格),避免因格式混乱导致模块解析异常。
内容的提问来源于stack exchange,提问作者Daniel
相关产品推荐
相关产品推荐

