Search⌘ K
AI Features

Solution: Fixing Errors in the Playbook

Understand how to identify and resolve common errors in Ansible playbooks. Learn to correct variable paths, fix indentation and syntax mistakes, and handle missing parameters. This lesson guides you through debugging steps to ensure your playbook runs smoothly and outputs expected results.

We'll cover the following...
---
- name: Exercise
  hosts: all
  vars:
    myfile: "/proc/mounts"
  tasks:
   - name: Set file_content
     ansible.builtin.set_fact:
       file_content: "{{ lookup('file', myfile) }}"

   - name: Display the current mounts
     ansible.builtin.debug:
       var: file_content
Code to read the mounts file

Explanation

  • For the read_file.yml file:

    • Line 5: In the read_file.yml file, we fix the path to  /proc/mounts for the user-defined variable myfile  in ...