使用块时 ansible playbook 角色出现语法错误

syntax error with ansible playbook role when using block

我正在尝试在角色任务文件中使用带有 ansible 2.1 的块,但收到语法错误,如下所示:

---
- name: transferring debian artifact to server
  - block:
     - copy:
         src: "{{ lookup('fileglob','{{base_git_path}}testserver/target/*.deb', wantlist=true) | first }}"
         dest: "{{base_destination_path}}"
         owner: xyz
         group: xyz
         mode: 644
         become: true
    rescue:
     - debug: msg="error while locating debian file in tmp directory"

语法错误

fatal: [akka_1]: FAILED! => {"failed": true, "reason": "Syntax Error while loading YAML.\n\n\nThe error appears to have been in '/home/user/test/ansible/testproj/playbooks/roles/tmp3/tasks/synchronize.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- name: transferring debian artifact to server\n  - block:\n  ^ here\n"}

block 应该与其他任务处于同一缩进级别。

块也不能有名称。 ⟵ 更新:自 Ansible 2.3 以来已更改,块 可以有 名称。

正确的语法:

---
# transferring debian artifact to server
- block:
    - copy:
        src: ...
  rescue:
    - debug: msg="..."