DEV Community

Cover image for Writing to Remote Files with Ansible
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

Writing to Remote Files with Ansible

This article was originally published on bmf-tech.com.

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.
Enter fullscreen mode Exit fullscreen mode

Thoughts

It's easy to write.

References

Top comments (0)