Ansible 错误';sudo';不是游戏的有效属性
我有一个ansible play文件,它必须执行两个任务,首先在本地机器上获取磁盘使用率,另一个任务是获取远程机器的磁盘使用率,并在远程机器上安装apache2 当我试图运行该文件时,我得到了一个错误“error!sudo”不是一个有效的播放属性“ 当我从yml文件中删除sudo和apt部分时,它运行良好 我使用的是ansible 2.9.4。以下是两个剧本文件: 文件运行时没有任何错误, 文件运行时出错: 完整错误消息:Ansible 错误';sudo';不是游戏的有效属性,ansible,Ansible,我有一个ansible play文件,它必须执行两个任务,首先在本地机器上获取磁盘使用率,另一个任务是获取远程机器的磁盘使用率,并在远程机器上安装apache2 当我试图运行该文件时,我得到了一个错误“error!sudo”不是一个有效的播放属性“ 当我从yml文件中删除sudo和apt部分时,它运行良好 我使用的是ansible 2.9.4。以下是两个剧本文件: 文件运行时没有任何错误, 文件运行时出错: 完整错误消息: ERROR! 'sudo' is not a valid attribu
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
使用been:yes它将以root用户身份运行任务
Ansible play关键字
sudo
was(很久以前)
看。使用:
been:true
---
-
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
- hosts: RemoteMachine1
name: play2
become: 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