|
Jump to: Shell |
copy
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html
|
## PLAYBOOK
copy1.yml |
---
- name: Copy module - example 1
hosts: all
become: True
vars:
srcfile: "myscript.sh"
srcdir: "/home/ansible"
destdir: "/home/ansible"
owner: "ansible"
group: "ansible"
perm: "0755"
tasks:
- name: Copy file and set ownership and permissions
copy:
src: "{{ srcdir }}/{{ srcfile }}"
dest: "{{ destdir }}"
owner: "{{ owner }}"
group: "{{ group }}"
mode: "{{ perm }}"
- name: Verify file was copied
shell: "ls -ldh {{ destdir }}/{{ srcfile }}"
register: listing
- debug: msg="{{ listing.stdout }}"
|
|
## OUTPUT
|
|
|
References
- ansible.builtin plugins and modules index
- ansible collections index
- ansible loops
- ansible conditionals
- ansible playbook error handling
- ansible playbook tests
- ansible playbook blocks
- ansible playbook roles
- ansible playbook files
|
|