ansible报错--‘when‘ is not a valid attribute for a Play
创始人
2024-12-26 03:37:29
0
 ```c [root@mac-vm-temp ~]# ansible-playbook install.yml --syntax-check ERROR! 'when' is not a valid attribute for a Play  The error appears to be in '/root/install.yml': line 1, column 3, but may be elsewhere in the file depending on the exact syntax problem.  The offending line appears to be:   - name: install tools for compiling native addons from npm   ^ here  
 yml内容:`--- - name: install tools   yum: name=open state=present  ~                                ` ```c  把when条件删除后又报错  ```c [root@mac-vm-temp ~]# ansible-playbook install.yml --syntax-check ERROR! 'yum' is not a valid attribute for a Play  The error appears to be in '/root/install.yml': line 1, column 3, but may be elsewhere in the file depending on the exact syntax problem.  The offending line appears to be:   - name: install tools for compiling native addons from npm   ^ here  

怀疑是系统版本或ansible版本版本过低,所以yum模块无法使用,为了验证yum模块的问题,不适用playbook,直接用命令执行

[root@mac-vm-temp ~]# ansible all -m yum -a "name=nginx " 10.0.0.1| SUCCESS => {     "ansible_facts": {         "discovered_interpreter_python": "/usr/bin/python"     },      "changed": false,      "msg": "",      "rc": 0,      "results": [         "1:nginx-1.20.1-10.el7.x86_64 providing nginx is already installed"     ] }  

基本确认不是yum模块问题导致的,所以还是语法上有问题。

--- - hosts: tan   tasks:   - name: install tools     yum:       name: nginx       state: present 

修改后,正常了。
[root@mac-vm-temp ~]# ansible-playbook nginx.yml --syntax-check

playbook: nginx.yml

 

相关内容

热门资讯

透视辅助!aapoker怎么拿... 透视辅助!aapoker怎么拿好牌,aapoker免费透视脚本,存在挂教程(有挂黑科技);1、透视辅...
小程序广东雀神智能插件免费,开... 小程序广东雀神智能插件免费,开心泉州小程序辅助免费下载,白金岛手游的作弊码细节1、小程序广东雀神智能...
透视数据!wepoker怎么买... 透视数据!wepoker怎么买辅助(透视)一直真的是有挂(玩家教程)1、每一步都需要思考,不同水平的...
透视了解!aapoker怎么控... 透视了解!aapoker怎么控制牌,aapoker辅助软件合法吗,解密教程(有挂辅助)1、任何aap...
广东麻雀有什么技巧,来趣广西辅... 广东麻雀有什么技巧,来趣广西辅助,白金岛辅助有用吗解说;1、来趣广西辅助系统规律教程、来趣广西辅助辅...
透视了解!wepoker私人局... 透视了解!wepoker私人局俱乐部(透视)果然真的有挂(新2025教程);1、操作简单,无需注册,...
透视私人局!aapoker透视... 透视私人局!aapoker透视脚本,aapoker怎么控制牌,透视教程(有挂插件);在进入aapok...
广东雀神智能ios插件安装包,... 广东雀神智能ios插件安装包,欢乐联盟辅助软件,闲逸透视app为什么免费介绍;1)欢乐联盟辅助软件辅...
透视能赢!wepoker可以免... 透视能赢!wepoker可以免费玩吗(透视)总是真的是有挂(微扑克教程)1、上手简单,内置详细流程视...
透视挂透视!aapoker透视... 透视挂透视!aapoker透视脚本,aapoker辅助器怎么用,科技教程(有挂插件)在进入aapok...