Ansible Pilot

Ansible troubleshooting - Destination does not exist

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to reproduce the destination does not exist error in Ansible, troubleshooting, and fix to be able to successfully download a file from an URL in a home directory with your Ansible playbook.

Today we’re going to talk about Ansible troubleshooting, specifically about the destination does not exist error. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

demo

The best way of talking about Ansible troubleshooting is to jump in a live demo to show you practically the destination does not exist error and how to solve it!

error code

---
- name: get_url module demo
  hosts: all
  become: false
  vars:
    myurl: "https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz"
    mycrc: "sha256:https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz.sha"
    mydest: "ansible-2.9.25.tar.gz"
  tasks:
    - name: download file
      ansible.builtin.get_url:
        url: "{{ myurl }}"
        dest: "{{ mydest }}"
        checksum: "{{ mycrc }}"
        mode: '0644'

error execution

$ ansible-playbook -i virtualmachines/demo/inventory troubleshooting/destinationdoesnotexist_error.yml

PLAY [get_url module demo] ******************************************************************

TASK [Gathering Facts] **********************************************************************
ok: [demo.example.com]

TASK [download file] ************************************************************************
fatal: [demo.example.com]: FAILED! => {"changed": false, "checksum_dest": null, "checksum_src": "574e24659f555fe370571167d3d44704671f1773", "dest": "ansible-2.9.25.tar.gz", "elapsed": 3, "msg": "Destination  does not exist", "src": "/home/devops/.ansible/tmp/ansible-tmp-1640555219.326019-1431-267536126421544/tmpmx_ra0hd", "url": "https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz"}

PLAY RECAP **********************************************************************************
demo.example.com           : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

fix code

---
- name: get_url module demo
  hosts: all
  become: false
  vars:
    myurl: "https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz"
    mycrc: "sha256:https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz.sha"
    mydest: "ansible-2.9.25.tar.gz"
  tasks:
    - name: download file
      ansible.builtin.get_url:
        url: "{{ myurl }}"
        dest: "./{{ mydest }}"
        checksum: "{{ mycrc }}"
        mode: '0644'

fix execution

$ ansible-playbook -i virtualmachines/demo/inventory troubleshooting/destinationdoesnotexist_fix.yml 

PLAY [get_url module demo] ******************************************************************

TASK [Gathering Facts] **********************************************************************
ok: [demo.example.com]

TASK [download file] ************************************************************************
changed: [demo.example.com]

PLAY RECAP **********************************************************************************
demo.example.com           : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

verification

$ ssh [email protected]
[[email protected] ~]$ ls -al
total 13964
drwx------. 4 devops wheel      140 Dec 26 21:47 .
drwxr-xr-x. 5 root   root        50 Dec 15 13:00 ..
drwx------. 3 devops wheel       17 Dec 15 13:00 .ansible
-rw-------. 1 devops wheel      322 Dec 26 21:46 .bash_history
-rw-r--r--. 1 devops wheel       18 Jul 26 09:51 .bash_logout
-rw-r--r--. 1 devops wheel      141 Jul 26 09:51 .bash_profile
-rw-r--r--. 1 devops wheel      376 Jul 26 09:51 .bashrc
drwx------. 2 devops wheel       29 Dec 15 13:00 .ssh
-rw-r--r--. 1 devops wheel 14280306 Dec 26 21:47 ansible-2.9.25.tar.gz

code with ❤️ in GitHub

Recap

Now you know better how to troubleshoot the Ansible destination does not exist error and solve it! Subscribe to the YouTube channel, Medium, Website and Twitter to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 100+ Automation Examples For Linux and Windows System Administrator and DevOps

Access the Complete Book and Learn Quick Ansible by 200+ Examples

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Trustpilot
Follow me

Subscribe not to miss any new releases

January 4, 2022

FREE Top 10 Best Practices

Top 10 Best Practices of Ansible Automation: save time, reduce errors and stress