Ansible core 2.15.3中ini_file模块设section为null时报错求助
问题解决:Ansible ini_file模块section设null报错
在Ansible Core 2.15.3环境中,使用community.general.ini_file模块时,设置section: null会触发类型转换错误,这是因为该版本组合下,模块无法将Python的None类型(YAML中null的解析结果)转换为字符串处理,尽管文档标注section允许设为null。
正确的写法是使用空字符串替代null,以此表示ini文件中的全局选项(不在任何section内的配置行):
- name: Ensure fav=juice is in file community.general.ini_file: path: /home/lab/test.conf section: '' option: fav value: juice
修改后执行Playbook,模块会将fav=juice写入到test.conf的全局区域,达到你原本期望的效果。
内容的提问来源于stack exchange,提问作者dealbitte
相关产品推荐
相关产品推荐

