Copy Files and Append Text to Remote Host - RHCE.pdf

support8872 186 views 10 slides Oct 09, 2024
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Slides on how to copy files and append text to remote host using ansible - Part of RHCE syllabus


Slide Content

Copy Files and Append Text to
Remote Hosts

●To copy the files from control node to remote hosts

●Attributes
○src: Source file to be copied
○dest: Destination directory on the remote clients
○owner: Sets the file owner to root
○group: Sets the file group to root
○mode: Sets the file permissions

●Link: copy module — Ansible Documentation




Copy Module

●Verify that remote host is reachable using ping module
Command: ansible all -m ping

Copy files to Remote Hosts

●Execute the playbook on control node
Command: ansible-playbook <file-name> . yml

●Verify if the text file is copied to the directory of the remote host
Command: ls /tmp | grep sample.txt

●Module to insert, update, or remove a block of text in a file in Ansible

●Attributes
○path: specifies the path where the file should be created
○state: create a file
○block: text which is added to the file

●Link: blockinfile — Ansible Documentation
Blockinfile Module

Append text to the text file

●Execute the playbook on control node
Command: ansible-playbook <file-name> . yml

●Verify if the text is appended to the file on remote host
Command: ansible-playbook <file-name> . yml

Appended text