Infrastructure 2017-09-26

Writing to Remote Files with Ansible

Write and modify remote files using Ansible blockinfile module for infrastructure configuration management and automation.

Read in: ja
Writing to Remote Files with Ansible

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

Tags: Ansible
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles