Solution: Fixing Errors in the Playbook
Look at the solution to the previous exercise.
We'll cover the following...
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_contentCode to read the mounts file
Explanation
For the
read_file.ymlfile:Line 5: In the
read_file.ymlfile, we fix the path to/proc/mountsfor the user-defined variablemyfilein ...