我开始使用Ansible,这是我第一次使用角色。我有一个主要的剧本,在安装Docker的时候,我只是想区分Ubuntu和CentOS,但是由于某些原因,我不能让它工作。是不是压痕的问题?
- name: Install Docker for Ubuntu and CentOS
hosts: all
remote_user: xyz
tasks:
- name: Import tasks for Ubuntu
- import_tasks: ubuntu_Docker.yml
when: ansible_facts['os_family'] == "Debian"
- name: Import tasks for CentOS
- import_tasks: centos_Docker.yml
when: ansible_facts['distribution'] == "CentOS"The error appears to be in 'filelocation': line 9, column 6, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Import tasks for Ubuntu
^ here (points at the n)我试了很多次缩进,就是不能让它工作。这可能是微不足道的,但再说一次:这是一个新手,并且在方面有一点confused...Thx。
发布于 2021-08-10 08:53:42
import_tasks没有连字符(-)。请查看https://docs.ansible.com/ansible/2.4/import_tasks_module.html上的示例
---
- name: Install Docker for Ubuntu and CentOS
hosts: all
remote_user: xyz
tasks:
- name: Import tasks for Ubuntu
import_tasks: ubuntu_Docker.yml
when: ansible_facts['os_family'] == "Debian"
- name: Import tasks for CentOS
import_tasks: centos_Docker.yml
when: ansible_facts['distribution'] == "CentOS"https://stackoverflow.com/questions/68723620
复制相似问题