Hands-on task
Ansible: idempotent line in a file
The config /etc/app/hosts.conf already has entries. Write a playbook /root/line.yml that ensures the presence of the line db.local 127.0.0.1 in it (the lineinfile module — adds it if the line is missing and won't duplicate it on a repeat run), leaving the other lines alone. Run it. The playbook must work whatever the file contains: add the line if it's missing, leave other entries alone, and change nothing on a second run.
- ansible
- lineinfile
- idempotency
- editing configs
- iac