Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用块时ansible playbook角色出现语法错误_Ansible_Ansible Playbook_Ansible 2.x - Fatal编程技术网

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

使用块时ansible playbook角色出现语法错误,ansible,ansible-playbook,ansible-2.x,Ansible,Ansible Playbook,Ansible 2.x,我试图在角色任务文件中使用ansible 2.1的块,但得到如下复制的sytax错误: --- - name: transferring debian artifact to server - block: - copy: src: "{{ lookup('fileglob','{{base_git_path}}testserver/target/*.deb', wantlist=true) | first }}" dest: "{{base_d

我试图在角色任务文件中使用ansible 2.1的块,但得到如下复制的sytax错误:

---
- 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"}

应与其他任务处于相同的缩进级别

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

正确语法:

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

应与其他任务处于相同的缩进级别

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

正确语法:

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

spaciba-将尝试恢复-你是一个救生员!对于那些现在发现这一点的人,从v2.3开始添加了
名称
关键字。spaciba-将尝试恢复-你是一个救生员!对于那些现在发现这一点的人,从v2.3开始添加了
名称
关键字。