Member-only story
Ansible Troubleshooting: Resolving the “Invalid Argument” Error
Unraveling the Mystery of the “Invalid Argument” Error with Ansible’s File Module
Introduction
Welcome to another episode of Ansible Pilot! I’m Luca Berton, and today we’ll delve into Ansible troubleshooting, focusing on the infamous “Invalid Argument” error. This error commonly occurs when using the Ansible file
module to create a symlink in a Linux environment. Let's explore how to reproduce, troubleshoot, and fix this issue.
The Demo
To better understand Ansible troubleshooting, let’s dive into a live demo. We’ll create a playbook (invalidargument_error.yml
) that attempts to create a symbolic link using the file
module. In this example, we're trying to symlink /proc/cpuinfo
to ~/example
.
---
- name: file module demo
hosts: all
vars:
mylink: "~/example"
mysrc: "/proc/cpuinfo"
tasks:
- name: Creating a symlink
ansible.builtin.file:
path: "{{ mylink }}"
dest: "{{ mysrc }}"
state: link
Executing this playbook (ansible-playbook -i virtualmachines/demo/inventory troubleshooting/invalidargument_error.yml
)…