Syntax error while using block in ansible role

0 votes

I'm trying to use a block with Ansible. I got stuck with some error. need urgent help.

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

Error:

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"}
Mar 13 in Ansible by Bob
99 views

1 answer to this question.

0 votes

block should be on the same indentation level as other tasks.

Use it in the following way:

---
# transferring debian artifact to server
- block:
    - copy:
        src: ...
  rescue:
    - debug: msg="..."
answered Mar 13 by Kim

Related Questions In Ansible

0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,810 points
326 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Error while copying files using ansible role.

Add the following as an argument to ...READ MORE

answered Mar 14 in Ansible by Yesha
43 views
0 votes
3 answers