有效Ansible代码上的Yamllint缩进警告

时间:2017-11-21 16:16:13

标签: ansible yaml

我的剧本中有以下任务:

    - name: gather os specific variables
      include_vars: "{{ item }}"
      with_first_found:
        - files:
          - "{{ ansible_distro }}-{{
                ansible_distribution_version|lower|replace('/', '_') }}.yml"
          - "{{ ansible_distro }}-{{ ansible_distribution_release }}.yml"
          - "{{ ansible_distro }}-{{
                ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
          - "{{ ansible_distro }}.yml"
          - "{{ ansible_os_family|lower }}.yml"
          paths:
          - ../vars
          skip: true

https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/lookup/first_found.py开始这是正确的。

Yamllint给了我以下错误:

  10:7      warning  wrong indentation: expected 8 but found 6  (indentation)
  18:7      warning  wrong indentation: expected 8 but found 6  (indentation)

为什么Yamllint在这里抱怨,我怎么能纠正它以便它仍然是一个有效的Ansible任务?

1 个答案:

答案 0 :(得分:0)

正确解析,但不足以让linter传递。

添加两个空格以获得更好的外观:

  with_first_found:
    - files:
        - "{{ ansible_distro }}-{{
      ^^ here

在这里:

      paths:
        - ../vars
      ^^