Infrastructure 2017-09-26

Copy Local Files to Remote with Ansible

Learn Ansible copy module syntax to transfer directory contents to remote servers with proper file permissions configuration.

Read in: ja
Copy Local Files to Remote with Ansible

Overview

This task involves copying files (contents of a directory) from a local machine to a remote location using Ansible.

Playbook

---
- hosts: vps
  become: yes
  user: root
  tasks:
  - name: Copy a directory
    copy:
     src: /path/to/directory/
     dest: /usr/local/bin/
     mode: u+x

This task copies all contents of a directory to the remote /usr/local/bin directory. Permissions are also specified.

Thoughts

There don't seem to be any tricky points; it works as documented.

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