错误!';sudo';不是剧本的有效属性 [英] ERROR! 'sudo' is not a valid attribute for a Play
本文介绍了错误!';sudo';不是剧本的有效属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Ansible play文件,它必须执行两个任务,第一个任务是在本地计算机上获取磁盘使用率,另一个任务是获取远程计算机的磁盘使用率并在远程计算机上安装apache2。
当我尝试运行该文件时,收到错误";error!"sudo"不是播放的有效属性&qot; 当我从YML文件中删除sudo和apt部分时,它运行正常。我使用的是Ansible 2.9.4。以下是两个攻略文件:
文件正在运行,没有任何错误,
---
-
connection: local
hosts: localhost
name: play1
tasks:
-
command: "df -h"
name: "Find the disk space available"
-
command: "ls -lrt"
name: "List all the files"
-
name: "List All the Files"
register: output
shell: "ls -lrt"
-
debug: var=output.stdout_lines
-
hosts: RemoteMachine1
name: play2
tasks:
- name: "Find the disk space"
command: "df -h"
register: result
- debug: var=result.stdout_lines
文件运行时出错:
---
-
connection: local
hosts: localhost
name: play1
tasks:
-
command: "df -h"
name: "Find the disk space available"
-
command: "ls -lrt"
name: "List all the files"
-
name: "List All the Files"
register: output
shell: "ls -lrt"
-
debug: var=output.stdout_lines
-
hosts: RemoteMachine1
name: play2
sudo: yes
tasks:
- name: "Find the disk space"
command: "df -h"
register: result
- name: "Install Apache in the remote machine"
apt: name=apache2 state=latest
- debug: var=result.stdout_lines
完整错误消息:
ERROR! 'sudo' is not a valid attribute for a Play
The error appears to be in '/home/Documents/ansible/play.yml': line 20, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
-
hosts: RemoteMachine1
^ here
推荐答案
可能的播放关键字sudo
(很久以前)deprecated with warnings in version 2.0 and removed in version 2.2
become: true
这篇关于错误!';sudo';不是剧本的有效属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文