使用块时ansible playbook角色出现语法错误
我试图在角色任务文件中使用ansible 2.1的块,但得到如下复制的sytax错误:使用块时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
---
- 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开始添加了名称
关键字。