DEV Community

Cover image for Copy Local Files to Remote with Ansible
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

Copy Local Files to Remote with Ansible

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

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

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

Top comments (0)