【发布时间】:2022-11-15 14:17:03
【问题描述】:
我无法找到为什么这个简单的模式似乎与任何东西都不匹配。我有两个ansible主机作为目标。这是我的库存文件:
[web_Xubuntu]
192.168.160.128
[database_Fedora]
192.168.160.132
这就是我的 YAML 剧本的样子:
# Hosts: where our play will run and options it will run with
hosts: *Fedora
become: True
#gather_facts: False
# Vars: variables that will apply to the play, on all target systems
vars:
motd: "Welcome to Fedora Linux - Ansible Rocks\n"
# Tasks: the list of tasks that will be executed within the playbook
tasks:
- name: Configure a MOTD (message of the day)
copy:
content: "{{ motd }}"
dest: /etc/motd
notify: MOTD changed
# Handlers: the list of handlers that are executed as a notify key from a task
handlers:
- name: MOTD changed
debug:
msg: The MOTD was changed
在处理此剧本时,ansible 报告以下错误:
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
found undefined alias
The offending line appears to be:
# Hosts: where our play will run and options it will run with
hosts: *Fedora
^ here
您能否建议使用通配符的正确方法是什么?
【问题讨论】: