Overview
A task to write to remote files using Ansible. Frequently used.
Playbook
---
- hosts: vps
become: yes
user: root
tasks:
- name: Add text
blockinfile:
dest: /path/to/file
insertafter: '^# Add Here'
content: |
# New Line
Here is a new line.
Thoughts
It's easy to write.
References
lineinfile - Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression.