Wednesday, October 7, 2020

Copy a text file from your machine to Remote Host Using Ansible playbook

 Step1: create your own inventory file in any folder i have created a folder name inventory in which i have created a file name cpIn.ini(inventory file for host)

$ cat cpIn.ini

[host-group]

localhost

in cpIn.ini i have created a host group in which i have taken localhost as a host

Step2: write playbook copy_playbook.yml
 ---
 - hosts: host-group
   become: yes
   become_user: host machine name(changing permission from rad to write(from localhost to destination host))
   tasks:
     - name: copy file to remote host
       copy:
         src: /source/file/destination/path
         dest: /host/machine/destination/path

step 3 write command

$ ansible-playbook copy_playbook.yml -i inventory/inv.ini(inventory file destination)


Copy a text file from your machine to Remote Host Using Ansible playbook

 Step1: create your own inventory file in any folder i have created a folder name inventory in which i have created a file name cpIn.ini(inv...