首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ansible playbook缩进问题

Ansible playbook缩进问题
EN

Stack Overflow用户
提问于 2021-08-10 08:43:48
回答 1查看 159关注 0票数 0

我开始使用Ansible,这是我第一次使用角色。我有一个主要的剧本,在安装Docker的时候,我只是想区分Ubuntu和CentOS,但是由于某些原因,我不能让它工作。是不是压痕的问题?

代码语言:javascript
复制
- 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"
代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

发布于 2021-08-10 08:53:42

import_tasks没有连字符(-)。请查看https://docs.ansible.com/ansible/2.4/import_tasks_module.html上的示例

代码语言:javascript
复制
---
- 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"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68723620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档