---
- name: Copy file to remote server
gather_facts: no
hosts: 127.0.0.1
tasks:
- name: Copy JSON file to remote server
copy:
dest: /apps/web/scripts/json
src: /tmp/report.json
remote_src: no
owner: user
group: group
mode: 0644
delegate_to: remote_server
become_user: awx
become: no
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/993a7441-8ea0-4181-9e87-4bfb715876ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jonathan lozada de la matta
AUTOMATION PRACTICE
- hosts: remoteserver
tasks:
- name: Ansible copy file to remote server
copy:
src: /tmp/somefile.txt
dest: /opt/remote/server/path
---
- name: Copy file to remote server
gather_facts: no
hosts: 127.0.0.1
tasks:
- set_fact:
jsonVariable: "{{ lookup('file', '/tmp/myfile.json') }}"
cacheable: true
- name: Create empty file on remote server
file:
path: "{{ item }}"
state: touch
mode: 0750
delegate_to: remoteServer
with_items:
- /opt/json/myfile.json
- name: Copy file to remote server
lineinfile:
dest: /opt/json/myfile.json
line: "{{ jsonVariable }}"
insertafter: EOF
delegate_to: remoteServer