gpt4 book ai didi

ansible - 运行以下 Playbook 语法似乎是正确的,但出现以下错误!- 'blockinfile' 不是 Play 的有效属性

转载 作者:行者123 更新时间:2023-12-01 10:35:23 25 4
gpt4 key购买 nike

运行以下 Playbook 语法似乎是正确的,但出现以下错误!-

ERROR! 'blockinfile' is not a valid attribute for a Play

The error appears to have been in '/root/playbook1.yml': line 2, column 3, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: insertupdate
^ here

我的剧本文件代码是:
---
- name: insertupdate
blockinfile:
dest: /etc/network/interfaces
block: |
iface eth2 inet static
address 192.168.0.1
netmask 255.255.255.0

顺便说一下,我使用的是 Ansible 版本 2.x

最佳答案

您的剧本丢失 tasks .就像错误所说的那样,blockinfile不是剧中的有效属性。你的剧本应该是这样的。只是一个例子,不要使用此代码。

- hosts: 127.0.0.1

tasks:
- name: insertupdate
blockinfile:
dest: /etc/network/interfaces
block: |
iface eth2 inet static
address 192.168.0.1
netmask 255.255.255.0

关于ansible - 运行以下 Playbook 语法似乎是正确的,但出现以下错误!- 'blockinfile' 不是 Play 的有效属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36468870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com