ansible注意的和错误代码分析

一、需要注意的点

  • 分清楚这个是主控节点还是被控节点的操作,有的时候是一个文件从主控到被控节点,还是被控节点的文件到主控节点上面了

剧本执行报错代码

# 仔细看,报错的原因就是ansibel_lvm 未定义,写错了变量名

TASK [research not exsist] *********************************************************************
fatal: [node1]: FAILED! => {"msg": "The conditional check 'ansible_hostname=='node1' and 'research' not in ansibel_lvm.vgs' failed. The error was: error while evaluating conditional (ansible_hostname=='node1' and 'research' not in ansibel_lvm.vgs): 'ansibel_lvm' is undefined. 'ansibel_lvm' is undefined\n\nThe error appears to be in '/home/devops/ansible/yml/lvs.yml': line 20, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n      when: \"ansible_hostname=='node1' and 'research' in ansible_lvm.vgs\"\n    - name: research not exist\n      ^ here\n"}

# permanant变量写错了,应该是permanent
TASK [firewalld] ******************************************************************************
fatal: [node1]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (firewalld) module: permananet. Supported parameters include: icmp_block, icmp_block_inversion, immediate, interface, masquerade, offline, permanent, port, port_forward, protocol, rich_rule, service, source, state, target, timeout, zone."}
fatal: [node2]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (firewalld) module: permananet. Supported parameters include: icmp_block, icmp_block_inversion, immediate, interface, masquerade, offline, permanent, port, port_forward, protocol, rich_rule, service, source, state, target, timeout, zone."}

posted @ 2025-09-25 22:10  乔的港口  阅读(4)  评论(0)    收藏  举报