Search⌘ K
AI Features

Solution: Ansible Language

Explore the fundamentals of Ansible language by learning to write playbooks that use variables, templates, and built-in facts. Understand how to manage inventory, define tasks, and generate reports dynamically with Ansible facts. This lesson equips you to automate file creation on target hosts using simple but powerful Ansible features.

We'll cover the following...
DATE: {{ ansible_date_time.date }}
vCPU: {{ ansible_processor_vcpus }}
RAM: {{ ansible_memtotal_mb }}
Created by Ansible {{ ansible_version.string }}
Code for creating a resource usage text report

Explanation

  • For the report.yml playbook file:

    • Line 2: We write the play named exercise.

    • Line 3: We specify the all host for the target hosts of execution.

    • Lines 4–5: We create a variable named myfile with the value "/usercode/report.txt".

    • ...