AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible 'Destination Does Not Exist' Error: Fix Path Issues — Video Tutorial
Fix Ansible destination does not exist error. Resolve missing parent directories, wrong paths, and permission issues for copy, template, and file modules.
What You'll Learn
- Introduction
- The `destination does not exist` Error
- Reproducing and Fixing the Error
- Reproducing the Error
- Fixing the Error
- Verification
- Conclusion
- The Fix: Create Directory First
- Common Scenarios
- copy module
Full Tutorial Content
Introduction
Welcome to another episode of Ansible Pilot! I'm Luca Berton, and today we'll dive into troubleshooting Ansible, specifically focusing on the notorious "destination does not exist error." This error often occurs when attempting to download a file from a URL using Ansible, and it can be a stumbling block for many users. In this article, I'll walk you through the error, Playbooknstrate how to reproduce it, and provide a fix to ensure a smooth Ansible playbook execution.
The `destination does not exist` Error
Let's start by examining the error through a live Playbook. Below is a simplified Ansible playbook (`destinationdoesnotexist_error.yml`) that attempts to download a file using the `get_url` module:
```yaml
---
- name: Get_url module Playbook
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'
```
Upon execution, you might encounter the following error:
```bash
$ ansible-playbook -i inventory destinationdoesnotexist_error.yml
PLAY [Get_url module Playbook] ******************************************************************
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
```
The error message clearly indicates that the destination does not exist.
Reproducing and Fixing the Error
Reproducing the Error
To reproduce the error, we can use the provided playbook (`destinationdoesnotexist_error.yml`). This playbook attempts to download the Ansible archive into the home directory, resulting in the "destination does not exist" error.
Fixing the Error
Let's address the issue by modifying the playbook. In the fixed version (`destinationdoesnotexist_fix.yml`), we adjust the destination path to include the current directory:
```yaml
---
- name: Get_url module Playbook
hosts: all
become: false
vars:
myurl: "https://releases.ansible.com/ansible/ansible-2.9.25.tar.gz"
mycrc: "sha256:https://releases.ansible.com/ansible/
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 6 min
- Category: troubleshooting
Read the full written article: Ansible 'Destination Does Not Exist' Error: Fix Path Issues
Related Video Tutorials
- Ansible 'chgrp failed' Error: Fix Group Ownership Permission Issues — Fix Ansible chgrp failed error when setting file group ownership. Resolve permission denied, missing groups, and mounted filesystem issues with troubleshooting.
- Ansible 'fatal: template error while templating string' Fix (Guide) — Fix Ansible template error while templating string. Resolve undefined variables, syntax errors, and Jinja2 issues in playbooks and templates with examples.
- Ansible 'Missing Required Arguments' Error: Fix Missing Module Parameters — Fix the Ansible 'missing required arguments' error. Identify required vs optional module parameters, check documentation, and troubleshoot common parameter.
- Ansible 'Failure Downloading' Error: Fix get_url & uri Module Issues — Fix Ansible 'failure downloading' errors with get_url and uri modules. Covers SSL certificate issues, proxy settings, timeouts, and authentication for file.
- Ansible 'urlopen error' Fix: SSL, Proxy & Network Connection Issues — Fix Ansible urlopen error for SSL certificate failures, proxy issues, DNS resolution, and network timeouts.
- Ansible troubleshooting - AWS Failed to import the required Python library (botocore or boto3) — Learn how to troubleshoot and fix the \"Failed to import the required Python library (botocore or boto3)\" error in Ansible for AWS with a live Playbook.